private Tablespace getTablespaceHandler(@Nullable String tableSpaceName, @Nullable URI tableUri) { if (tableSpaceName != null) { return TablespaceManager.getByName(tableSpaceName); } else if (tableUri != null) { return TablespaceManager.get(tableUri); } else { return TablespaceManager.getDefault(); } } }
@Override public long getTableVolumn(TableDesc table, Optional<EvalNode> filter) throws UnsupportedException { return get(table.getUri()).getTableVolume(table, filter); }
@Test public void testTablespaceHandler() throws Exception { assertTrue((TablespaceManager.getByName("cluster1")) instanceof HBaseTablespace); assertTrue((TablespaceManager.get(URI.create("hbase:zk://host1:2171"))) instanceof HBaseTablespace); }
@Test public void testTablespaceHandler() throws Exception { assertTrue((TablespaceManager.getByName("cluster1")) instanceof KafkaTablespace); assertTrue((TablespaceManager.get(KAFKA_SERVER_URI)) instanceof KafkaTablespace); }
public void openAppender(int suffixId) throws IOException { Path actualFilePath = lastFileName; if (suffixId > 0) { actualFilePath = new Path(lastFileName + "_" + suffixId); } appender = ((FileTablespace) TablespaceManager.get(lastFileName.toUri())) .getAppender(meta, outSchema, actualFilePath); appender.enableStats(); appender.init(); }
private Tablespace getTablespaceHandler(@Nullable String tableSpaceName, @Nullable URI tableUri) { if (tableSpaceName != null) { return TablespaceManager.getByName(tableSpaceName); } else if (tableUri != null) { return TablespaceManager.get(tableUri); } else { return TablespaceManager.getDefault(); } } }
@Test(timeout = 1000) public void testTablespaceHandler() throws Exception { assertTrue((TablespaceManager.getByName("pgsql_cluster")) instanceof PgSQLTablespace); assertEquals("pgsql_cluster", (TablespaceManager.getByName("pgsql_cluster").getName())); assertTrue((TablespaceManager.get(jdbcUrl)) instanceof PgSQLTablespace); assertTrue((TablespaceManager.get(jdbcUrl + "&table=tb1")) instanceof PgSQLTablespace); assertEquals(jdbcUrl, TablespaceManager.get(jdbcUrl).getUri().toASCIIString()); assertTrue(TablespaceManager.get(jdbcUrl).getMetadataProvider() instanceof PgSQLMetadataProvider); }
@Override public long getTableVolumn(TableDesc table, Optional<EvalNode> filter) throws UnsupportedException { return get(table.getUri()).getTableVolume(table, filter); }
@Test public void testCalculateSizeWithS3APrefix() throws Exception { Path path = new Path(S3A_URI, "test"); assertTrue((TablespaceManager.getByName(S3A_SPACENAME)) instanceof S3TableSpace); S3TableSpace tableSpace = TablespaceManager.get(path.toUri()); tableSpace.setAmazonS3Client(new MockAmazonS3()); long size = tableSpace.calculateSize(path); assertEquals(30L, size); }
public void openAppender(int suffixId) throws IOException { Path actualFilePath = lastFileName; if (suffixId > 0) { actualFilePath = new Path(lastFileName + "_" + suffixId); } appender = ((FileTablespace) TablespaceManager.get(lastFileName.toUri())) .getAppender(meta, outSchema, actualFilePath); appender.enableStats(); appender.init(); }
@Test public void testCalculateSizeWithS3Prefix() throws Exception { Path path = new Path(S3_URI, "test"); assertTrue((TablespaceManager.getByName(S3_SPACENAME)) instanceof S3TableSpace); S3TableSpace tableSpace = TablespaceManager.get(path.toUri()); tableSpace.setAmazonS3Client(new MockAmazonS3()); long size = tableSpace.calculateSize(path); assertEquals(30L, size); }
private void handleQueryFailure(Query query, Stage lastStage) { QueryContext context = query.context.getQueryContext(); if (lastStage != null && context.hasOutputTableUri()) { Tablespace space = TablespaceManager.get(context.getOutputTableUri()); try { LogicalRootNode rootNode = lastStage.getMasterPlan().getLogicalPlan().getRootBlock().getRoot(); space.rollbackTable(rootNode.getChild()); } catch (Throwable e) { LOG.warn(query.getId() + ", failed processing cleanup storage when query failed:" + e.getMessage(), e); } } }
@Test public void testCalculateSizeWithS3NPrefix() throws Exception { Path path = new Path(S3N_URI, "test"); assertTrue((TablespaceManager.getByName(S3N_SPACENAME)) instanceof S3TableSpace); S3TableSpace tableSpace = TablespaceManager.get(path.toUri()); tableSpace.setAmazonS3Client(new MockAmazonS3()); long size = tableSpace.calculateSize(path); assertEquals(30L, size); }
private void handleQueryFailure(Query query, Stage lastStage) { QueryContext context = query.context.getQueryContext(); if (lastStage != null && context.hasOutputTableUri()) { Tablespace space = TablespaceManager.get(context.getOutputTableUri()); try { LogicalRootNode rootNode = lastStage.getMasterPlan().getLogicalPlan().getRootBlock().getRoot(); space.rollbackTable(rootNode.getChild()); } catch (Throwable e) { LOG.warn(query.getId() + ", failed processing cleanup storage when query failed:" + e.getMessage(), e); } } }
@Override public void init() throws IOException { super.init(); HBaseTablespace space = (HBaseTablespace) TablespaceManager.get(uri); HConnection hconn = space.getConnection(); htable = hconn.getTable(columnMapping.getHbaseTableName()); htable.setAutoFlushTo(false); htable.setWriteBufferSize(5 * 1024 * 1024); }
@Override public void init() throws IOException { super.init(); HBaseTablespace space = (HBaseTablespace) TablespaceManager.get(uri); HConnection hconn = space.getConnection(); htable = hconn.getTable(columnMapping.getHbaseTableName()); htable.setAutoFlushTo(false); htable.setWriteBufferSize(5 * 1024 * 1024); }
@Test public void testGetSchemas() throws Exception { Tablespace tablespace = TablespaceManager.get(jdbcUrl); MetadataProvider provider = tablespace.getMetadataProvider(); assertTrue(provider.getSchemas().isEmpty()); }
@Test public void testGetTablespaceName() throws Exception { Tablespace tablespace = TablespaceManager.get(jdbcUrl); MetadataProvider provider = tablespace.getMetadataProvider(); assertEquals("pgsql_cluster", provider.getTablespaceName()); }
public MasterPlan compileMasterPlan(LogicalPlan plan, QueryContext context, GlobalPlanner planner) throws Exception { LogicalRootNode rootNode = plan.getRootBlock().getRoot(); TableDesc tableDesc = PlannerUtil.getTableDesc(planner.getCatalog(), rootNode.getChild()); if (tableDesc != null) { Tablespace space = TablespaceManager.get(tableDesc.getUri()); space.rewritePlan(context, plan); } MasterPlan masterPlan = new MasterPlan(QueryIdFactory.NULL_QUERY_ID, context, plan); planner.build(context, masterPlan); return masterPlan; } }
@Test public void testGetTableDescriptor() throws Exception { Tablespace tablespace = TablespaceManager.get(jdbcUrl); MetadataProvider provider = tablespace.getMetadataProvider(); for (String tableName : PgSQLTestServer.TPCH_TABLES) { TableDesc table = provider.getTableDesc(null, tableName); assertEquals("tpch." + tableName, table.getName()); assertEquals(jdbcUrl + "&table=" + tableName, table.getUri().toASCIIString()); } } }