Java 类com.facebook.presto.tpch.TpchConnectorFactory 实例源码

项目:presto-hyperloglog    文件:TestHyperLogLogQueries.java   
private static LocalQueryRunner createLocalQueryRunner()
{
    Session defaultSession = testSessionBuilder()
            .setCatalog("tpch")
            .setSchema(TINY_SCHEMA_NAME)
            .build();

    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
    InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager();
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of());

    HyperLogLogPlugin plugin = new HyperLogLogPlugin();
    for (Type type : plugin.getTypes()) {
        localQueryRunner.getTypeManager().addType(type);
    }
    for (ParametricType parametricType : plugin.getParametricTypes()) {
        localQueryRunner.getTypeManager().addParametricType(parametricType);
    }

    localQueryRunner.getMetadata().addFunctions(extractFunctions(plugin.getFunctions()));

    return localQueryRunner;
}
项目:presto    文件:BenchmarkQueryRunner.java   
public static LocalQueryRunner createLocalQueryRunner(boolean hashingEnabled)
{
    SessionBuilder sessionBuilder = testSessionBuilder()
            .setCatalog("tpch")
            .setSchema(TINY_SCHEMA_NAME);

    if (hashingEnabled) {
        sessionBuilder.setSystemProperties(ImmutableMap.of("optimizer.optimize_hash_generation", "true"));
    }

    Session session = sessionBuilder.build();
    LocalQueryRunner localQueryRunner = queryRunnerWithInitialTransaction(session);

    // add tpch
    InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager();
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of());

    return localQueryRunner;
}
项目:presto    文件:RaptorBenchmarkQueryRunner.java   
public static LocalQueryRunner createLocalQueryRunner()
{
    Session session = testSessionBuilder()
            .setCatalog("raptor")
            .setSchema("benchmark")
            .build();
    LocalQueryRunner localQueryRunner = new LocalQueryRunner(session);

    // add tpch
    InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager();
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of());

    // add raptor
    ConnectorFactory raptorConnectorFactory = createRaptorConnectorFactory(TPCH_CACHE_DIR, nodeManager);
    localQueryRunner.createCatalog("raptor", raptorConnectorFactory, ImmutableMap.of());

    if (!localQueryRunner.tableExists(session, "orders")) {
        localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch.sf1.orders");
    }
    if (!localQueryRunner.tableExists(session, "lineitem")) {
        localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch.sf1.lineitem");
    }
    return localQueryRunner;
}
项目:presto    文件:TestLocalQueries.java   
private static LocalQueryRunner createLocalQueryRunner()
{
    Session defaultSession = testSessionBuilder()
            .setCatalog("local")
            .setSchema(TINY_SCHEMA_NAME)
            .build();

    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);

    // add the tpch catalog
    // local queries run directly against the generator
    localQueryRunner.createCatalog(
            defaultSession.getCatalog().get(),
            new TpchConnectorFactory(localQueryRunner.getNodeManager(), 1),
            ImmutableMap.<String, String>of());
    localQueryRunner.createCatalog(TPCH_SAMPLED_SCHEMA, new SampledTpchConnectorFactory(localQueryRunner.getNodeManager(), 1, 2), ImmutableMap.<String, String>of());

    localQueryRunner.getMetadata().addFunctions(CUSTOM_FUNCTIONS);

    SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager();
    sessionPropertyManager.addSystemSessionProperties(AbstractTestQueries.TEST_SYSTEM_PROPERTIES);
    sessionPropertyManager.addConnectorSessionProperties("connector", AbstractTestQueries.TEST_CATALOG_PROPERTIES);

    return localQueryRunner;
}
项目:presto    文件:TestTransactionManager.java   
@Test
public void testTransactionWorkflow()
        throws Exception
{
    try (IdleCheckExecutor executor = new IdleCheckExecutor()) {
        TransactionManager transactionManager = TransactionManager.create(new TransactionManagerConfig(), executor.getExecutor(), finishingExecutor);

        Connector c1 = new TpchConnectorFactory(new InMemoryNodeManager()).create("c1", ImmutableMap.of());
        transactionManager.addConnector("c1", c1);

        TransactionId transactionId = transactionManager.beginTransaction(false);

        Assert.assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
        TransactionInfo transactionInfo = transactionManager.getTransactionInfo(transactionId);
        Assert.assertFalse(transactionInfo.isAutoCommitContext());
        Assert.assertTrue(transactionInfo.getConnectorIds().isEmpty());
        Assert.assertFalse(transactionInfo.getWrittenConnectorId().isPresent());

        ConnectorMetadata metadata = transactionManager.getMetadata(transactionId, "c1");
        metadata.listSchemaNames(TEST_SESSION.toConnectorSession("c1"));
        transactionInfo = transactionManager.getTransactionInfo(transactionId);
        Assert.assertEquals(transactionInfo.getConnectorIds(), ImmutableList.of("c1"));
        Assert.assertFalse(transactionInfo.getWrittenConnectorId().isPresent());

        transactionManager.asyncCommit(transactionId).join();

        Assert.assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
    }
}
项目:presto    文件:TestTransactionManager.java   
@Test
public void testAbortedTransactionWorkflow()
        throws Exception
{
    try (IdleCheckExecutor executor = new IdleCheckExecutor()) {
        TransactionManager transactionManager = TransactionManager.create(new TransactionManagerConfig(), executor.getExecutor(), finishingExecutor);

        Connector c1 = new TpchConnectorFactory(new InMemoryNodeManager()).create("c1", ImmutableMap.of());
        transactionManager.addConnector("c1", c1);

        TransactionId transactionId = transactionManager.beginTransaction(false);

        Assert.assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
        TransactionInfo transactionInfo = transactionManager.getTransactionInfo(transactionId);
        Assert.assertFalse(transactionInfo.isAutoCommitContext());
        Assert.assertTrue(transactionInfo.getConnectorIds().isEmpty());
        Assert.assertFalse(transactionInfo.getWrittenConnectorId().isPresent());

        ConnectorMetadata metadata = transactionManager.getMetadata(transactionId, "c1");
        metadata.listSchemaNames(TEST_SESSION.toConnectorSession("c1"));
        transactionInfo = transactionManager.getTransactionInfo(transactionId);
        Assert.assertEquals(transactionInfo.getConnectorIds(), ImmutableList.of("c1"));
        Assert.assertFalse(transactionInfo.getWrittenConnectorId().isPresent());

        transactionManager.asyncAbort(transactionId).join();

        Assert.assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
    }
}
项目:presto    文件:TestMLQueries.java   
private static LocalQueryRunner createLocalQueryRunner()
{
    Session defaultSession = testSessionBuilder()
            .setCatalog("local")
            .setSchema(TINY_SCHEMA_NAME)
            .build();

    LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);

    // add the tpch catalog
    // local queries run directly against the generator
    localQueryRunner.createCatalog(
            defaultSession.getCatalog().get(),
            new TpchConnectorFactory(localQueryRunner.getNodeManager(), 1),
            ImmutableMap.<String, String>of());

    MLPlugin plugin = new MLPlugin();
    plugin.setTypeManager(localQueryRunner.getTypeManager());
    for (Type type : plugin.getServices(Type.class)) {
        localQueryRunner.getTypeManager().addType(type);
    }
    for (ParametricType parametricType : plugin.getServices(ParametricType.class)) {
        localQueryRunner.getTypeManager().addParametricType(parametricType);
    }
    localQueryRunner.getMetadata().getFunctionRegistry().addFunctions(Iterables.getOnlyElement(plugin.getServices(FunctionFactory.class)).listFunctions());

    return localQueryRunner;
}
项目:presto    文件:HiveBenchmarkQueryRunner.java   
public static LocalQueryRunner createLocalQueryRunner(File tempDir)
{
    Session session = testSessionBuilder()
            .setCatalog("hive")
            .setSchema("tpch")
            .build();

    LocalQueryRunner localQueryRunner = new LocalQueryRunner(session);

    // add tpch
    InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager();
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of());

    // add hive
    File hiveDir = new File(tempDir, "hive_data");
    InMemoryHiveMetastore metastore = new InMemoryHiveMetastore(hiveDir);
    File tpchDataDir = new File(hiveDir, "tpch");
    metastore.createDatabase(new Database("tpch", null, tpchDataDir.toURI().toString(), null));

    HiveConnectorFactory hiveConnectorFactory = new HiveConnectorFactory(
            "hive",
            ImmutableMap.of("node.environment", "test"),
            HiveBenchmarkQueryRunner.class.getClassLoader(),
            metastore,
            new TypeRegistry(),
            new GroupByHashPageIndexerFactory());

    Map<String, String> hiveCatalogConfig = ImmutableMap.<String, String>builder()
            .put("hive.metastore.uri", "thrift://none.invalid:0")
            .put("hive.max-split-size", "10GB")
            .build();

    localQueryRunner.createCatalog("hive", hiveConnectorFactory, hiveCatalogConfig);

    localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch.sf1.orders");
    localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch.sf1.lineitem");
    return localQueryRunner;
}
项目:presto-bloomfilter    文件:TestBloomFilterQueries.java   
private static LocalQueryRunnerSupplier createQueryRunner()
{
    try {
        Session defaultSession = testSessionBuilder()
                .setCatalog("local")
                .setSchema(TINY_SCHEMA_NAME)
                .build();

        LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);

        // add the tpch catalog
        // local queries run directly against the generator
        localQueryRunner.createCatalog(
                defaultSession.getCatalog().get(),
                new TpchConnectorFactory(1),
                ImmutableMap.<String, String>of());

        localQueryRunner.getTypeManager().addType(new BloomFilterType());
        localQueryRunner.getTypeManager().addParametricType(new BloomFilterParametricType());
        localQueryRunner.getMetadata().addFunctions(extractFunctions(new BloomFilterPlugin().getFunctions()));

        return new LocalQueryRunnerSupplier(localQueryRunner);
    }
    catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:presto    文件:TestTransactionManager.java   
