Package org.apache.drill.exec.record.selection

Examples of org.apache.drill.exec.record.selection.SelectionVector4


      SchemaPath sp = SchemaPath.getSimplePath("f" + i++);
      orderDefs.add(new Ordering(od.getDirection(), new FieldReference(sp)));
    }

    // sort the data incoming samples.
    SelectionVector4 newSv4 = containerBuilder.getSv4();
    Sorter sorter = SortBatch.createNewSorter(context, orderDefs, allSamplesContainer);
    sorter.setup(context, newSv4, allSamplesContainer);
    sorter.sort(newSv4, allSamplesContainer);

    // Copy every Nth record from the samples into a candidate partition table, where N = totalSampledRecords/partitions
View Full Code Here


    this.limit = limit;
    this.context = context;
    this.allocator = allocator;
    BufferAllocator.PreAllocator preAlloc = allocator.getNewPreAllocator();
    preAlloc.preAllocate(4 * (limit + 1));
    heapSv4 = new SelectionVector4(preAlloc.getAllocation(), limit, Character.MAX_VALUE);
    this.hasSv2 = hasSv2;
  }
View Full Code Here

    newContainer.buildSchema(BatchSchema.SelectionVectorMode.FOUR_BYTE);
    this.hyperBatch = new ExpandableHyperContainer(newContainer);
    this.batchCount = hyperBatch.iterator().next().getValueVectors().length;
    BufferAllocator.PreAllocator preAlloc = allocator.getNewPreAllocator();
    preAlloc.preAllocate(4 * (limit + 1));
    this.heapSv4 = new SelectionVector4(preAlloc.getAllocation(), limit, Character.MAX_VALUE);
    for (int i = 0; i < v4.getTotalCount(); i++) {
      heapSv4.set(i, v4.get(i));
    }
    v4.clear();
  }
View Full Code Here

  public void generate() throws SchemaChangeException {
    Stopwatch watch = new Stopwatch();
    watch.start();
    BufferAllocator.PreAllocator preAlloc = allocator.getNewPreAllocator();
    preAlloc.preAllocate(4 * queueSize);
    finalSv4 = new SelectionVector4(preAlloc.getAllocation(), queueSize, 4000);
    for (int i = queueSize - 1; i >= 0; i--) {
      finalSv4.set(i, pop());
    }
    logger.debug("Took {} us to generate output of {}", watch.elapsed(TimeUnit.MICROSECONDS), finalSv4.getTotalCount());
  }
View Full Code Here

  public SelectionVector4 getNewSV4(int recordCount) throws SchemaChangeException {

    ByteBuf vector = allocator.buffer((recordCount * 4));

    SelectionVector4 sv4 = new SelectionVector4(vector, recordCount, recordCount);

    // Initialize the vector
    for (int i = 0; i < recordCount; i++) {
      sv4.set(i, INDEX_EMPTY);
    }

    return sv4;
  }
View Full Code Here

    int batchIdx  = keyIndex / HashTable.BATCH_SIZE;
    int offsetIdx = keyIndex % HashTable.BATCH_SIZE;

    assert batchIdx < startIndices.size();

    SelectionVector4 sv4 = startIndices.get(batchIdx);

    return sv4.get(offsetIdx);
  }
View Full Code Here

    if (keyIndex >= (HashTable.BATCH_SIZE * startIndices.size())) {
        // allocate a new batch
      addStartIndexBatch();
    }

    SelectionVector4 startIndex = startIndices.get(batchIdx);
    int linkIndex;

    // If head of the list is empty, insert current index at this position
    if ((linkIndex = (startIndex.get(offsetIdx))) == INDEX_EMPTY) {
      startIndex.set(offsetIdx, batchIndex, recordIndex);
    } else {
      /* Head of this list is not empty, if the first link
       * is empty insert there
       */
      batchIdx = linkIndex >>> SHIFT_SIZE;
      offsetIdx = linkIndex & Character.MAX_VALUE;

      SelectionVector4 link = buildInfoList.get(batchIdx).getLinks();
      int firstLink = link.get(offsetIdx);

      if (firstLink == INDEX_EMPTY) {
        link.set(offsetIdx, batchIndex, recordIndex);
      } else {
        /* Insert the current value as the first link and
         * make the current first link as its next
         */
        int firstLinkBatchIdx  = firstLink >>> SHIFT_SIZE;
        int firstLinkOffsetIDx = firstLink & Character.MAX_VALUE;

        SelectionVector4 nextLink = buildInfoList.get(batchIndex).getLinks();
        nextLink.set(recordIndex, firstLinkBatchIdx, firstLinkOffsetIDx);

        link.set(offsetIdx, batchIndex, recordIndex);
      }
    }
  }
