public void populate(final int count){ for (int i = 0; i < count; i++) { if(value != null) { ((Float8Vector) vector).setSafe(i, value); } } vector.setValueCount(count); }
private static void writeDoubleData(Float8Vector vector, int valueCount) { final double even = 20.2373; final double odd = 40.2378; for (int i = 0; i < valueCount; i++) { if (i % 2 == 0) { vector.setSafe(i, even); } else { vector.setSafe(i, odd); } } vector.setValueCount(valueCount); }
/** * * @param allocator * @param name * @param length the length of the vector * @return */ public static Float8Vector doubleVectorOf(BufferAllocator allocator,String name,int length) { Float8Vector float8Vector = new Float8Vector(name,allocator); float8Vector.allocateNew(); float8Vector.setValueCount(length); return float8Vector; }
public void write(Float8Holder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void writeNull() { vector.setNull(idx()); vector.setValueCount(idx()+1); } }
public void write(NullableFloat8Holder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void writeFloat8(double value) { vector.setSafe(idx(), 1, value); vector.setValueCount(idx()+1); }
/** * * @param allocator * @param name * @param data * @return */ public static Float8Vector vectorFor(BufferAllocator allocator,String name,double[] data) { Float8Vector float8Vector = new Float8Vector(name,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 void populateDouble(Float8Vector vector, Double[] data) { vector.allocateNew(); Random r = new Random(); for(int i =0; i < data.length; i++){ Double val = data[i]; if(val != null){ vector.setSafe(i, val); } else { vector.setSafe(i, 0, r.nextDouble()); } } vector.setValueCount(data.length); }
private static VectorContainer buildDoubleGlobalDictionary(List<Dictionary> dictionaries, VectorContainer existingDict, ColumnDescriptor columnDescriptor, BufferAllocator bufferAllocator) { final Field field = new Field(SchemaPath.getCompoundPath(columnDescriptor.getPath()).getAsUnescapedPath(), true, new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE), null); final VectorContainer input = new VectorContainer(bufferAllocator); final Float8Vector doubleVector = input.addOrGet(field); doubleVector.allocateNew(); SortedSet<Double> values = Sets.newTreeSet(); for (Dictionary dictionary : dictionaries) { for (int i = 0; i <= dictionary.getMaxId(); ++i) { values.add(dictionary.decodeToDouble(i)); } } if (existingDict != null) { final Float8Vector existingDictValues = existingDict.getValueAccessorById(Float8Vector.class, 0).getValueVector(); for (int i = 0; i < existingDict.getRecordCount(); ++i) { values.add(existingDictValues.get(i)); } } final Iterator<Double> iter = values.iterator(); int recordCount = 0; while (iter.hasNext()) { doubleVector.setSafe(recordCount++, iter.next()); } doubleVector.setValueCount(recordCount); input.setRecordCount(recordCount); input.buildSchema(BatchSchema.SelectionVectorMode.NONE); return input; }
final Float8Vector dictionary = dictionaries.get(fieldName).getValueAccessorById(Float8Vector.class, 0).getValueVector(); decodeDouble(input, output, dictionary); output.setValueCount(recordsConsumedCurrentBatch);
doubleVector.setSafe(3, 400.4); doubleVector.setSafe(4, 500.5); doubleVector.setValueCount(5); dict3.setRecordCount(5); dict3.buildSchema(BatchSchema.SelectionVectorMode.NONE);
float8Vector.setValueCount(records); mapVector.setValueCount(records);