@Override public void allocate() { vector.allocateNew(); }
public void allocate(){ vector.allocateNew(); }
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; }
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; }
/** * * @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; }
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)); }
bigIntVector.allocateNew(2); bigIntVector.set(0, 52459253098448904L); bigIntVector.set(1, 1116675951L);
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); }
){ in.allocateNew(count);
final Field field1 = new Field(SchemaPath.getSimplePath("c0").getAsUnescapedPath(), true, new ArrowType.Int(64, true), null); final BigIntVector longVector = dict1.addOrGet(field1); longVector.allocateNew(); longVector.setSafe(0, 10L); longVector.setSafe(1, 20L);
@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); } } }