@Override public void copy(int inputIdx, int count, int outputIdx) { final double[] input = inputVector.vector; if (inputVector.isRepeating) { if (inputVector.isNull[0]) { return; // If all repeating values are null, then there is no need to write anything to vector } final float value = (float)input[0]; for (int i = 0; i < count; i++, outputIdx++) { outputVector.set(outputIdx, value); } // We can't rely noNulls flag due to the bug/hive shenanigans here (they set the noNulls flag wrong): // https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/io/orc/RecordReaderImpl.java#L656 // } else if (inputVector.noNulls) { // for (int i = 0; i < count; i++, inputIdx++, outputIdx++) { // outputVector.set(outputIdx, input[inputIdx]); // } } else { final boolean isNull[] = inputVector.isNull; for (int i = 0; i < count; i++, inputIdx++, outputIdx++) { if (!isNull[inputIdx]) { outputVector.set(outputIdx, (float) input[inputIdx]); } } } } }
private static Pair<Float4Vector, ResultVerifier> testFloat4Vector(final int startIndexInCurrentOutput, final int startIndexInJob) { Float4Vector colFloat4V = new Float4Vector("colFloat4", allocator); colFloat4V.allocateNew(5); colFloat4V.set(0, 20.0f); colFloat4V.set(1, 50.023f); colFloat4V.set(2, -238423f); colFloat4V.setNull(3); colFloat4V.set(4, 0f); ResultVerifier verifier = new ResultVerifier() { @Override public void verify(DataPOJO output) { int index = startIndexInCurrentOutput; assertEquals(20.0d, ((Double)output.extractValue("colFloat4", index++)).doubleValue(), 0.01f); assertEquals(50.023d, ((Double)output.extractValue("colFloat4", index++)).doubleValue(), 0.01f); assertEquals(-238423d, ((Double)output.extractValue("colFloat4", index++)).doubleValue(), 0.01f); assertNull(output.extractValue("colFloat4", index++)); assertEquals(0d, ((Double)output.extractValue("colFloat4", index++)).doubleValue(), 0.01f); } }; return Pair.of(colFloat4V, verifier); }
/** * Same as {@link #set(int, float)} except that it handles the * case when index is greater than or equal to existing * value capacity {@link #getValueCapacity()}. * * @param index position of element * @param value value of element */ public void setSafe(int index, float value) { handleSafe(index); set(index, value); }
/** * Same as {@link #set(int, NullableFloat4Holder)} except that it handles the * case when index is greater than or equal to existing * value capacity {@link #getValueCapacity()}. * * @param index position of element * @param holder nullable data holder for value of element */ public void setSafe(int index, NullableFloat4Holder holder) throws IllegalArgumentException { handleSafe(index); set(index, holder); }
/** * Same as {@link #set(int, Float4Holder)} except that it handles the * case when index is greater than or equal to existing * value capacity {@link #getValueCapacity()}. * * @param index position of element * @param holder data holder for value of element */ public void setSafe(int index, Float4Holder holder) { handleSafe(index); set(index, holder); }
/** * Same as {@link #set(int, int, float)} except that it handles the case * when index is greater than or equal to current value capacity of the * vector. * * @param index position of the new value * @param isSet 0 for NULL value, 1 otherwise * @param value element value */ public void setSafe(int index, int isSet, float value) { handleSafe(index); set(index, isSet, value); }
/** * Store the given value at a particular position in the vector. isSet indicates * whether the value is NULL or not. * * @param index position of the new value * @param isSet 0 for NULL value, 1 otherwise * @param value element value */ public void set(int index, int isSet, float value) { if (isSet > 0) { set(index, value); } else { BitVectorHelper.setValidityBit(validityBuffer, index, 0); } }
Float4Vector float4Vector = (Float4Vector) fieldVector; float set2 = TypeConversion.getInstance().convertFloat(value); float4Vector.set(row, set2); break; case Double: