public void populate(final int count){ for (int i = 0; i < count; i++) { if(value != null) { ((IntVector) vector).setSafe(i, value); } } vector.setValueCount(count); }
private static void writeIntData(IntVector vector, int valueCount) { final int even = 1000; final int odd = 2000; 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(NullableIntHolder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void write(IntHolder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void writeInt(int value) { vector.setSafe(idx(), 1, value); vector.setValueCount(idx()+1); }
static Integer[] populate4ByteValues(IntVector vector, int size){ vector.allocateNew(); Integer values[] = new Integer[size]; for(int i =0; i < size; i++){ if(RAND.nextBoolean()){ values[i] = RAND.nextInt(); vector.setSafe(i, values[i]); } } vector.setValueCount(size); return values; }
static Integer[] populate4ByteValuesWithoutNull(IntVector vector, int size){ vector.allocateNew(); Integer values[] = new Integer[size]; for(int i =0; i < size; i++){ values[i] = RAND.nextInt(); vector.setSafe(i, values[i]); } vector.setValueCount(size); return values; }
private void populateInt(IntVector vector, Integer[] data) { vector.allocateNew(); Random r = new Random(); for(int i =0; i < data.length; i++){ Integer val = data[i]; if(val != null){ vector.setSafe(i, val); } else { vector.setSafe(i, 0, r.nextInt()); } } vector.setValueCount(data.length); }
/** * * @param allocator * @param name * @return */ public static IntVector intVectorOf(BufferAllocator allocator,String name,int length) { IntVector float8Vector = new IntVector(name,FieldType.nullable(new ArrowType.Int(32,true)),allocator); float8Vector.allocateNew(length); float8Vector.setValueCount(length); return float8Vector; }
private void populateInt(IntVector vector, Integer[] data) { vector.allocateNew(); Random r = new Random(); for(int i =0; i < data.length; i++){ Integer val = data[i]; if(val != null){ vector.setSafe(i, val); } else { vector.setSafe(i, 0, r.nextInt()); } } vector.setValueCount(data.length); }
private void populateInt(IntVector vector, Integer[] data) { vector.allocateNew(); Random r = new Random(); for(int i =0; i < data.length; i++){ Integer val = data[i]; if(val != null){ vector.setSafe(i, val); } else { vector.setSafe(i, 0, r.nextInt()); } } vector.setValueCount(data.length); }
static void populate(IntVector vector, Integer[] values){ vector.allocateNew(); Random r = new Random(); for(int i =0; i < values.length; i++){ Integer val = values[i]; if(val != null){ vector.setSafe(i, val); } else { // add noise so we make sure not to read/see noise. vector.setSafe(i, 0, r.nextInt()); } } vector.setValueCount(values.length); }
/** * * @param allocator * @param name * @param data * @return */ public static IntVector vectorFor(BufferAllocator allocator,String name,int[] data) { IntVector float8Vector = new IntVector(name,FieldType.nullable(new ArrowType.Int(32,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 buildIntegerGlobalDictionary(List<Dictionary> dictionaries, VectorContainer existingDict, ColumnDescriptor columnDescriptor, BufferAllocator bufferAllocator) { final Field field = new Field(SchemaPath.getCompoundPath(columnDescriptor.getPath()).getAsUnescapedPath(), true, new ArrowType.Int(32, true), null); final VectorContainer input = new VectorContainer(bufferAllocator); final IntVector intVector = input.addOrGet(field); intVector.allocateNew(); final SortedSet<Integer> values = Sets.newTreeSet(); for (Dictionary dictionary : dictionaries) { for (int i = 0; i <= dictionary.getMaxId(); ++i) { values.add(dictionary.decodeToInt(i)); } } if (existingDict != null) { final IntVector existingDictValues = existingDict.getValueAccessorById(IntVector.class, 0).getValueVector(); for (int i = 0; i < existingDict.getRecordCount(); ++i) { values.add(existingDictValues.get(i)); } } final Iterator<Integer> iter = values.iterator(); int recordCount = 0; while (iter.hasNext()) { intVector.setSafe(recordCount++, iter.next()); } intVector.setValueCount(recordCount); input.setRecordCount(recordCount); input.buildSchema(BatchSchema.SelectionVectorMode.NONE); return input; }
intVector.setSafe(3, 3); binVector.setSafe(3, "THREE".getBytes(), 0, "TWO".getBytes().length); intVector.setValueCount(4); binVector.setValueCount(4);
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; }
in.setValueCount(count); copy(copiers, sv2); out.setValueCount(count); for(int i =0; i < count; i++){ assertEquals(in.getObject(i), out.getObject(i));
inv.setValueCount(count); pairs.add(new FieldVectorPair(inv, outv));
@Test public void intRoundtrip() throws Exception { final int count = 1024; try ( IntVector in = new IntVector("in", allocator); IntVector out = new IntVector("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.pivot4Bytes(pivot.getFixedPivots().get(0), fbv, count); 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); } } }