Package org.apache.tajo.catalog.statistics

Examples of org.apache.tajo.catalog.statistics.TableStats


    SortNode sortNode = PlannerUtil.findTopNode(sampleChildBlock.getPlan(), NodeType.SORT);
    SortSpec [] sortSpecs = sortNode.getSortKeys();
    Schema sortSchema = new Schema(channel.getShuffleKeys());

    // calculate the number of maximum query ranges
    TableStats totalStat = computeChildBlocksStats(subQuery.getContext(), masterPlan, subQuery.getId());

    // If there is an empty table in inner join, it should return zero rows.
    if (totalStat.getNumBytes() == 0 && totalStat.getColumnStats().size() == 0 ) {
      return;
    }
    TupleRange mergedRange = TupleUtil.columnStatToRange(sortSpecs, sortSchema, totalStat.getColumnStats());
    RangePartitionAlgorithm partitioner = new UniformRangePartition(mergedRange, sortSpecs);
    BigDecimal card = partitioner.getTotalCardinality();

    // if the number of the range cardinality is less than the desired number of tasks,
    // we set the the number of tasks to the number of range cardinality.
View Full Code Here


  public static void scheduleHashShuffledFetches(TaskSchedulerContext schedulerContext, MasterPlan masterPlan,
                                                 SubQuery subQuery, DataChannel channel,
                                                 int maxNum) {
    ExecutionBlock execBlock = subQuery.getBlock();
    TableStats totalStat = computeChildBlocksStats(subQuery.getContext(), masterPlan, subQuery.getId());

    if (totalStat.getNumRows() == 0) {
      return;
    }

    ScanNode scan = execBlock.getScanNodes()[0];
    Path tablePath;
View Full Code Here

    this.context = new TaskAttemptContext(systemConf, taskId,
        request.getFragments().toArray(new FragmentProto[request.getFragments().size()]), taskDir);
    this.context.setDataChannel(request.getDataChannel());
    this.context.setEnforcer(request.getEnforcer());
    this.inputStats = new TableStats();

    this.reporter = new Reporter(taskId, masterProxy);
    this.reporter.startCommunicationThread();

    plan = CoreGsonHelper.fromJson(request.getSerializedData(), LogicalNode.class);
View Full Code Here

    synchronized(inputStats) {
      if (this.executor == null) {
        return inputStats.getProto();
      }

      TableStats executorInputStats = this.executor.getInputStats();

      if (executorInputStats != null) {
        inputStats.setValues(executorInputStats);
      }
      return inputStats.getProto();
View Full Code Here

    builder.setInputStats(reloadInputStats());

    if (context.hasResultStats()) {
      builder.setResultStats(context.getResultStats().getProto());
    } else {
      builder.setResultStats(new TableStats().getProto());
    }

    Iterator<Entry<Integer,String>> it = context.getShuffleFileOutputs();
    if (it.hasNext()) {
      do {
View Full Code Here

    try {
      taskHistory.setStatus(getStatus().toString());
      taskHistory.setProgress(context.getProgress());

      taskHistory.setInputStats(new TableStats(reloadInputStats()));
      if (context.getResultStats() != null) {
        taskHistory.setOutputStats((TableStats)context.getResultStats().clone());
      }

      if (hasFetchPhase()) {
View Full Code Here

      fs.copyFromLocalFile(localPath, dfsPath);
      TableMeta meta = CatalogUtil.newTableMeta(CatalogProtos.StoreType.CSV, option);

      // Add fake table statistic data to tables.
      // It gives more various situations to unit tests.
      TableStats stats = new TableStats();
      stats.setNumBytes(TPCH.tableVolumes.get(names[i]));
      TableDesc tableDesc = new TableDesc(
          CatalogUtil.buildFQName(TajoConstants.DEFAULT_DATABASE_NAME, names[i]), schemas[i], meta,
          tablePath);
      tableDesc.setStats(stats);
      util.getMaster().getCatalog().createTable(tableDesc);
View Full Code Here

    }

    assertEquals(1.0f, exec.getProgress(), 0);
    assertEquals(numTuple, cnt);

    TableStats tableStats = exec.getInputStats();
    assertNotNull(tableStats);
    assertEquals(testDataStats.getNumBytes().longValue(), tableStats.getNumBytes().longValue());
    assertEquals(cnt, testDataStats.getNumRows().longValue());
    assertEquals(cnt, tableStats.getNumRows().longValue());
    assertEquals(testDataStats.getNumBytes().longValue(), tableStats.getReadBytes().longValue());

    // for rescan test
    preVal = null;
    exec.rescan();

    cnt = 0;
    while ((tuple = exec.next()) != null) {
      curVal = tuple;
      if (preVal != null) {
        assertTrue("prev: " + preVal + ", but cur: " + curVal, comparator.compare(preVal, curVal) <= 0);
      }
      preVal = curVal;
      cnt++;
    }
    assertEquals(1.0f, exec.getProgress(), 0);
    assertEquals(numTuple, cnt);
    exec.close();
    assertEquals(1.0f, exec.getProgress(), 0);

    tableStats = exec.getInputStats();
    assertNotNull(tableStats);
    assertEquals(testDataStats.getNumBytes().longValue(), tableStats.getNumBytes().longValue());
    assertEquals(cnt, testDataStats.getNumRows().longValue());
    assertEquals(cnt, tableStats.getNumRows().longValue());
    assertEquals(testDataStats.getNumBytes().longValue(), tableStats.getReadBytes().longValue());
  }
View Full Code Here

    scoreSchema = new Schema();
    scoreSchema.addColumn("deptname", Type.TEXT);
    scoreSchema.addColumn("score", Type.INT4);
    scoreMeta = CatalogUtil.newTableMeta(StoreType.CSV);
    TableStats stats = new TableStats();

    Path p = sm.getTablePath("score");
    sm.getFileSystem().mkdirs(p);
    Appender appender = StorageManagerFactory.getStorageManager(conf).getAppender(scoreMeta, scoreSchema,
        new Path(p, "score"));
    appender.init();
    int deptSize = 100;
    int tupleNum = 10000;
    Tuple tuple;
    long written = 0;
    for (int i = 0; i < tupleNum; i++) {
      tuple = new VTuple(2);
      String key = "test" + (i % deptSize);
      tuple.put(0, DatumFactory.createText(key));
      tuple.put(1, DatumFactory.createInt4(i + 1));
      written += key.length() + Integer.SIZE;
      appender.addTuple(tuple);
    }
    appender.close();
    stats.setNumRows(tupleNum);
    stats.setNumBytes(written);
    stats.setAvgRows(tupleNum);
    stats.setNumBlocks(1000);
    stats.setNumShuffleOutputs(100);
    desc = new TableDesc(CatalogUtil.buildFQName(TajoConstants.DEFAULT_DATABASE_NAME, "score"),
        scoreSchema, scoreMeta, p);
    desc.setStats(stats);
  }
View Full Code Here

    tpch.loadOutSchema();
    for (String table : tpch.getTableNames()) {
      TableMeta m = CatalogUtil.newTableMeta(CatalogProtos.StoreType.CSV);
      TableDesc d = CatalogUtil.newTableDesc(
          CatalogUtil.buildFQName(DEFAULT_DATABASE_NAME, table), tpch.getSchema(table), m, CommonTestingUtil.getTestDir());
      TableStats stats = new TableStats();
      stats.setNumBytes(TPCH.tableVolumes.get(table));
      d.setStats(stats);
      catalog.createTable(d);
    }

    analyzer = new SQLAnalyzer();
View Full Code Here

TOP

Related Classes of org.apache.tajo.catalog.statistics.TableStats

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.