当前位置: 首页>>代码示例>>Java>>正文


Java TableDesc类代码示例

本文整理汇总了Java中org.apache.tajo.catalog.TableDesc的典型用法代码示例。如果您正苦于以下问题:Java TableDesc类的具体用法?Java TableDesc怎么用?Java TableDesc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TableDesc类属于org.apache.tajo.catalog包,在下文中一共展示了TableDesc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initStagingDir

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
private void initStagingDir() throws IOException {
  URI stagingDir;

  try {
    Tablespace tablespace = TablespaceManager.get(queryContext.get(QueryVars.OUTPUT_TABLE_URI, ""));
    TableDesc desc = PlannerUtil.getOutputTableDesc(plan);

    FormatProperty formatProperty = tablespace.getFormatProperty(desc.getMeta());
    if (formatProperty.isStagingSupport()) {
      stagingDir = tablespace.prepareStagingSpace(systemConf, queryId.toString(), queryContext, desc.getMeta());

      // Create a staging space
      LOG.info("The staging dir '" + stagingDir + "' is created.");
      queryContext.setStagingDir(stagingDir);
    }

  } catch (IOException ioe) {
    LOG.warn("Creating staging space has been failed.", ioe);
    throw ioe;
  }
}
 
开发者ID:apache,项目名称:tajo,代码行数:22,代码来源:QueryMasterTask.java

