/** * Same as {@link #set(int, ArrowBuf)} 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 buffer ArrowBuf containing decimal value. */ public void setSafe(int index, ArrowBuf buffer) { handleSafe(index); set(index, buffer); }
private static Pair<DecimalVector, ResultVerifier> testDecimalVector(final int startIndexInCurrentOutput, final int startIndexInJob) { DecimalVector colDecimalV = new DecimalVector("colDecimal", allocator, 10, 10); colDecimalV.allocateNew(5); DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(25.03).setScale(5, RoundingMode.HALF_UP), tempBuf, 0); colDecimalV.set(0, tempBuf); DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(2524324.034534), tempBuf, 0); colDecimalV.set(1, tempBuf); colDecimalV.setNull(2); DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(2523423423424234243234.235), tempBuf, 0); colDecimalV.set(3, tempBuf); DecimalUtility.writeBigDecimalToArrowBuf(new BigDecimal(2523423423424234243234.23524324234234), tempBuf, 0); colDecimalV.set(4, tempBuf); ResultVerifier verifier = new ResultVerifier() { @Override public void verify(DataPOJO output) { int index = startIndexInCurrentOutput; assertEquals(2.503E-4, ((Double)output.extractValue("colDecimal", index++)).doubleValue(), 0.001f); assertEquals(2.524324034534E23, ((Double)output.extractValue("colDecimal", index++)).doubleValue(), 0.001f); assertNull(output.extractValue("colDecimal", index++)); assertEquals(2.523423423424234E11, ((Double)output.extractValue("colDecimal", index++)).doubleValue(), 0.001f); assertEquals(2.523423423424234E11, ((Double)output.extractValue("colDecimal", index++)).doubleValue(), 0.001f); } }; return Pair.of(colDecimalV, verifier); }
BigDecimal val = new BigDecimal(i + j + ((double) (i + j) / count)).setScale(0, RoundingMode.HALF_UP); DecimalUtility.writeBigDecimalToArrowBuf(val, tempBuf, 0); in.set(i + j, tempBuf); BigDecimal val = new BigDecimal(i + j + ((double) (i + j) / count)).setScale(0, RoundingMode.HALF_UP); DecimalUtility.writeBigDecimalToArrowBuf(val, tempBuf, 0); in.set(i + j, tempBuf);
BigDecimal decimal8 = new BigDecimal("1212121212.343434343"); decimalVector.set(0, decimal1); decimalVector.set(1, decimal2); decimalVector.set(2, decimal3); decimalVector.set(3, decimal4); decimalVector.set(4, decimal5); decimalVector.set(5, decimal6); decimalVector.set(6, decimal7); decimalVector.set(7, decimal8);
/** * Same as {@link #set(int, DecimalHolder)} 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, DecimalHolder holder) { handleSafe(index); set(index, holder); }
/** * Same as {@link #set(int, BigDecimal)} 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 BigDecimal containing decimal value. */ public void setSafe(int index, BigDecimal value) { handleSafe(index); set(index, value); }
/** * Same as {@link #set(int, NullableDecimalHolder)} 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, NullableDecimalHolder holder) throws IllegalArgumentException { handleSafe(index); set(index, holder); }
/** * Same as {@link #set(int, int, ArrowBuf)} 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 start start index of data in the buffer * @param buffer ArrowBuf containing decimal value. */ public void setSafe(int index, int start, ArrowBuf buffer) { handleSafe(index); set(index, start, buffer); }
/** * Same as {@link #setSafe(int, int, int, ArrowBuf)} except that it handles * the case when the position of new value is beyond the current value * capacity of the vector. * * @param index position of the new value * @param isSet 0 for NULL value, 1 otherwise * @param start start position of the value in the buffer * @param buffer buffer containing the value to be stored in the vector */ public void setSafe(int index, int isSet, int start, ArrowBuf buffer) { handleSafe(index); set(index, isSet, start, buffer); }
/** * 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 start start position of the value in the buffer * @param buffer buffer containing the value to be stored in the vector */ public void set(int index, int isSet, int start, ArrowBuf buffer) { if (isSet > 0) { set(index, start, buffer); } else { BitVectorHelper.setValidityBit(validityBuffer, index, 0); } }