Package org.apache.drill.exec.record

Examples of org.apache.drill.exec.record.RawFragmentBatch


  }

  @Override
  public RawFragmentBatch getNext(){
   
    RawFragmentBatch b = buffer.poll();
    if(b == null && !finished){
      try {
        return buffer.take();
      } catch (InterruptedException e) {
        return null;
View Full Code Here


        bee.addFragmentPendingRemote(newHandler);
        handler = newHandler;
      }
    }
   
    boolean canRun = handler.handle(connection.getConnectionThrottle(), new RawFragmentBatch(fragmentBatch, body));
    if(canRun){
      logger.debug("Arriving batch means local batch can run, starting local batch.");
      // if we've reached the canRun threshold, we'll proceed.  This expects handler.handle() to only return a single true.
      bee.startFragmentPendingRemote(handler);
    }
View Full Code Here

    return batchLoader.getValueAccessorById(fieldId, clazz);
  }

  @Override
  public IterOutcome next() {
    RawFragmentBatch batch = fragProvider.getNext();
    try{
      if (batch == null) return IterOutcome.NONE;

      logger.debug("Next received batch {}", batch);

      RecordBatchDef rbd = batch.getHeader().getDef();
      boolean schemaChanged = batchLoader.load(rbd, batch.getBody());
      batch.release();
      if(schemaChanged){
        this.schema = batchLoader.getSchema();
        return IterOutcome.OK_NEW_SCHEMA;
      }else{
        return IterOutcome.OK;
View Full Code Here

  @Override
  public IterOutcome next() {
    stats.startProcessing();
    try{
      RawFragmentBatch batch;
      try {
        stats.startWait();
        batch = fragProvider.getNext();

        // skip over empty batches. we do this since these are basically control messages.
        while (batch != null && !batch.getHeader().getIsOutOfMemory() && batch.getHeader().getDef().getRecordCount() == 0 && !first) {
          batch = fragProvider.getNext();
        }
      } finally {
        stats.stopWait();
      }

      first = false;

      if (batch == null) {
        batchLoader.clear();
        if (context.isCancelled()) {
          return IterOutcome.STOP;
        }
        return IterOutcome.NONE;
      }

      if (batch.getHeader().getIsOutOfMemory()) {
        return IterOutcome.OUT_OF_MEMORY;
      }


//      logger.debug("Next received batch {}", batch);

      RecordBatchDef rbd = batch.getHeader().getDef();
      boolean schemaChanged = batchLoader.load(rbd, batch.getBody());
      stats.addLongStat(Metric.BYTES_RECEIVED, batch.getByteCount());

      batch.release();
      if(schemaChanged) {
        this.schema = batchLoader.getSchema();
        stats.batchReceived(0, rbd.getRecordCount(), true);
        return IterOutcome.OK_NEW_SCHEMA;
      } else {
View Full Code Here

      fragmentManager.setAutoRead(true);
      logger.debug("Setting autoRead true");
    }
    boolean spool = spooling.get();
    RawFragmentBatchWrapper w = buffer.poll();
    RawFragmentBatch batch;
    if(w == null && !finished){
      try {
        w = buffer.take();
        batch = w.get();
        if (batch.getHeader().getIsOutOfMemory()) {
          outOfMemory = true;
          return batch;
        }
        queueSize -= w.getBodySize();
        return batch;
      } catch (InterruptedException e) {
        return null;
      }
    }
    if (w == null) {
      return null;
    }

    batch = w.get();
    if (batch.getHeader().getIsOutOfMemory()) {
      outOfMemory = true;
      return batch;
    }
    queueSize -= w.getBodySize();
//    assert queueSize >= 0;
View Full Code Here

      Stopwatch watch = new Stopwatch();
      watch.start();
      BitData.FragmentRecordBatch header = BitData.FragmentRecordBatch.parseDelimitedFrom(stream);
      ByteBuf buf = allocator.buffer(bodyLength);
      buf.writeBytes(stream, bodyLength);
      batch = new RawFragmentBatch(null, header, buf, null);
      buf.release();
      available = true;
      latch.countDown();
      long t = watch.elapsed(TimeUnit.MICROSECONDS);
      logger.debug("Took {} us to read {} from disk. Rate {} mb/s", t, bodyLength, bodyLength / t);
View Full Code Here


  public void handle(RemoteConnection connection, FragmentManager manager, FragmentRecordBatch fragmentBatch, ByteBuf data, ResponseSender sender) throws RpcException {
//    logger.debug("Fragment Batch received {}", fragmentBatch);
    try {
      boolean canRun = manager.handle(new RawFragmentBatch(connection, fragmentBatch, data, sender));
      if (canRun) {
//        logger.debug("Arriving batch means local batch can run, starting local batch.");
        // if we've reached the canRun threshold, we'll proceed. This expects handler.handle() to only return a single
        // true.
        bee.startFragmentPendingRemote(manager);
View Full Code Here

    if (!buffer.isEmpty()) {
      if (!context.isFailed() && !context.isCancelled()) {
        context.fail(new IllegalStateException("Batches still in queue during cleanup"));
        logger.error("{} Batches in queue.", buffer.size());
        RawFragmentBatch batch;
        while ((batch = buffer.poll()) != null) {
          logger.error("Batch left in queue: {}", batch);
        }
      }
      RawFragmentBatch batch;
      while ((batch = buffer.poll()) != null) {
        if (batch.getBody() != null) batch.getBody().release();
      }
    }
  }
View Full Code Here

  }

  @Override
  public void kill(FragmentContext context) {
    while(!buffer.isEmpty()){
      RawFragmentBatch batch = buffer.poll();
      batch.getBody().release();
    }
  }
View Full Code Here

      logger.debug("Setting autoread true");
      outOfMemory.set(false);
      readController.flushResponses();
    }

    RawFragmentBatch b = null;

    b = buffer.poll();

    // if we didn't get a buffer, block on waiting for buffer.
    if(b == null && (!finished || !buffer.isEmpty())){
      try {
        b = buffer.take();
      } catch (InterruptedException e) {
        return null;
      }
    }

    if (b != null && b.getHeader().getIsOutOfMemory()) {
      outOfMemory.set(true);
      return b;
    }


    // if we are in the overlimit condition and aren't finished, check if we've passed the start limit.  If so, turn off the overlimit condition and set auto read to true (start reading from socket again).
    if(!finished && overlimit.get()){
      if(buffer.size() == startlimit){
        overlimit.set(false);
        readController.flushResponses();
      }
    }

    if (b != null && b.getHeader().getIsLastBatch()) {
      streamCounter--;
      if (streamCounter == 0) {
        finished();
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.record.RawFragmentBatch

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.