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

The following examples show how to use org.apache.arrow.vector.ValueVector#clear() . 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
void evaluateProjector(int recordsToConsume, Stopwatch javaWatch, Stopwatch gandivaWatch) throws Exception {
  try {
    allocateNew(recordsToConsume);

    gandivaWatch.start();
    nativeProjectEvaluator.evaluate(recordsToConsume);
    gandivaWatch.stop();
    javaWatch.start();
    javaProjector.projectRecords(recordsToConsume);
    javaWatch.stop();

    setValueCount(recordsToConsume);
    transferOut();
  } catch (Exception e) {
    // release memory allocated in case of an exception
    for(ValueVector vv : allocationVectors) {
      vv.clear();
    }

    for(ComplexWriter writer : complexWriters) {
      writer.clear();
    }

    throw e;
  } finally {
    markSplitOutputAsRead();
  }
}
 
Example 2
Source File: SampleMutator.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Since this OutputMutator is passed by TextRecordReader to get the header out
 * the mutator might not get cleaned up elsewhere. TextRecordReader will call
 * this method to clear any allocations
 */
public void close() {
  logger.debug("closing mutator");
  for (final ValueVector v : fieldVectorMap.values()) {
    v.clear();
  }
  fieldVectorMap.clear();
  container.clear();
  bufferManager.close();
}
 
Example 3
Source File: CompliantTextRecordReader.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Since this OutputMutator is passed by TextRecordReader to get the header out
 * the mutator might not get cleaned up elsewhere. TextRecordReader will call
 * this method to clear any allocations
 */
@Override
public void close() {
  for (final ValueVector v : fieldVectorMap.values()) {
    v.clear();
  }
  fieldVectorMap.clear();
}
 
Example 4
Source File: ScanOperator.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends ValueVector> T addField(Field field,
                                          Class<T> clazz) throws SchemaChangeException {
  // Check if the field exists.
  final ValueVector v = fieldVectorMap.get(field.getName().toLowerCase());
  if (v == null || !clazz.isAssignableFrom(v.getClass()) || checkIfDecimalsTypesAreDifferent(v, field)) {
    // Field does not exist--add it to the map and the output container.
    ValueVector newVector = TypeHelper.getNewVector(field, context.getAllocator(), callBack);
    if (!clazz.isAssignableFrom(newVector.getClass())) {
      throw new SchemaChangeException(
          String.format(
              "The class that was provided, %s, does not correspond to the "
              + "expected vector type of %s.",
              clazz.getSimpleName(), newVector.getClass().getSimpleName()));
    }

    final ValueVector old = fieldVectorMap.put(field.getName().toLowerCase(), newVector);
    if (old != null) {
      old.clear();
      outgoing.remove(old);
    }

    outgoing.add(newVector);
    return clazz.cast(newVector);
  }

  return clazz.cast(v);
}
 
Example 5
Source File: DremioTestWrapper.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private void cleanupHyperValueIterators(Collection<HyperVectorValueIterator> hyperBatches) {
  for (HyperVectorValueIterator hvi : hyperBatches) {
    for (ValueVector vv : hvi.getHyperVector().getValueVectors()) {
      vv.clear();
    }
  }
}
 
Example 6
Source File: CopierTemplate4.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
private void clearVectors() {
  for (VectorWrapper<?> vw : outgoing) {
    final ValueVector v = vw.getValueVector();
    v.clear();
  }
}
 
Example 7
Source File: CopierTemplate2.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
private void clearVectors() {
  for (VectorWrapper<?> vw : outgoing) {
    final ValueVector v = vw.getValueVector();
    v.clear();
  }
}