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


Java TableDesc.getUri方法代码示例

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


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

示例1: 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

示例2: verifyResultStats

import org.apache.tajo.catalog.TableDesc; //导入方法依赖的package包/类
private void verifyResultStats(Optional<TajoResultSetBase[]> existing, long numRows) throws Exception {
  assertTrue(existing.isPresent());

  // Get TableStats using TajoResultSetBase.
  TajoResultSetBase[] resultSet = existing.get();
  QueryId qid = resultSet[0].getQueryId();
  QueryInfo queryInfo = testingCluster.getMaster().getContext().getQueryJobManager().getFinishedQuery(qid);
  TableDesc desc = queryInfo.getResultDesc();
  TableStats stats = desc.getStats();

  // Compare specified number of rows to the number of rows in TableStats.
  assertEquals(numRows, stats.getNumRows().longValue());

  // Compare the volume number of directRaw to the number of rows in TableStats.
  FileSystem fs = FileSystem.get(conf);
  Path path = new Path(desc.getUri());
  assertTrue(fs.exists(path));
  ContentSummary summary = fs.getContentSummary(path);
  assertEquals(summary.getLength(), stats.getNumBytes().longValue());

  closeResultSets(resultSet);
}
 
开发者ID:apache,项目名称:tajo,代码行数:23,代码来源:TestUnionQuery.java

示例3: assertNullCharSessionVar

import org.apache.tajo.catalog.TableDesc; //导入方法依赖的package包/类
public void assertNullCharSessionVar(TableDesc resultDesc) throws Exception {
  TajoConf tajoConf = TpchTestBase.getInstance().getTestingCluster().getConfiguration();

  assertEquals(resultDesc.getMeta().getProperty(StorageConstants.TEXT_NULL), "\\\\T");

  Path path = new Path(resultDesc.getUri());
  FileSystem fs = path.getFileSystem(tajoConf);

  FileStatus[] files = fs.listStatus(path);
  assertNotNull(files);
  assertEquals(1, files.length);

  InputStream in = fs.open(files[0].getPath());
  byte[] buf = new byte[1024];


  int readBytes = in.read(buf);
  assertTrue(readBytes > 0);

  // text type field's value is replaced with \T
  String expected = "1|1|O\n" +
      "2|2|O\n" +
      "3|3|F\n" +
      "4||\\T\n" +
      "5||\\T\n" +
      "||\\T\n" +
      "||\\T\n" +
      "||\\T\n" +
      "||\\T\n" +
      "||\\T\n" +
      "||\\T\n";

  String resultDatas = new String(buf, 0, readBytes);

  assertEquals(expected, resultDatas);
}
 
开发者ID:apache,项目名称:tajo,代码行数:37,代码来源:TestTajoClient.java

示例4: getTableFileContents

import org.apache.tajo.catalog.TableDesc; //导入方法依赖的package包/类
/**
 * Reads data file from Test Cluster's HDFS
 * @param tableName
 * @return data file's contents
 * @throws Exception
 */
public String getTableFileContents(String tableName) throws Exception {
  TableDesc tableDesc = testingCluster.getMaster().getCatalog().getTableDesc(getCurrentDatabase(), tableName);
  if (tableDesc == null) {
    return null;
  }

  Path path = new Path(tableDesc.getUri());
  return getTableFileContents(path);
}
 
开发者ID:apache,项目名称:tajo,代码行数:16,代码来源:QueryTestCaseBase.java

示例5: listTableFiles

import org.apache.tajo.catalog.TableDesc; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:tajo,代码行数:12,代码来源:QueryTestCaseBase.java

示例6: getNonZeroLengthDataFiles

import org.apache.tajo.catalog.TableDesc; //导入方法依赖的package包/类
/**
 * Listing table data file which is not empty.
 * If the table is a partitioned table, return file list which has same partition key.
 * @param tajoConf
 * @param tableDesc
 * @param fileIndex
 * @param numResultFiles
 * @return
 * @throws java.io.IOException
 */
public static CatalogProtos.FragmentProto[] getNonZeroLengthDataFiles(TajoConf tajoConf,TableDesc tableDesc,
                                                        int fileIndex, int numResultFiles) throws IOException {
  Path path = new Path(tableDesc.getUri());
  FileSystem fs = path.getFileSystem(tajoConf);

  //In the case of partitioned table, we should return same partition key data files.
  int partitionDepth = 0;
  if (tableDesc.hasPartition()) {
    partitionDepth = tableDesc.getPartitionMethod().getExpressionSchema().getRootColumns().size();
  }

  List<FileStatus> nonZeroLengthFiles = new ArrayList<>();
  if (fs.exists(path)) {
    getNonZeroLengthDataFiles(fs, path, nonZeroLengthFiles, fileIndex, numResultFiles,
        new AtomicInteger(0), tableDesc.hasPartition(), 0, partitionDepth);
  }

  List<FileFragment> fragments = new ArrayList<>();


  String[] previousPartitionPathNames = null;
  for (FileStatus eachFile: nonZeroLengthFiles) {
    FileFragment fileFragment = new FileFragment(tableDesc.getName(), eachFile.getPath(), 0, eachFile.getLen(), null);

    if (partitionDepth > 0) {
      // finding partition key;
      Path filePath = fileFragment.getPath();
      Path parentPath = filePath;
      String[] parentPathNames = new String[partitionDepth];
      for (int i = 0; i < partitionDepth; i++) {
        parentPath = parentPath.getParent();
        parentPathNames[partitionDepth - i - 1] = parentPath.getName();
      }

      // If current partitionKey == previousPartitionKey, add to result.
      if (previousPartitionPathNames == null) {
        fragments.add(fileFragment);
      } else if (previousPartitionPathNames != null && Arrays.equals(previousPartitionPathNames, parentPathNames)) {
        fragments.add(fileFragment);
      } else {
        break;
      }
      previousPartitionPathNames = parentPathNames;
    } else {
      fragments.add(fileFragment);
    }
  }
  return FragmentConvertor.toFragmentProtoArray(tajoConf, fragments.toArray(new Fragment[fragments.size()]));
}
 
