public void populate(final int count){ for (int i = 0; i < count; i++) { if(value != null) { ((BigIntVector) vector).setSafe(i, value); } } vector.setValueCount(count); }
private static void writeBigIntData(BigIntVector vector, int valueCount) { final long even = 1000000000; final long odd = 2000000000; for (int i = 0; i < valueCount; i++) { if (i % 2 == 0) { vector.setSafe(i, even); } else { vector.setSafe(i, odd); } } vector.setValueCount(valueCount); }
public void writeNull() { vector.setNull(idx()); vector.setValueCount(idx()+1); } }
public void write(BigIntHolder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void writeBigInt(long value) { vector.setSafe(idx(), 1, value); vector.setValueCount(idx()+1); }
public void write(NullableBigIntHolder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
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; }
static Long[] populate8ByteValues(BigIntVector vector, int size){ vector.allocateNew(); Long values[] = new Long[size]; for(int i = 0; i < values.length; i++){ if (RAND.nextBoolean()) { values[i] = RAND.nextLong(); vector.setSafe(i, values[i]); } } vector.setValueCount(values.length); return values; }
/** * * @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; }
private void populateBigInt(BigIntVector vector, Long[] data) { vector.allocateNew(); Random r = new Random(); for(int i =0; i < data.length; i++){ Long val = data[i]; if(val != null){ vector.setSafe(i, val); } else { vector.setSafe(i, 0, r.nextLong()); } } vector.setValueCount(data.length); }
/** * * @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; }
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; }
final BigIntVector dictionary = dictionaries.get(fieldName).getValueAccessorById(BigIntVector.class, 0).getValueVector(); decodeBigInt(input, output, dictionary); output.setValueCount(recordsConsumedCurrentBatch);
in.setValueCount(count); copy(copiers, sv2); out.setValueCount(count); for(int i =0; i < count; i++){ assertEquals(in.getObject(i), out.getObject(i));
longVector.setSafe(3, 40L); longVector.setSafe(4, 50L); longVector.setValueCount(5); dict1.setRecordCount(5); dict1.buildSchema(BatchSchema.SelectionVectorMode.NONE);
@Test public void bigintRoundtrip() throws Exception { final int count = 1024; try ( BigIntVector in = new BigIntVector("in", allocator); BigIntVector out = new BigIntVector("out", allocator); ) { in.allocateNew(count); for (int i = 0; i < count; i++) { if (i % 5 == 0) { in.setSafe(i, i); } } in.setValueCount(count); final PivotDef pivot = PivotBuilder.getBlockDefinition(new FieldVectorPair(in, out)); try ( final FixedBlockVector fbv = new FixedBlockVector(allocator, pivot.getBlockWidth()); final VariableBlockVector vbv = new VariableBlockVector(allocator, pivot.getVariableCount()); ) { fbv.ensureAvailableBlocks(count); Pivots.pivot(pivot, count, fbv, vbv); ValueVector[] ins = new ValueVector[]{in}; ValueVector[] outs = new ValueVector[]{out}; unpivotHelper(pivot, fbv, vbv, ins, outs, 0, count); unpivotHelper(pivot, fbv, vbv, ins, outs, 0, 100); unpivotHelper(pivot, fbv, vbv, ins, outs, 100, 924); } } }