public void populate(final int count){ for (int i = 0; i < count; i++) { if(value != null) { ((Float4Vector) vector).setSafe(i, value); } } vector.setValueCount(count); }
@Override public void set(ValueVector v, int index) { if(obj != null){ ((Float4Vector) v).setSafe(index, obj); } }
@Override protected void readField(long recordsToReadInThisPass) { recordsReadInThisIteration = Math.min(pageReader.currentPageCount - pageReader.valuesRead, recordsToReadInThisPass - valuesReadInCurrentPass); for (int i = 0; i < recordsReadInThisIteration; i++){ valueVec.setSafe(valuesReadInCurrentPass + i, pageReader.dictionaryValueReader.readFloat()); } } }
@Override public void setSafeValue(ObjectInspector oi, Object hiveFieldValue, ValueVector outputVV, int outputIndex) { final float value = (float) ((FloatObjectInspector)oi).getPrimitiveJavaObject(hiveFieldValue); ((Float4Vector) outputVV).setSafe(outputIndex, value); } }
@Override protected void readField(long recordsToReadInThisPass) { if (usingDictionary) { for (int i = 0; i < recordsToReadInThisPass; i++){ valueVec.setSafe(valuesReadInCurrentPass + i, pageReader.dictionaryValueReader.readFloat()); } } else { for (int i = 0; i < recordsToReadInThisPass; i++){ valueVec.setSafe(valuesReadInCurrentPass + i, pageReader.valueReader.readFloat()); } } } }
public void write(Float4Holder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void write(NullableFloat4Holder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void writeFloat4(float value) { vector.setSafe(idx(), 1, value); vector.setValueCount(idx()+1); }
/** * * @param allocator * @param name * @param data * @return */ public static Float4Vector vectorFor(BufferAllocator allocator,String name,float[] data) { Float4Vector float4Vector = new Float4Vector(name,allocator); float4Vector.allocateNew(data.length); for(int i = 0; i < data.length; i++) { float4Vector.setSafe(i,data[i]); } float4Vector.setValueCount(data.length); return float4Vector; }
private static VectorContainer buildFloatGlobalDictionary(List<Dictionary> dictionaries, VectorContainer existingDict, ColumnDescriptor columnDescriptor, BufferAllocator bufferAllocator) { final Field field = new Field(SchemaPath.getCompoundPath(columnDescriptor.getPath()).getAsUnescapedPath(), true, new ArrowType.FloatingPoint(FloatingPointPrecision.SINGLE), null); final VectorContainer input = new VectorContainer(bufferAllocator); final Float4Vector floatVector = input.addOrGet(field); floatVector.allocateNew(); SortedSet<Float> values = Sets.newTreeSet(); for (Dictionary dictionary : dictionaries) { for (int i = 0; i <= dictionary.getMaxId(); ++i) { values.add(dictionary.decodeToFloat(i)); } } if (existingDict != null) { final Float4Vector existingDictValues = existingDict.getValueAccessorById(Float4Vector.class, 0).getValueVector(); for (int i = 0; i < existingDict.getRecordCount(); ++i) { values.add(existingDictValues.get(i)); } } final Iterator<Float> iter = values.iterator(); int recordCount = 0; while (iter.hasNext()) { floatVector.setSafe(recordCount++, iter.next()); } floatVector.setValueCount(recordCount); input.setRecordCount(recordCount); input.buildSchema(BatchSchema.SelectionVectorMode.NONE); return input; }
@Override public int next(int records) { if (position == fixKeyValues1.length) { return 0; } records = Math.min(records, fixKeyValues1.length - position); container.allocateNew(); for (int i = 0; i < records; i++) { final int absoluteRecordIndex = position + i; fixkey1.setSafe(i, fixKeyValues1[absoluteRecordIndex]); fixkey2.setSafe(i, fixKeyValues2[absoluteRecordIndex]); byte[] valueBytes = varKeyValues1[absoluteRecordIndex].getBytes(); varkey1.setSafe(i, valueBytes, 0, valueBytes.length); m1.setSafe(i, measure1[absoluteRecordIndex]); m2.setSafe(i, measure2[absoluteRecordIndex]); m3.setSafe(i, measure3[absoluteRecordIndex]); m4.setSafe(i, measure4[absoluteRecordIndex]); } container.setAllCount(records); position += records; return records; }
Float value = pv.getFloatValue(); if(value != null){ float4Vector.setSafe(index, value);
switch (type.getMode()) { case REQUIRED: ((Float4Vector) vector).setSafe(index, (Float4Holder) holder); return; case OPTIONAL: if (holder instanceof NullableFloat4Holder) { if (((NullableFloat4Holder) holder).isSet == 1) { ((Float4Vector) vector).setSafe(index, (NullableFloat4Holder) holder); } else { ((Float4Vector) vector).isSafe(index); ((Float4Vector) vector).setSafe(index, (Float4Holder) holder);