Package org.apache.drill.exec.proto.UserProtos

Examples of org.apache.drill.exec.proto.UserProtos.QueryResult


  public QueryWritableBatch convertNext(boolean isLast) {
    //batch.getWritableBatch().getDef().getRecordCount()
    WritableBatch w = batch.getWritableBatch();

    QueryResult header = QueryResult.newBuilder() //
        .setQueryId(queryId) //
        .setRowCount(batch.getRecordCount()) //
        .setDef(w.getDef()).setIsLastChunk(isLast).build();
    QueryWritableBatch batch = new QueryWritableBatch(header, w.getBuffers());
    return batch;
View Full Code Here


  public RpcOutcomeListener<QueryId> getWrappedListener(UserResultsListener listener){
    return new SubmissionListener(listener);
  }
 
  public void batchArrived(ByteBuf pBody, ByteBuf dBody) throws RpcException {
    final QueryResult result = RpcBus.get(pBody, QueryResult.PARSER);
    final QueryResultBatch batch = new QueryResultBatch(result, dBody);
    UserResultsListener l = resultsListener.get(result.getQueryId());
   
    boolean failed = batch.getHeader().getQueryState() == QueryState.FAILED;
    // logger.debug("For QueryId [{}], retrieved result listener {}", result.getQueryId(), l);
    if (l == null) {
      BufferingListener bl = new BufferingListener();
      l = resultsListener.putIfAbsent(result.getQueryId(), bl);
      // if we had a succesful insert, use that reference.  Otherwise, just throw away the new bufering listener.
      if (l == null) l = bl;
      if (result.getQueryId().toString().equals("")) {
        failAll();
      }
    }
     
    if(failed){
      l.submissionFailed(new RpcException("Remote failure while running query." + batch.getHeader().getErrorList()));
      resultsListener.remove(result.getQueryId(), l);
    }else{
      l.resultArrived(batch);
    }
   
    if (
        (failed || result.getIsLastChunk())
        &&
        (!(l instanceof BufferingListener) || ((BufferingListener)l).output != null)
        ) {
      resultsListener.remove(result.getQueryId(), l);
    }


  }
View Full Code Here

  private void fail(String message, Throwable t) {
    if(isFinished()){
      logger.error("Received a failure message query finished of: {}", message, t);
    }
    DrillPBError error = ErrorHelper.logAndConvertError(context.getCurrentEndpoint(), message, t, logger);
    QueryResult result = QueryResult //
        .newBuilder() //
        .addError(error) //
        .setIsLastChunk(true) //
        .setQueryState(QueryState.FAILED) //
        .setQueryId(queryId) //
View Full Code Here

    }
   
    // cancel remote fragments.
    fragmentManager.cancel();
   
    QueryResult result = QueryResult.newBuilder().setQueryState(QueryState.CANCELED).setIsLastChunk(true).setQueryId(queryId).build();
    cleanupAndSendResult(result);
  }
View Full Code Here

 
  private void finished(FragmentStatus status){
    updateStatus(status);
    int remaining = remainingFragmentCount.decrementAndGet();
    if(remaining == 0){
      QueryResult result = QueryResult.newBuilder() //
              .setQueryState(QueryState.COMPLETED) //
              .setQueryId(queryId) //
              .build();
      foreman.cleanupAndSendResult(result);
    }
View Full Code Here

  }
 
  private void fail(FragmentStatus status){
    updateStatus(status);
    stopQuery();
    QueryResult result = QueryResult.newBuilder().setQueryId(queryId).setQueryState(QueryState.FAILED).addError(status.getError()).build();
    foreman.cleanupAndSendResult(result);
  }
View Full Code Here

      IterOutcome outcome = incoming.next();
      logger.debug("Screen Outcome {}", outcome);
      switch(outcome){
      case STOP: {
          QueryResult header = QueryResult.newBuilder() //
              .setQueryId(context.getHandle().getQueryId()) //
              .setRowCount(0) //
              .addError(ErrorHelper.logAndConvertError(context.getIdentity(), "Screen received stop request sent.", context.getFailureCause(), logger))
              .setDef(RecordBatchDef.getDefaultInstance()) //
              .setIsLastChunk(true) //
              .build();
          QueryWritableBatch batch = new QueryWritableBatch(header);
          connection.sendResult(listener, batch);

          return false;
      }
      case NONE: {
        if(materializer == null){
          // receive no results.
          context.batchesCompleted.inc(1);
          context.recordsCompleted.inc(incoming.getRecordCount());
          QueryResult header = QueryResult.newBuilder() //
              .setQueryId(context.getHandle().getQueryId()) //
              .setRowCount(0) //
              .setDef(RecordBatchDef.getDefaultInstance()) //
              .setIsLastChunk(true) //
              .build();
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.proto.UserProtos.QueryResult

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.