示例2: testGetTableDesc

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
@Test
public final void testGetTableDesc() throws IOException, ServiceException, SQLException {
  final String tableName1 = "table3";
  Path tablePath = writeTmpTable(tableName1);
  LOG.error("Full path:" + tablePath.toUri().getRawPath());
  FileSystem fs = tablePath.getFileSystem(conf);
  assertTrue(fs.exists(tablePath));

  assertNotNull(tablePath);
  assertFalse(client.existTable(tableName1));

  client.createExternalTable("table3", BackendTestingUtil.mockupSchema, tablePath, BackendTestingUtil.mockupMeta);
  assertTrue(client.existTable(tableName1));

  TableDesc desc = client.getTableDesc(tableName1);
  assertNotNull(desc);
  assertEquals(tableName1, desc.getName());
  assertTrue(desc.getStats().getNumBytes() > 0);
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:20,代码来源:TestTajoClient.java

示例3: invoke

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
@Override
public void invoke(String[] cmd) throws Exception {
  if (cmd.length == 2) {
    TableDesc desc = client.getTableDesc(cmd[1]);
    if (desc == null) {
      sout.println("Did not find any relation named \"" + cmd[1] + "\"");
    } else {
      sout.println(toFormattedString(desc));
    }
  } else if (cmd.length == 1) {
    List<String> tableList = client.getTableList();
    if (tableList.size() == 0) {
      sout.println("No Relation Found");
    }
    for (String table : tableList) {
      sout.println(table);
    }
  } else {
    throw new IllegalArgumentException();
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:22,代码来源:DescTableCommand.java

示例4: createTable

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
@Override
public void createTable(TableDesc table, boolean ifNotExists) throws TajoException, IOException {
  HttpURLConnection connection = null;

  try {
    connection = (HttpURLConnection) new URL(table.getUri().toASCIIString()).openConnection();
    connection.setRequestMethod("HEAD");
    connection.connect();

    if (connection.getResponseCode() == 404) {
      throw new FileNotFoundException();
    }

  } catch (IOException e) {
    throw new TajoInternalError(e);

  } finally {
    if (connection != null) {
      connection.disconnect();
    }
  }
}
 
开发者ID:apache,项目名称:tajo,代码行数:23,代码来源:ExampleHttpFileTablespace.java

示例5: rewrite

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
@Override
public LogicalPlan rewrite(LogicalPlan plan) throws PlanningException {
  boolean containsPartitionedTables;
  for (LogicalPlan.QueryBlock block : plan.getQueryBlocks()) {
    containsPartitionedTables = false;
    for (RelationNode relation : block.getRelations()) {
      if (relation.getType() == NodeType.SCAN) {
        TableDesc table = ((ScanNode)relation).getTableDesc();
        if (table.hasPartition()) {
          containsPartitionedTables = true;
        }
      }
    }
    if (containsPartitionedTables) {
      rewriter.visit(block, plan, block, block.getRoot(), new Stack<LogicalNode>());
    }
  }
  return plan;
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:20,代码来源:PartitionedTableRewriter.java

示例6: testGetSplit

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
/**
 * Test for getSplit.
 *
 * @throws Exception
 */
@Test
public void testGetSplit() throws Exception {
  TableMeta meta = CatalogUtil.newTableMeta("KAFKA", new TajoConf());
  Map<String, String> option = new java.util.HashMap<String, String>();
  option.put(KafkaStorageConstants.KAFKA_TOPIC, TOPIC_NAME);
  option.put(KafkaStorageConstants.KAFKA_FRAGMENT_SIZE, "10");
  meta.setPropertySet(new KeyValueSet(option));
  TableDesc td = new TableDesc("test_table", null, meta, null);
  KafkaTablespace kafkaTablespace = TablespaceManager.getByName("cluster1");
  List<Fragment> fragmentList = kafkaTablespace.getSplits("", td, false, null);
  long totalCount = 0;
  for (int i = 0; i < fragmentList.size(); i++) {
    totalCount += fragmentList.get(i).getLength();
  }
  assertEquals(100, totalCount);
}
 
开发者ID:apache,项目名称:tajo,代码行数:22,代码来源:TestKafkaTablespace.java

示例7: setTargetTable

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
public void setTargetTable(TableDesc desc) {
  setTableName(desc.getName());
  if (desc.hasPartition()) {
    tableSchema = desc.getLogicalSchema();
  } else {
    tableSchema = desc.getSchema();
  }
  if (desc.getUri() != null) {
    setUri(desc.getUri());
  }
  setOptions(desc.getMeta().getPropertySet());
  setDataFormat(desc.getMeta().getDataFormat());

  if (desc.hasPartition()) {
    this.setPartitionMethod(desc.getPartitionMethod());
  }
}
 
开发者ID:apache,项目名称:tajo,代码行数:18,代码来源:InsertNode.java

示例8: createExternalTable

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
public TableDesc createExternalTable(final String name, final Schema schema, final Path path, final TableMeta meta)
    throws SQLException, ServiceException {
  return new ServerCallable<TableDesc>(connPool, tajoMasterAddr,
      TajoMasterClientProtocol.class, false, true) {
    public TableDesc call(NettyClientBase client) throws ServiceException, SQLException {
      TajoMasterClientProtocolService.BlockingInterface tajoMasterService = client.getStub();

      CreateTableRequest.Builder builder = CreateTableRequest.newBuilder();
      builder.setName(name);
      builder.setSchema(schema.getProto());
      builder.setMeta(meta.getProto());
      builder.setPath(path.toUri().toString());
      TableResponse res = tajoMasterService.createExternalTable(null, builder.build());
      if (res.getResultCode() == ResultCode.OK) {
        return CatalogUtil.newTableDesc(res.getTableDesc());
      } else {
        throw new SQLException(res.getErrorMessage(), SQLStates.ER_NO_SUCH_TABLE.getState());
      }
    }
  }.withRetries();
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:22,代码来源:TajoClient.java

示例9: invoke

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
@Override
public void invoke(String[] cmd) throws Exception {
  if (cmd.length == 2) {
    TableDesc desc = client.getTableDesc(cmd[1]);
    if (desc == null) {
      context.getOutput().println("Did not find any relation named \"" + cmd[1] + "\"");
    } else {
      context.getOutput().println(toFormattedString(desc));
    }
  } else if (cmd.length == 1) {
    List<String> tableList = client.getTableList(null);
    if (tableList.size() == 0) {
      context.getOutput().println("No Relation Found");
    }
    for (String table : tableList) {
      context.getOutput().println(table);
    }
  } else {
    throw new IllegalArgumentException();
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:22,代码来源:DescTableCommand.java

示例10: testInsertOverwrite

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
@Test
public final void testInsertOverwrite() throws Exception {
  String tableName = CatalogUtil.normalizeIdentifier("InsertOverwrite");
  ResultSet res = tpch.execute("create table " + tableName +" (col1 int4, col2 int4, col3 float8)");
  res.close();
  TajoTestingCluster cluster = tpch.getTestingCluster();
  CatalogService catalog = cluster.getMaster().getCatalog();
  assertTrue(catalog.existsTable(DEFAULT_DATABASE_NAME, tableName));

  res = tpch.execute("insert overwrite into " + tableName
      + " select l_orderkey, l_partkey, l_quantity from lineitem");
  res.close();

  TableDesc desc = catalog.getTableDesc(DEFAULT_DATABASE_NAME, tableName);
  if (!cluster.isHCatalogStoreRunning()) {
    assertEquals(5, desc.getStats().getNumRows().intValue());
  }
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:19,代码来源:TestInsertQuery.java

示例11: testInsertOverwrite

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
@Test
public final void testInsertOverwrite() throws Exception {
  ResultSet res = executeFile("table1_ddl.sql");
  res.close();

  CatalogService catalog = testingCluster.getMaster().getCatalog();
  assertTrue(catalog.existsTable(getCurrentDatabase(), "table1"));

  res = executeFile("testInsertOverwrite.sql");
  res.close();

  TableDesc desc = catalog.getTableDesc(getCurrentDatabase(), "table1");
  if (!testingCluster.isHiveCatalogStoreRunning()) {
    assertEquals(8, desc.getStats().getNumRows().intValue());
  }

  executeString("DROP TABLE table1 PURGE");
}
 
开发者ID:apache,项目名称:tajo,代码行数:19,代码来源:TestInsertQuery.java

示例12: testInsertOverwriteWithAsterisk

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
@Test
public final void testInsertOverwriteWithAsterisk() throws Exception {
  ResultSet res = executeFile("full_table_csv_ddl.sql");
  res.close();

  CatalogService catalog = testingCluster.getMaster().getCatalog();
  assertTrue(catalog.existsTable(getCurrentDatabase(), "full_table_csv"));

  res = executeString("insert overwrite into full_table_csv select * from default.lineitem where l_orderkey = 3");
  res.close();
  TableDesc desc = catalog.getTableDesc(getCurrentDatabase(), "full_table_csv");
  if (!testingCluster.isHiveCatalogStoreRunning()) {
    assertEquals(2, desc.getStats().getNumRows().intValue());
  }
  executeString("DROP TABLE full_table_csv PURGE");
}
 
开发者ID:apache,项目名称:tajo,代码行数:17,代码来源:TestInsertQuery.java

示例13: waitOnResult

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
private Schema waitOnResult() throws SQLException {
  try {
    QueryStatus status = TajoClientUtil.waitCompletion(tajoClient, queryId);

    if (status.getState() != TajoProtos.QueryState.QUERY_SUCCEEDED) {
      throw new SQLException(status.getErrorMessage(),
          SQLExceptionUtil.toSQLState(ResultCode.INTERNAL_ERROR), ResultCode.INTERNAL_ERROR.getNumber());
    }

    ClientProtos.GetQueryResultResponse response = tajoClient.getResultResponse(queryId);
    TableDesc tableDesc = new TableDesc(response.getTableDesc());
    return tableDesc.getLogicalSchema();
  } catch (TajoException e) {
    throw SQLExceptionUtil.toSQLException(e);
  }
}
 
开发者ID:apache,项目名称:tajo,代码行数:17,代码来源:WaitingResultSet.java

示例14: testInsertOverwriteIntoSelect

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
@Test
public final void testInsertOverwriteIntoSelect() throws Exception {
  String tableName = IdentifierUtil.normalizeIdentifier("insertoverwriteintoselect");
  ResultSet res = executeString("create table " + tableName + " as select l_orderkey from default.lineitem");
  assertFalse(res.next());
  res.close();


  CatalogService catalog = testingCluster.getMaster().getCatalog();
  assertTrue(catalog.existsTable(getCurrentDatabase(), tableName));
  TableDesc orderKeys = catalog.getTableDesc(getCurrentDatabase(), tableName);
  if (!testingCluster.isHiveCatalogStoreRunning()) {
    assertEquals(8, orderKeys.getStats().getNumRows().intValue());
  }

  // this query will result in the two rows.
  res = executeString("insert overwrite into " + tableName + " select l_orderkey from default.lineitem where l_orderkey = 3");
  assertFalse(res.next());
  res.close();

  assertTrue(catalog.existsTable(getCurrentDatabase(), tableName));
  orderKeys = catalog.getTableDesc(getCurrentDatabase(), tableName);
  if (!testingCluster.isHiveCatalogStoreRunning()) {
    assertEquals(2, orderKeys.getStats().getNumRows().intValue());
  }
  executeString("DROP TABLE " + tableName + " PURGE");
}
 
开发者ID:apache,项目名称:tajo,代码行数:28,代码来源:TestInsertQuery.java

示例15: testInsertOverwriteWithCompression

import org.apache.tajo.catalog.TableDesc; //导入依赖的package包/类
@Test
public final void testInsertOverwriteWithCompression() throws Exception {
  String tableName = IdentifierUtil.normalizeIdentifier("testInsertOverwriteWithCompression");
  ResultSet res = executeFile("testInsertOverwriteWithCompression_ddl.sql");
  res.close();

  CatalogService catalog = testingCluster.getMaster().getCatalog();
  assertTrue(catalog.existsTable(getCurrentDatabase(), tableName));

  res = executeQuery();
  res.close();
  TableDesc desc = catalog.getTableDesc(getCurrentDatabase(), tableName);
  if (!testingCluster.isHiveCatalogStoreRunning()) {
    assertEquals(2, desc.getStats().getNumRows().intValue());
  }

  FileSystem fs = FileSystem.get(testingCluster.getConfiguration());
  assertTrue(fs.exists(new Path(desc.getUri())));
  CompressionCodecFactory factory = new CompressionCodecFactory(testingCluster.getConfiguration());

  for (FileStatus file : fs.listStatus(new Path(desc.getUri()))) {
    CompressionCodec codec = factory.getCodec(file.getPath());
    assertTrue(codec instanceof DeflateCodec);
  }
  executeString("DROP TABLE " + tableName + " PURGE");
}
 
开发者ID:apache,项目名称:tajo,代码行数:27,代码来源:TestInsertQuery.java


注:本文中的org.apache.tajo.catalog.TableDesc类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。