View Full Code Here

  private void purge() throws SchemaChangeException {
    Stopwatch watch = new Stopwatch();
    watch.start();
    VectorContainer c = priorityQueue.getHyperBatch();
    VectorContainer newContainer = new VectorContainer();
    SelectionVector4 selectionVector4 = priorityQueue.getHeapSv4();
    SimpleRecordBatch batch = new SimpleRecordBatch(c, selectionVector4, context);
    SimpleRecordBatch newBatch = new SimpleRecordBatch(newContainer, null, context);
    if (copier == null) {
      copier = RemovingRecordBatch.getGenerated4Copier(batch, context, oContext.getAllocator(),  newContainer, newBatch);
    } else {
      for(VectorWrapper<?> i : batch){

        ValueVector v = TypeHelper.getNewVector(i.getField(), oContext.getAllocator());
        newContainer.add(v);
      }
      copier.setupRemover(context, batch, newBatch);
    }
    SortRecordBatchBuilder builder = new SortRecordBatchBuilder(oContext.getAllocator(), MAX_SORT_BYTES);
    do {
      int count = selectionVector4.getCount();
      int copiedRecords = copier.copyRecords(0, count);
      assert copiedRecords == count;
      for(VectorWrapper<?> v : newContainer){
        ValueVector.Mutator m = v.getValueVector().getMutator();
        m.setValueCount(count);
      }
      newContainer.buildSchema(BatchSchema.SelectionVectorMode.NONE);
      newContainer.setRecordCount(count);
      builder.add(newBatch);
    } while (selectionVector4.next());
    selectionVector4.clear();
    c.clear();
    VectorContainer newQueue = new VectorContainer();
    builder.canonicalize();
    builder.build(context, newQueue);
    priorityQueue.resetQueue(newQueue, builder.getSv4().createNewWrapperCurrent());
    builder.getSv4().clear();
    selectionVector4.clear();
    logger.debug("Took {} us to purge", watch.elapsed(TimeUnit.MICROSECONDS));
  }
View Full Code Here

        // set up the multi-batch selection vector
        this.svAllocator = oContext.getAllocator().getNewPreAllocator();
        if (!svAllocator.preAllocate(incoming.getRecordCount()*4))
          throw new SchemaChangeException("Attempted to filter an SV4 which exceeds allowed memory (" +
                                          incoming.getRecordCount() * 4 + " bytes)");
        sv4 = new SelectionVector4(svAllocator.getAllocation(), incoming.getRecordCount(), Character.MAX_VALUE);
        this.filter = generateSV4Filterer();
        break;
      default:
        throw new UnsupportedOperationException();
    }
View Full Code Here

  private void purge() throws SchemaChangeException {
    Stopwatch watch = new Stopwatch();
    watch.start();
    VectorContainer c = priorityQueue.getHyperBatch();
    VectorContainer newContainer = new VectorContainer(oContext);
    SelectionVector4 selectionVector4 = priorityQueue.getHeapSv4();
    SimpleRecordBatch batch = new SimpleRecordBatch(c, selectionVector4, context);
    SimpleRecordBatch newBatch = new SimpleRecordBatch(newContainer, null, context);
    if (copier == null) {
      copier = RemovingRecordBatch.getGenerated4Copier(batch, context, oContext.getAllocator(),  newContainer, newBatch);
    } else {
      for (VectorWrapper<?> i : batch) {

        ValueVector v = TypeHelper.getNewVector(i.getField(), oContext.getAllocator());
        newContainer.add(v);
      }
      copier.setupRemover(context, batch, newBatch);
    }
    SortRecordBatchBuilder builder = new SortRecordBatchBuilder(oContext.getAllocator(), MAX_SORT_BYTES);
    do {
      int count = selectionVector4.getCount();
      int copiedRecords = copier.copyRecords(0, count);
      assert copiedRecords == count;
      for (VectorWrapper<?> v : newContainer) {
        ValueVector.Mutator m = v.getValueVector().getMutator();
        m.setValueCount(count);
      }
      newContainer.buildSchema(BatchSchema.SelectionVectorMode.NONE);
      newContainer.setRecordCount(count);
      builder.add(newBatch);
    } while (selectionVector4.next());
    selectionVector4.clear();
    c.clear();
    VectorContainer newQueue = new VectorContainer();
    builder.canonicalize();
    builder.build(context, newQueue);
    priorityQueue.resetQueue(newQueue, builder.getSv4().createNewWrapperCurrent());
    builder.getSv4().clear();
    selectionVector4.clear();
    logger.debug("Took {} us to purge", watch.elapsed(TimeUnit.MICROSECONDS));
  }
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.record.selection.SelectionVector4

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.