}
private static QueryRunner createQueryRunner()
throws Exception
{
DistributedQueryRunner queryRunner = new DistributedQueryRunner(createSession("tpch"), 4);
try {
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch");
queryRunner.installPlugin(new SampledTpchPlugin());
queryRunner.createCatalog("tpch_sampled", "tpch_sampled");
File baseDir = queryRunner.getCoordinator().getBaseDataDir().toFile();
InMemoryHiveMetastore metastore = new InMemoryHiveMetastore();
metastore.createDatabase(new Database("tpch", null, new File(baseDir, "tpch").toURI().toString(), null));
metastore.createDatabase(new Database("tpch_sampled", null, new File(baseDir, "tpch_sampled").toURI().toString(), null));
queryRunner.installPlugin(new HivePlugin("hive", metastore));
Map<String, String> hiveProperties = ImmutableMap.<String, String>builder()
.put("hive.metastore.uri", "thrift://localhost:8080")
.put("hive.allow-drop-table", "true")
.put("hive.allow-rename-table", "true")
.build();
queryRunner.createCatalog("hive", "hive", hiveProperties);
log.info("Loading data...");
long startTime = System.nanoTime();
distributeData(queryRunner, "tpch", TpchMetadata.TINY_SCHEMA_NAME, createSession("tpch"));
distributeData(queryRunner, "tpch_sampled", TpchMetadata.TINY_SCHEMA_NAME, createSession("tpch_sampled"));
log.info("Loading complete in %s", nanosSince(startTime).toString(SECONDS));
return queryRunner;
}
catch (Exception e) {
queryRunner.close();
throw e;
}
}