开发者ID:apache,项目名称:tajo,代码行数:60,代码来源:PhysicalPlanUtil.java

示例7: testCtasWithoutTableDefinition

import org.apache.tajo.catalog.TableDesc; //导入方法依赖的package包/类
@Test
public final void testCtasWithoutTableDefinition() throws Exception {
  ResultSet res = executeQuery();
  res.close();

  String tableName = IdentifierUtil.normalizeIdentifier("testCtasWithoutTableDefinition");
  CatalogService catalog = testBase.getTestingCluster().getMaster().getCatalog();
  String qualifiedTableName = buildFQName(DEFAULT_DATABASE_NAME, tableName);
  TableDesc desc = catalog.getTableDesc(qualifiedTableName);
  assertTrue(catalog.existsTable(qualifiedTableName));

  assertTrue(desc.getSchema().contains("default.testctaswithouttabledefinition.col1"));
  PartitionMethodDesc partitionDesc = desc.getPartitionMethod();
  assertEquals(partitionDesc.getPartitionType(), CatalogProtos.PartitionType.COLUMN);
  assertEquals("key", partitionDesc.getExpressionSchema().getRootColumns().get(0).getSimpleName());

  FileSystem fs = FileSystem.get(testBase.getTestingCluster().getConfiguration());
  Path path = new Path(desc.getUri());
  assertTrue(fs.isDirectory(path));
  assertTrue(fs.isDirectory(new Path(path.toUri() + "/key=17.0")));
  assertTrue(fs.isDirectory(new Path(path.toUri() + "/key=36.0")));
  assertTrue(fs.isDirectory(new Path(path.toUri() + "/key=38.0")));
  assertTrue(fs.isDirectory(new Path(path.toUri() + "/key=45.0")));
  assertTrue(fs.isDirectory(new Path(path.toUri() + "/key=49.0")));
  if (!testingCluster.isHiveCatalogStoreRunning()) {
    assertEquals(8, desc.getStats().getNumRows().intValue());
  }

  ResultSet res2 = executeFile("check1.sql");

  Map<Double, int []> resultRows1 = Maps.newHashMap();
  resultRows1.put(45.0d, new int[]{3, 2});
  resultRows1.put(38.0d, new int[]{2, 2});

  int i = 0;
  while(res2.next()) {
    assertEquals(resultRows1.get(res2.getDouble(3))[0], res2.getInt(1));
    assertEquals(resultRows1.get(res2.getDouble(3))[1], res2.getInt(2));
    i++;
  }
  res2.close();
  assertEquals(2, i);
}
 
开发者ID:apache,项目名称:tajo,代码行数:44,代码来源:TestCTASQuery.java

示例8: testCtasWithColumnedPartition

import org.apache.tajo.catalog.TableDesc; //导入方法依赖的package包/类
@Test
public final void testCtasWithColumnedPartition() throws Exception {
  ResultSet res = executeQuery();
  res.close();

  String tableName = IdentifierUtil.normalizeIdentifier("testCtasWithColumnedPartition");

  TajoTestingCluster cluster = testBase.getTestingCluster();
  CatalogService catalog = cluster.getMaster().getCatalog();
  TableDesc desc = catalog.getTableDesc(DEFAULT_DATABASE_NAME, tableName);
  assertTrue(catalog.existsTable(DEFAULT_DATABASE_NAME, tableName));
  PartitionMethodDesc partitionDesc = desc.getPartitionMethod();
  assertEquals(partitionDesc.getPartitionType(), CatalogProtos.PartitionType.COLUMN);
  assertEquals("key", partitionDesc.getExpressionSchema().getRootColumns().get(0).getSimpleName());

  FileSystem fs = FileSystem.get(cluster.getConfiguration());
  Path path = new Path(desc.getUri());
  assertTrue(fs.isDirectory(path));
  assertTrue(fs.isDirectory(new Path(path.toUri() + "/key=17.0")));
  assertTrue(fs.isDirectory(new Path(path.toUri() + "/key=36.0")));
  assertTrue(fs.isDirectory(new Path(path.toUri() + "/key=38.0")));
  assertTrue(fs.isDirectory(new Path(path.toUri() + "/key=45.0")));
  assertTrue(fs.isDirectory(new Path(path.toUri() + "/key=49.0")));
  if (!cluster.isHiveCatalogStoreRunning()) {
    assertEquals(8, desc.getStats().getNumRows().intValue());
  }

  ResultSet res2 = executeFile("check2.sql");

  Map<Double, int []> resultRows1 = Maps.newHashMap();
  resultRows1.put(45.0d, new int[]{3, 2});
  resultRows1.put(38.0d, new int[]{2, 2});

  int i = 0;
  while(res2.next()) {
    assertEquals(resultRows1.get(res2.getDouble(3))[0], res2.getInt(1));
    assertEquals(resultRows1.get(res2.getDouble(3))[1], res2.getInt(2));
    i++;
  }
  res2.close();
  assertEquals(2, i);
}
 
开发者ID:apache,项目名称:tajo,代码行数:43,代码来源:TestCTASQuery.java


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