@Test
public void testFailedTransactionWorkflow()
        throws Exception
{
    try (IdleCheckExecutor executor = new IdleCheckExecutor()) {
        TransactionManager transactionManager = TransactionManager.create(new TransactionManagerConfig(), executor.getExecutor(), finishingExecutor);

        Connector c1 = new TpchConnectorFactory(new InMemoryNodeManager()).create("c1", ImmutableMap.of());
        transactionManager.addConnector("c1", c1);

        TransactionId transactionId = transactionManager.beginTransaction(false);

        Assert.assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
        TransactionInfo transactionInfo = transactionManager.getTransactionInfo(transactionId);
        Assert.assertFalse(transactionInfo.isAutoCommitContext());
        Assert.assertTrue(transactionInfo.getConnectorIds().isEmpty());
        Assert.assertFalse(transactionInfo.getWrittenConnectorId().isPresent());

        ConnectorMetadata metadata = transactionManager.getMetadata(transactionId, "c1");
        metadata.listSchemaNames(TEST_SESSION.toConnectorSession("c1"));
        transactionInfo = transactionManager.getTransactionInfo(transactionId);
        Assert.assertEquals(transactionInfo.getConnectorIds(), ImmutableList.of("c1"));
        Assert.assertFalse(transactionInfo.getWrittenConnectorId().isPresent());

        transactionManager.fail(transactionId);
        Assert.assertEquals(transactionManager.getAllTransactionInfos().size(), 1);

        try {
            transactionManager.getMetadata(transactionId, "c1");
            Assert.fail();
        }
        catch (PrestoException e) {
            Assert.assertEquals(e.getErrorCode(), TRANSACTION_ALREADY_ABORTED.toErrorCode());
        }
        Assert.assertEquals(transactionManager.getAllTransactionInfos().size(), 1);

        transactionManager.asyncAbort(transactionId).join();

        Assert.assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
    }
}
项目:presto    文件:TestMemoryPools.java   
@Test
public void testBlocking()
        throws Exception
{
    Session session = TEST_SESSION
            .withSystemProperty("task_default_concurrency", "1");

    LocalQueryRunner localQueryRunner = queryRunnerWithInitialTransaction(session);

    // add tpch
    InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager();
    localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of());

    // reserve all the memory in the pool
    MemoryPool pool = new MemoryPool(new MemoryPoolId("test"), new DataSize(10, MEGABYTE));
    QueryId fakeQueryId = new QueryId("fake");
    assertTrue(pool.tryReserve(fakeQueryId, TEN_MEGABYTES));
    MemoryPool systemPool = new MemoryPool(new MemoryPoolId("testSystem"), new DataSize(10, MEGABYTE));

    QueryContext queryContext = new QueryContext(new QueryId("query"), new DataSize(10, MEGABYTE), pool, systemPool, localQueryRunner.getExecutor());
    LocalQueryRunner.MaterializedOutputFactory outputFactory = new LocalQueryRunner.MaterializedOutputFactory();
    TaskContext taskContext = createTaskContext(queryContext, localQueryRunner.getExecutor(), session, new DataSize(0, BYTE));
    Driver driver = Iterables.getOnlyElement(localQueryRunner.createDrivers("SELECT COUNT(*), clerk FROM orders GROUP BY clerk", outputFactory, taskContext));

    // run driver, until it blocks
    while (!driver.isFinished()) {
        if (!driver.process().isDone()) {
            break;
        }
    }

    // driver should be blocked waiting for memory
    assertFalse(driver.isFinished());
    assertTrue(pool.getFreeBytes() <= 0);

    pool.free(fakeQueryId, TEN_MEGABYTES);
    do {
        // driver should not block
        assertTrue(driver.process().isDone());
    }
    while (!driver.isFinished());
}
项目:presto    文件:TestHiddenColumns.java   
public TestHiddenColumns()
{
    runner = new LocalQueryRunner(TEST_SESSION);
    runner.createCatalog(TEST_SESSION.getCatalog().get(), new TpchConnectorFactory(runner.getNodeManager(), 1), ImmutableMap.<String, String>of());
}