@Override public void purgeTable(TableDesc tableDesc) throws IOException { try { Path path = new Path(tableDesc.getUri()); FileSystem fs = path.getFileSystem(conf); LOG.info("Delete table data dir: " + path); fs.delete(path, true); } catch (IOException e) { throw new InternalError(e.getMessage()); } }
@Override public void purgeTable(TableDesc tableDesc) throws IOException { try { Path path = new Path(tableDesc.getUri()); FileSystem fs = path.getFileSystem(conf); LOG.info("Delete table data dir: " + path); fs.delete(path, true); } catch (IOException e) { throw new InternalError(e.getMessage()); } }
@Override public List<Fragment> getSplits(String inputSourceId, TableDesc tableDesc, @Nullable EvalNode filterCondition) throws IOException { return Lists.newArrayList((Fragment)new JdbcFragment(inputSourceId, tableDesc.getUri().toASCIIString())); }
@Override public List<Fragment> getSplits(String inputSourceId, TableDesc tableDesc, boolean requireSorted, @Nullable EvalNode filterCondition) throws IOException { return Lists.newArrayList((Fragment)new JdbcFragment(inputSourceId, tableDesc.getUri())); }
@Override public List<Fragment> getSplits(String inputSourceId, TableDesc tableDesc, boolean requireSort, @Nullable EvalNode filterCondition) throws IOException, TajoException { // getSplits() should return multiple fragments for distributed processing of a large data. // This example tablespace returns only one fragment for the whole data for simplicity, // but this may significantly increase the query processing time. long tableVolume = getTableVolume(tableDesc, Optional.empty()); return Lists.newArrayList(new ExampleHttpFileFragment(tableDesc.getUri(), inputSourceId, 0, tableVolume)); }
public String toString() { StringBuilder sb = new StringBuilder("Scan (table=").append(getTableName()); if (hasAlias()) { sb.append(", alias=").append(alias); } if (hasQual()) { sb.append(", filter=").append(qual); } sb.append(", path=").append(getTableDesc().getUri()).append(")"); return sb.toString(); }
public String toString() { StringBuilder sb = new StringBuilder("Partitions Scan (table=").append(getTableName()); if (hasAlias()) { sb.append(", alias=").append(alias); } if (hasQual()) { sb.append(", filter=").append(qual); } sb.append(", uri=").append(getTableDesc().getUri()).append(")"); return sb.toString(); }
@Override public long getTableVolume(TableDesc table, Optional<EvalNode> filter) { Path path = new Path(table.getUri()); long totalVolume = 0L; try { totalVolume = calculateSize(path); } catch (IOException e) { throw new TajoInternalError(e); } return totalVolume; }
public String toString() { StringBuilder sb = new StringBuilder(capitalize(getType().name()) + " (table=").append(getTableName()); if (hasAlias()) { sb.append(", alias=").append(alias); } if (hasQual()) { sb.append(", filter=").append(qual); } sb.append(", path=").append(getTableDesc().getUri()).append(")"); return sb.toString(); }
@Override public List<Fragment> getSplits(String inputSourceId, TableDesc table, @Nullable EvalNode filterCondition) throws IOException { return getSplits(inputSourceId, table.getMeta(), table.getSchema(), new Path(table.getUri())); }
@Override public List<Fragment> getSplits(String inputSourceId, TableDesc table, boolean requireSort, @Nullable EvalNode filterCondition) throws IOException { return getSplits(inputSourceId, table.getMeta(), table.getSchema(), requireSort, new Path(table.getUri())); }
@Override public long getTableVolumn(TableDesc table, Optional<EvalNode> filter) throws UnsupportedException { return get(table.getUri()).getTableVolume(table, filter); }
@Override public long getTableVolumn(TableDesc table, Optional<EvalNode> filter) throws UnsupportedException { return get(table.getUri()).getTableVolume(table, filter); }
@Override public long getTableVolume(TableDesc table, Optional<EvalNode> filter) throws UnsupportedException { Path path = new Path(table.getUri()); ContentSummary summary; try { summary = fs.getContentSummary(path); } catch (IOException e) { throw new TajoInternalError(e); } return summary.getLength(); }
@Override public void createTable(TableDesc tableDesc, boolean ifNotExists) throws TajoException, IOException { createTable(tableDesc.getUri(), tableDesc.getMeta(), tableDesc.getSchema(), tableDesc.isExternal(), ifNotExists); TableStats stats = new TableStats(); stats.setNumRows(TajoConstants.UNKNOWN_ROW_NUMBER); tableDesc.setStats(stats); }
public List<Path> listTableFiles(String tableName) throws Exception { TableDesc tableDesc = testingCluster.getMaster().getCatalog().getTableDesc(getCurrentDatabase(), tableName); if (tableDesc == null) { return null; } Path path = new Path(tableDesc.getUri()); FileSystem fs = path.getFileSystem(conf); return listFiles(fs, path); }
@Override public void createTable(TableDesc tableDesc, boolean ifNotExists) throws TajoException, IOException { createTable(tableDesc.getUri(), tableDesc.getMeta(), tableDesc.getSchema(), tableDesc.isExternal(), ifNotExists); TableStats stats = new TableStats(); stats.setNumRows(TajoConstants.UNKNOWN_ROW_NUMBER); tableDesc.setStats(stats); }
@Test(timeout = 1000) public void testGetTable() throws UndefinedTableException { for (String tableName: PgSQLTestServer.TPCH_TABLES) { TableDesc retrieved = client.getTableDesc(PgSQLTestServer.DATABASE_NAME + "." + tableName); assertEquals(PgSQLTestServer.DATABASE_NAME + "." + tableName, retrieved.getName()); assertEquals(jdbcUrl + "&table=" + tableName, retrieved.getUri().toASCIIString()); } } }
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()); } } }