/** * Get the element at the given index from the vector and * sets the state in holder. If element at given index * is null, holder.isSet will be zero. * * @param index position of element */ public void get(int index, NullableDecimalHolder holder) { if (isSet(index) == 0) { holder.isSet = 0; return; } holder.isSet = 1; holder.buffer = valueBuffer; holder.precision = precision; holder.scale = scale; holder.start = index * TYPE_WIDTH; }
/** * Get the element at the given index from the vector. * * @param index position of element * @return element at given index */ public ArrowBuf get(int index) throws IllegalStateException { if (isSet(index) == 0) { throw new IllegalStateException("Value at index is null"); } return valueBuffer.slice(index * TYPE_WIDTH, TYPE_WIDTH); }
/** * Same as {@link #get(int)}. * * @param index position of element * @return element at given index */ public BigDecimal getObject(int index) { if (isSet(index) == 0) { return null; } else { return DecimalUtility.getBigDecimalFromArrowBuf(valueBuffer, index, scale); } }
/** * Copy a cell value from a particular index in source vector to a particular * position in this vector. * * @param fromIndex position to copy from in source vector * @param thisIndex position to copy to in this vector * @param from source vector */ public void copyFrom(int fromIndex, int thisIndex, DecimalVector from) { BitVectorHelper.setValidityBit(validityBuffer, thisIndex, from.isSet(fromIndex)); from.valueBuffer.getBytes(fromIndex * TYPE_WIDTH, valueBuffer, thisIndex * TYPE_WIDTH, TYPE_WIDTH); }
case DECIMAL : holder = new NullableDecimalHolder(); ((NullableDecimalHolder)holder).isSet = ((DecimalVector) vector).isSet(index); if (((NullableDecimalHolder)holder).isSet == 1) { ((DecimalVector) vector).get(index, (NullableDecimalHolder)holder);