Java Code Examples for org.apache.arrow.vector.ValueVector#makeTransferPair()

The following examples show how to use org.apache.arrow.vector.ValueVector#makeTransferPair() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SplitStageExecutor.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private Field setupSplit(ExpressionSplit split, VectorContainer outgoing, boolean gandivaCodeGen) throws GandivaException {
  NamedExpression namedExpression = split.getNamedExpression();
  LogicalExpression expr = namedExpression.getExpr();
  Field outputField = expr.getCompleteType().toField(namedExpression.getRef());
  ValueVector vector = intermediateOutputs.addOrGet(outputField);
  split.setOutputOfSplit(vector);

  if (outgoing != null) {
    // transfer the output to the outgoing VectorContainer
    ValueVector transferTo = outgoing.addOrGet(outputField);
    transferPairs.add(vector.makeTransferPair(transferTo));
  }

  // space needs to be allocated for this vector
  allocationVectors.add(vector);

  if (gandivaCodeGen) {
    logger.trace("Setting up split for {} in Gandiva", split.toString());
    nativeProjectorBuilder.add(expr, vector);
    return outputField;
  }

  logger.trace("Setting up split for {} in Java", split.toString());
  // setup in Java
  TypedFieldId fid = intermediateOutputs.getValueVectorId(SchemaPath.getSimplePath(outputField.getName()));
  boolean useSetSafe = !(vector instanceof FixedWidthVector);
  ValueVectorWriteExpression write = new ValueVectorWriteExpression(fid, expr, useSetSafe);
  cg.addExpr(write, ClassGenerator.BlockCreateMode.NEW_IF_TOO_LARGE, true);

  if (expr instanceof ValueVectorReadExpression) {
    final ValueVectorReadExpression vectorRead = (ValueVectorReadExpression) expr;
    if (!vectorRead.hasReadPath()) {
      final TypedFieldId id = vectorRead.getFieldId();
      final ValueVector vvIn = incoming.getValueAccessorById(id.getIntermediateClass(), id.getFieldIds()).getValueVector();
      vvIn.makeTransferPair(vector);
    }
  }

  return outputField;
}
 
Example 2
Source File: HashTableTemplate.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private void outputKeys(VectorContainer outContainer) {

      /** for debugging
      BigIntVector vv0 = getValueVector(0);
      BigIntHolder holder = new BigIntHolder();
      */

      // set the value count for htContainer's value vectors before the transfer ..
      setValueCount();

      Iterator<VectorWrapper<?>> outgoingIter = outContainer.iterator();

      for (VectorWrapper<?> sourceWrapper : htContainer) {
        ValueVector sourceVV = sourceWrapper.getValueVector();
        ValueVector targetVV = outgoingIter.next().getValueVector();
        TransferPair tp = sourceVV.makeTransferPair(targetVV);
        tp.transfer();
      }

/*
      logger.debug("Attempting to output keys for batch index: {} from index {} to maxOccupiedIndex {}.",
      this.batchIndex, 0, maxOccupiedIdx);
      for (int i = batchOutputCount; i <= maxOccupiedIdx; i++) {
        if (outputRecordKeys(i, batchOutputCount) ) {
          if (EXTRA_DEBUG) logger.debug("Outputting keys to output index: {}", batchOutputCount) ;

          // debugging
          // holder.value = vv0.getAccessor().get(i);
          // if (holder.value == 100018 || holder.value == 100021) {
          //  logger.debug("Outputting key = {} at index - {} to outgoing index = {}.", holder.value, i,
          //      batchOutputCount);
          // }

          batchOutputCount++;
        } else {
          return false;
        }
      }
 */
    }