@Override final long getLong(int rowId) { return accessor.get(rowId); } }
@Override public FieldVector getNewVector( String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { return new BigIntVector(name, fieldType, allocator); }
@Override public void allocate() { vector.allocateNew(); }
public void populate(final int count){ for (int i = 0; i < count; i++) { if(value != null) { ((BigIntVector) vector).setSafe(i, value); } } vector.setValueCount(count); }
/** * Same as {@link #set(int, int, long)} except that it handles the case * when index is greater than or equal to current value capacity of the * vector. * @param index position of the new value * @param isSet 0 for NULL value, 1 otherwise * @param value element value */ public void setSafe(int index, int isSet, long value) { handleSafe(index); set(index, isSet, value); }
/** * * @param allocator * @param name * @param data * @return */ public static BigIntVector vectorFor(BufferAllocator allocator,String name,long[] data) { BigIntVector float8Vector = new BigIntVector(name,FieldType.nullable(new ArrowType.Int(64,true)),allocator); float8Vector.allocateNew(data.length); for(int i = 0; i < data.length; i++) { float8Vector.setSafe(i,data[i]); } float8Vector.setValueCount(data.length); return float8Vector; }
static Long[] populate8ByteValuesWithoutNull(BigIntVector vector, int size){ vector.allocateNew(); Long values[] = new Long[size]; for(int i = 0; i < values.length; i++){ values[i] = RAND.nextLong(); vector.setSafe(i, values[i]); } vector.setValueCount(values.length); return values; }
private static VectorContainer buildLongGlobalDictionary(List<Dictionary> dictionaries, VectorContainer existingDict, ColumnDescriptor columnDescriptor, BufferAllocator bufferAllocator) { final Field field = new Field(SchemaPath.getCompoundPath(columnDescriptor.getPath()).getAsUnescapedPath(), true, new ArrowType.Int(64, true), null); final VectorContainer input = new VectorContainer(bufferAllocator); final BigIntVector longVector = input.addOrGet(field); longVector.allocateNew(); SortedSet<Long> values = Sets.newTreeSet(); for (Dictionary dictionary : dictionaries) { for (int i = 0; i <= dictionary.getMaxId(); ++i) { values.add(dictionary.decodeToLong(i)); } } if (existingDict != null) { final BigIntVector existingDictValues = existingDict.getValueAccessorById(BigIntVector.class, 0).getValueVector(); for (int i = 0; i < existingDict.getRecordCount(); ++i) { values.add(existingDictValues.get(i)); } } final Iterator<Long> iter = values.iterator(); int recordCount = 0; while (iter.hasNext()) { longVector.setSafe(recordCount++, iter.next()); } longVector.setValueCount(recordCount); input.setRecordCount(recordCount); input.buildSchema(BatchSchema.SelectionVectorMode.NONE); return input; }
ArgumentCaptor<Integer> partitionCaptor = ArgumentCaptor.forClass(Integer.class); BigIntVector bigIntVector = new BigIntVector("key", ALLOCATOR); bigIntVector.allocateNew(2); bigIntVector.set(0, 52459253098448904L); bigIntVector.set(1, 1116675951L);
private static Pair<BigIntVector, ResultVerifier> testBigIntVector(final int startIndexInCurrentOutput, final int startIndexInJob) { BigIntVector colBigIntV = new BigIntVector("colBigInt", allocator); colBigIntV.allocateNew(5); colBigIntV.setNull(0); colBigIntV.set(1, 50); colBigIntV.set(2, -2000); colBigIntV.set(3, 327345234234L); colBigIntV.set(4, 0); ResultVerifier verifier = new ResultVerifier() { @Override public void verify(DataPOJO output) { int index = startIndexInCurrentOutput; assertNull(output.extractValue("colBigInt", index++)); assertEquals(50, ((Integer)output.extractValue("colBigInt", index++)).intValue()); assertEquals(-2000, ((Integer)output.extractValue("colBigInt", index++)).intValue()); assertEquals(327345234234L, ((Long)output.extractValue("colBigInt", index++)).longValue()); assertEquals(0, ((Integer)output.extractValue("colBigInt", index++)).intValue()); } }; return Pair.of(colBigIntV, verifier); }
/** * * @param allocator * @param name * @param length the number of rows in the column vector * @return */ public static BigIntVector longVectorOf(BufferAllocator allocator,String name,int length) { BigIntVector float8Vector = new BigIntVector(name,FieldType.nullable(new ArrowType.Int(64,true)),allocator); float8Vector.allocateNew(length); float8Vector.setValueCount(length); return float8Vector; }
@Override public void writeField(Object pojo, int outboundIndex) throws IllegalArgumentException, IllegalAccessException { Long o = (Long) field.get(pojo); if (o != null) { vector.setSafe(outboundIndex, o); } } }
BigIntVector c1 = loader.getValueAccessorById(BigIntVector.class, loader.getValueVectorId(new SchemaPath("blue")).getFieldIds()).getValueVector(); for (int i =0; i < c1.getValueCount(); i++) { recordCount++; assertTrue(String.format("%d < %d", previousBigInt, c1.get(i)), previousBigInt >= c1.get(i)); previousBigInt = c1.get(i); assertTrue(String.format("%d == %d", c1.get(0), c1.get(c1.getValueCount() - 1)), c1.get(0) != c1.get(c1.getValueCount() - 1)); loader.clear(); b.release();
final boolean firstPartition) { BigIntVector in1SumOutputVector = new BigIntVector("int-sum", allocator); final SumAccumulators.IntSumAccumulator in1SumAccum = new SumAccumulators.IntSumAccumulator(in1, in1SumOutputVector, in1SumOutputVector, MAX_VALUES_PER_BATCH, BigIntVector in1Count = new BigIntVector("int-count", allocator); final CountColumnAccumulator in1countAccum = new CountColumnAccumulator(in1, in1Count, in1Count, MAX_VALUES_PER_BATCH, BigIntVector in1Count1 = new BigIntVector("int-count1", allocator); final CountOneAccumulator in1count1Accum = new CountOneAccumulator(null, in1Count1, in1Count1, MAX_VALUES_PER_BATCH, postSpillAccumulatorVectorFields.add(in1SumOutputVector.getField()); postSpillAccumulatorVectorFields.add(in1MaxOutputVector.getField()); postSpillAccumulatorVectorFields.add(in1MinOutputVector.getField()); postSpillAccumulatorVectorFields.add(in1Count.getField()); postSpillAccumulatorVectorFields.add(in1Count1.getField());
assertEquals(valueCount, ac1New.getValueCount()); assertEquals(valueCount, ac2New.getValueCount()); assertEquals(valueCount, ac3New.getValueCount()); assertEquals(valueCount, ac4New.getValueCount()); assertEquals(valueCount, ac5New.getValueCount()); assertEquals(valueCount, ac6New.getValueCount()); assertEquals(valueCount, ac7New.getValueCount()); assertEquals(valueCount, ac8New.getValueCount()); assertEquals(valueCount, ac9New.getValueCount()); assertEquals(valueCount, ac13New.getValueCount()); assertEquals(valueCount, ac17New.getValueCount()); assertEquals(sum.intOut[i], ac1New.getObject(i)); assertEquals(max.intOut[i], ac2New.getObject(i)); assertEquals(min.intOut[i], ac3New.getObject(i)); assertEquals(counts[i], ac4New.get(i)); assertEquals(counts1[i], ac5New.get(i)); assertEquals(sum.bigintOut[i], ac6New.getObject(i)); assertEquals(max.bigintOut[i], ac7New.getObject(i)); assertEquals(min.bigintOut[i], ac8New.getObject(i)); assertEquals(counts[i], ac9New.get(i)); assertEquals(counts[i], ac13New.get(i)); assertEquals(counts[i], ac17New.get(i));
@Override public void copy(int inputIdx, int count, int outputIdx) { final long[] input = inputVector.vector; if (inputVector.isRepeating) { if (inputVector.isNull[0]) { return; // If all repeating values are null, then there is no need to write anything to vector } final long value = input[0]; for (int i = 0; i < count; i++, outputIdx++) { outputVector.set(outputIdx, value); } } else if (inputVector.noNulls) { for (int i = 0; i < count; i++, inputIdx++, outputIdx++) { outputVector.set(outputIdx, input[inputIdx]); } } else { final boolean isNull[] = inputVector.isNull; for (int i = 0; i < count; i++, inputIdx++, outputIdx++) { if (!isNull[inputIdx]) { outputVector.set(outputIdx, input[inputIdx]); } } } } }
public void loadData(SerializedField metadata, ArrowBuf buffer) { /* clear the current buffers (if any) */ vector.clear(); /* get the metadata children */ final SerializedField bitsField = metadata.getChild(0); final SerializedField valuesField = metadata.getChild(1); final int valuesLength = buffer.capacity(); vector.allocateNew(metadata.getValueCount()); /* set inner validity buffer */ setValidityBuffer(bitsField); /* load inner value buffer */ vector.valueBuffer.close(); loadDataBuffer(valuesField, buffer.slice(0, valuesLength)); }
public void writeNull() { vector.setNull(idx()); vector.setValueCount(idx()+1); } }