Package org.apache.drill.exec.record.RecordBatch

Examples of org.apache.drill.exec.record.RecordBatch.IterOutcome


      if(!ok){
        stop();
        return false;
      }

      IterOutcome outcome = incoming.next();
      logger.debug("Screen Outcome {}", outcome);
      switch(outcome){
      case STOP: {
          QueryResult header = QueryResult.newBuilder() //
              .setQueryId(context.getHandle().getQueryId()) //
View Full Code Here


      if(!ok){
        incoming.kill();
       
        return false;
      }
      IterOutcome out = incoming.next();
      logger.debug("Outcome of sender next {}", out);
      switch(out){
      case STOP:
      case NONE:
        FragmentWritableBatch b2 = new FragmentWritableBatch(true, handle.getQueryId(), handle.getMajorFragmentId(), handle.getMinorFragmentId(), recMajor, 0, incoming.getWritableBatch());
View Full Code Here

        InternalBatch previous = null;
       
        try{
          while(true){
            previous = new InternalBatch(incoming);
            IterOutcome out = incoming.next();
            if(EXTRA_DEBUG) logger.debug("Received IterOutcome of {}", out);
            switch(out){
            case NONE:
              lastOutcome = out;
              if(addedRecordCount > 0){
View Full Code Here

        stop();
        context.fail(this.listener.ex);
        return false;
      }

      IterOutcome outcome = next(incoming);
//      logger.debug("Screen Outcome {}", outcome);
      switch(outcome){
      case STOP: {
          sendCount.waitForSendComplete();
        boolean verbose = context.getOptions().getOption(ExecConstants.ENABLE_VERBOSE_ERRORS_KEY).bool_val;
View Full Code Here

        // Done processing all records in the previous batch, clean up!
        for (VectorWrapper<?> wrapper : probeBatch) {
          wrapper.getValueVector().clear();
        }

        IterOutcome leftUpstream = outgoingJoinBatch.next(HashJoinHelper.LEFT_INPUT, probeBatch);

        switch (leftUpstream) {
          case NONE:
          case NOT_YET:
          case STOP:
View Full Code Here

        incoming.kill(false);
       
        return false;
      }

      IterOutcome out;
      if (!done) {
        out = next(incoming);
      } else {
        incoming.kill(true);
        out = IterOutcome.NONE;
View Full Code Here

    }
  }

  public final IterOutcome next(RecordBatch b){
    stats.stopProcessing();
    IterOutcome next;
    try {
      next = b.next();
    } finally {
      stats.startProcessing();
    }
View Full Code Here

    if (done) {
      return IterOutcome.NONE;
    }
    // this is only called on the first batch. Beyond this, the aggregator manages batches.
    if (aggregator == null) {
      IterOutcome outcome = next(incoming);
      logger.debug("Next outcome of {}", outcome);
      switch (outcome) {
      case NONE:
        throw new UnsupportedOperationException("Received NONE on first batch");
      case NOT_YET:
      case STOP:
        return outcome;
      case OK_NEW_SCHEMA:
        if (!createAggregator()){
          done = true;
          return IterOutcome.STOP;
        }
        break;
      case OK:
        throw new IllegalStateException("You should never get a first batch without a new schema");
      default:
        throw new IllegalStateException(String.format("unknown outcome %s", outcome));
      }
    }

    if (aggregator.allFlushed()) {
      return IterOutcome.NONE;
    }

  if (aggregator.buildComplete() && ! aggregator.allFlushed()) {
    // aggregation is complete and not all records have been output yet
    IterOutcome outcome = aggregator.outputCurrentBatch();
    if (outcome == IterOutcome.NONE && first) {
      first = false;
      done = true;
      return IterOutcome.OK_NEW_SCHEMA;
    }
    return outcome;
  }

  logger.debug("Starting aggregator doWork; incoming record count = {} ", incoming.getRecordCount());

    while(true){
      AggOutcome out = aggregator.doWork();
      logger.debug("Aggregator response {}, records {}", out, aggregator.getOutputCount());
      switch(out){
      case CLEANUP_AND_RETURN:
        container.zeroVectors();
        aggregator.cleanup();
        done = true;
        // fall through
      case RETURN_OUTCOME:
        IterOutcome outcome = aggregator.getOutcome();
        if (outcome == IterOutcome.NONE && first) {
          first = false;
          done = true;
          return IterOutcome.OK_NEW_SCHEMA;
        }
View Full Code Here

        allocateOutgoing();
      }

      if (incoming.getRecordCount() == 0) {
        outer: while (true) {
          IterOutcome out = outgoing.next(0, incoming);
          switch (out) {
            case OK_NEW_SCHEMA:
            case OK:
              if (incoming.getRecordCount() == 0) {
                continue;
              } else {
                break outer;
              }
            case NONE:
              out = IterOutcome.OK_NEW_SCHEMA;
            case STOP:
            default:
              lastOutcome = out;
              outcome = out;
              done = true;
              return AggOutcome.CLEANUP_AND_RETURN;
          }
        }
      }

      // pick up a remainder batch if we have one.
      if(remainderBatch != null){
        if (!outputToBatch( previousIndex )) return tooBigFailure();
        remainderBatch.clear();
        remainderBatch = null;
        return setOkAndReturn();
      }


      // setup for new output and pick any remainder.
      if (pendingOutput) {
        allocateOutgoing();
        pendingOutput = false;
        if(EXTRA_DEBUG) logger.debug("Attempting to output remainder.");
        if (!outputToBatch( previousIndex)) return tooBigFailure();
      }

      if(newSchema){
        return AggOutcome.UPDATE_AGGREGATOR;
      }

      if(lastOutcome != null){
        outcome = lastOutcome;
        return AggOutcome.CLEANUP_AND_RETURN;
      }

      outside: while(true){
      // loop through existing records, adding as necessary.
        for (; underlyingIndex < incoming.getRecordCount(); incIndex()) {
          if(EXTRA_DEBUG) logger.debug("Doing loop with values underlying {}, current {}", underlyingIndex, currentIndex);
          if (previousIndex == -1) {
            if (EXTRA_DEBUG) logger.debug("Adding the initial row's keys and values.");
            addRecordInc(currentIndex);
          }
          else if (isSame( previousIndex, currentIndex )) {
            if(EXTRA_DEBUG) logger.debug("Values were found the same, adding.");
            addRecordInc(currentIndex);
          } else {
            if(EXTRA_DEBUG) logger.debug("Values were different, outputting previous batch.");
            if (outputToBatch(previousIndex)) {
              if(EXTRA_DEBUG) logger.debug("Output successful.");
              addRecordInc(currentIndex);
            } else {
              if(EXTRA_DEBUG) logger.debug("Output failed.");
              if(outputCount == 0) return tooBigFailure();

              // mark the pending output but move forward for the next cycle.
              pendingOutput = true;
              previousIndex = currentIndex;
              incIndex();
              return setOkAndReturn();

            }
          }
          previousIndex = currentIndex;
        }


        InternalBatch previous = null;

        try{
          while(true){
            if (previous != null) {
              previous.clear();
            }
            previous = new InternalBatch(incoming);
            IterOutcome out = outgoing.next(0, incoming);
            if(EXTRA_DEBUG) logger.debug("Received IterOutcome of {}", out);
            switch(out){
            case NONE:
              done = true;
              lastOutcome = out;
View Full Code Here

          while(true){
            // Cleanup the previous batch since we are done processing it.
            for (VectorWrapper<?> v : incoming) {
              v.getValueVector().clear();
            }
            IterOutcome out = outgoing.next(0, incoming);
            if(EXTRA_DEBUG_1) logger.debug("Received IterOutcome of {}", out);
            switch(out){
            case NOT_YET:
              this.outcome = out;
              return AggOutcome.RETURN_OUTCOME;
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.record.RecordBatch.IterOutcome

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.