Java Code Examples for org.apache.arrow.vector.IntVector#set()

The following examples show how to use org.apache.arrow.vector.IntVector#set() . 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: TestData.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
private Pair<IntVector, ResultVerifier> testIntVector() {
  final String colName = "colInt";
  final List<Integer> values =  asList(20, 50, -2000, 327345, null);

  IntVector valuesVector = new IntVector(colName, allocator);
  valuesVector.allocateNew(values.size());
  for (int i = 0; i < values.size(); i++) {
    if (values.get(i) == null) {
      valuesVector.setNull(i);
    } else {
      valuesVector.set(i, values.get(i));
    }
  }

  ResultVerifier verifier = new ResultVerifier() {
    @Override
    public void verify(DataPOJO output) {
      verifyIntValues(values, output, colName);
    }
  };

  return Pair.of(valuesVector, verifier);
}
 
Example 2
Source File: VectorizedDictionaryEncodedParquetValuesReader.java    From iceberg with Apache License 2.0 5 votes vote down vote up
void readBatchOfDictionaryIds(IntVector intVector, int startOffset, int numValuesToRead,
                              NullabilityHolder nullabilityHolder) {
  int left = numValuesToRead;
  int idx = startOffset;
  while (left > 0) {
    if (this.currentCount == 0) {
      this.readNextGroup();
    }
    int numValues = Math.min(left, this.currentCount);
    switch (mode) {
      case RLE:
        for (int i = 0; i < numValues; i++) {
          intVector.set(idx, currentValue);
          setNotNull(intVector, nullabilityHolder, idx);
          idx++;
        }
        break;
      case PACKED:
        for (int i = 0; i < numValues; i++) {
          intVector.set(idx, packedValuesBuffer[packedValuesBufferIdx++]);
          setNotNull(intVector, nullabilityHolder, idx);
          idx++;
        }
        break;
    }
    left -= numValues;
    currentCount -= numValues;
  }
}
 
Example 3
Source File: TestQueryReAttempt.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
private IntVector intVector(String name) {
  IntVector vec = new IntVector(name, allocator);
  vec.allocateNew(5);
  vec.set(0, 20);
  vec.set(1, 50);
  vec.set(2, -2000);
  vec.set(3, 327345);
  vec.setNull(4);

  vec.setValueCount(COUNT);
  return vec;
}
 
Example 4
Source File: MockHiveWarehouseConnector.java    From spark-llap with Apache License 2.0 5 votes vote down vote up
public MockLlapArrowBatchRecordReader(long arrowAllocatorMax) {
  BufferAllocator allocator = RootAllocatorFactory.INSTANCE.getOrCreateRootAllocator(arrowAllocatorMax);
  IntVector vector = new IntVector("a", allocator);
  vector.allocateNewSafe();
  for(int i = 0; i < testVector.length; i++) {
    vector.set(i, testVector[i]);
  }
  vector.setValueCount(testVector.length);
  List<Field> fields = Lists.newArrayList(vector.getField());
  List<FieldVector> vectors = new ArrayList<>();
  vectors.add(vector);
  vectorSchemaRoot = new VectorSchemaRoot(fields, vectors, testVector.length);
}