Package org.apache.tajo.engine.planner.global

Examples of org.apache.tajo.engine.planner.global.ExecutionBlock


      }
    }

    private static void createTasks(SubQuery subQuery) throws IOException {
      MasterPlan masterPlan = subQuery.getMasterPlan();
      ExecutionBlock execBlock = subQuery.getBlock();
      QueryUnit [] tasks;
      if (subQuery.getMasterPlan().isLeaf(execBlock.getId()) && execBlock.getScanNodes().length == 1) { // Case 1: Just Scan
        tasks = createLeafTasks(subQuery);

      } else if (execBlock.getScanNodes().length > 1) { // Case 2: Join
        tasks = Repartitioner.createJoinTasks(subQuery);

      } else { // Case 3: Others (Sort or Aggregation)
        int numTasks = getNonLeafTaskNum(subQuery);
        ExecutionBlockId childId = masterPlan.getChilds(subQuery.getBlock()).get(0).getId();
View Full Code Here


        return aggregatedVolume;
      }
    }

    public static void allocateContainers(SubQuery subQuery) {
      ExecutionBlock execBlock = subQuery.getBlock();
      QueryUnit [] tasks = subQuery.getQueryUnits();

      int numRequest = subQuery.getContext().getResourceAllocator().calculateNumRequestContainers(
          subQuery.getContext().getQueryMasterContext().getWorkerContext(), tasks.length
      );

      final Resource resource = Records.newRecord(Resource.class);

      resource.setMemory(2000);

      LOG.info("Request Container for " + subQuery.getId() + " containers=" + numRequest);

      Priority priority = Records.newRecord(Priority.class);
      priority.setPriority(subQuery.getPriority());
      ContainerAllocationEvent event =
          new ContainerAllocationEvent(ContainerAllocatorEventType.CONTAINER_REQ,
              subQuery.getId(), priority, resource, numRequest,
              execBlock.isLeafBlock(), 0.0f);
      subQuery.eventHandler.handle(event);
    }
View Full Code Here

              execBlock.isLeafBlock(), 0.0f);
      subQuery.eventHandler.handle(event);
    }

    private static QueryUnit [] createLeafTasks(SubQuery subQuery) throws IOException {
      ExecutionBlock execBlock = subQuery.getBlock();
      ScanNode[] scans = execBlock.getScanNodes();
      Preconditions.checkArgument(scans.length == 1, "Must be Scan Query");
      TableMeta meta;
      Path inputPath;

      ScanNode scan = scans[0];
View Full Code Here

      return queryUnits.toArray(new QueryUnit[queryUnits.size()]);
    }

    private static QueryUnit newQueryUnit(SubQuery subQuery, int taskId, Fragment fragment) {
      ExecutionBlock execBlock = subQuery.getBlock();
      QueryUnit unit = new QueryUnit(
          QueryIdFactory.newQueryUnitId(subQuery.getId(), taskId), execBlock.isLeafBlock(),
          subQuery.eventHandler);
      unit.setLogicalPlan(execBlock.getPlan());
      unit.setFragment2(fragment);
      return unit;
    }
View Full Code Here

    List<ColumnStat> columnStats = Lists.newArrayList();

    MasterPlan masterPlan = subQuery.getMasterPlan();
    Iterator<ExecutionBlock> it = masterPlan.getChilds(subQuery.getBlock()).iterator();
    while (it.hasNext()) {
      ExecutionBlock block = it.next();
      SubQuery childSubQuery = subQuery.context.getSubQuery(block.getId());
      childStat = childSubQuery.getTableStat();
      avgRows += childStat.getAvgRows();
      columnStats.addAll(childStat.getColumnStats());
      numBlocks += childStat.getNumBlocks();
      numBytes += childStat.getNumBytes();
View Full Code Here

    }

    private void finalizeQuery(Query query, QueryCompletedEvent event) {
      MasterPlan masterPlan = query.getPlan();

      ExecutionBlock terminal = query.getPlan().getTerminalBlock();
      DataChannel finalChannel = masterPlan.getChannel(event.getExecutionBlockId(), terminal.getId());
      Path finalOutputDir = commitOutputData(query);

      QueryHookExecutor hookExecutor = new QueryHookExecutor(query.context.getQueryMasterContext());
      try {
        hookExecutor.execute(query.context.getQueryContext(), query, event.getExecutionBlockId(),
View Full Code Here

  public static class SubQueryCompletedTransition implements SingleArcTransition<Query, QueryEvent> {

    private boolean hasNext(Query query) {
      ExecutionBlockCursor cursor = query.getExecutionBlockCursor();
      ExecutionBlock nextBlock = cursor.peek();
      return !query.getPlan().isTerminal(nextBlock);
    }
View Full Code Here

      return !query.getPlan().isTerminal(nextBlock);
    }

    private void executeNextBlock(Query query) {
      ExecutionBlockCursor cursor = query.getExecutionBlockCursor();
      ExecutionBlock nextBlock = cursor.nextBlock();
      SubQuery nextSubQuery = new SubQuery(query.context, query.getPlan(), nextBlock, query.sm);
      nextSubQuery.setPriority(query.priority--);
      query.addSubQuery(nextSubQuery);
      nextSubQuery.handle(new SubQueryEvent(nextSubQuery.getId(), SubQueryEventType.SQ_INIT));
View Full Code Here

    List<ColumnStats> columnStatses = Lists.newArrayList();

    MasterPlan masterPlan = subQuery.getMasterPlan();
    Iterator<ExecutionBlock> it = masterPlan.getChilds(subQuery.getBlock()).iterator();
    while (it.hasNext()) {
      ExecutionBlock block = it.next();
      SubQuery childSubQuery = subQuery.context.getSubQuery(block.getId());
      TableStats[] childStatArray = new TableStats[]{
          childSubQuery.getInputStats(), childSubQuery.getResultStats()
      };
      for (int i = 0; i < 2; i++) {
        if (childStatArray[i] == null) {
View Full Code Here

  }

  public static QueryUnit newEmptyQueryUnit(TaskSchedulerContext schedulerContext,
                                            QueryUnitAttemptScheduleContext queryUnitContext,
                                            SubQuery subQuery, int taskId) {
    ExecutionBlock execBlock = subQuery.getBlock();
    QueryUnit unit = new QueryUnit(schedulerContext.getMasterContext().getConf(),
        queryUnitContext,
        QueryIdFactory.newQueryUnitId(schedulerContext.getBlockId(), taskId),
        schedulerContext.isLeafQuery(), subQuery.eventHandler);
    unit.setLogicalPlan(execBlock.getPlan());
    subQuery.addTask(unit);
    return unit;
  }
View Full Code Here

TOP

Related Classes of org.apache.tajo.engine.planner.global.ExecutionBlock

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.