/** * Set a BigDecimal for the lower bound * @param lowerBound value for the lower bound */ public void setLowerBound(BigDecimal lowerBound) { checkColumn(Type.DECIMAL); int precision = column.getTypeAttributes().getPrecision(); int scale = column.getTypeAttributes().getScale(); BigDecimal coercedVal = DecimalUtil.coerce(lowerBound, precision, scale); setLowerBoundInternal(Bytes.fromBigDecimal(coercedVal, precision)); }
/** * Set a BigDecimal for the upper bound * @param upperBound value for the upper bound */ public void setUpperBound(BigDecimal upperBound) { checkColumn(Type.DECIMAL); int precision = column.getTypeAttributes().getPrecision(); int scale = column.getTypeAttributes().getScale(); BigDecimal coercedVal = DecimalUtil.coerce(upperBound, precision, scale); setUpperBoundInternal(Bytes.fromBigDecimal(coercedVal, precision)); }
value = DecimalUtil.coerce(value, precision, scale);
/** * Add a Decimal for the specified column. * @param columnIndex the column's index in the schema * @param val value to add * @throws IllegalArgumentException if the value doesn't match the column's type * @throws IllegalStateException if the row was already applied * @throws IndexOutOfBoundsException if the column doesn't exist */ public void addDecimal(int columnIndex, BigDecimal val) { checkNotFrozen(); ColumnSchema column = schema.getColumnByIndex(columnIndex); ColumnTypeAttributes typeAttributes = column.getTypeAttributes(); checkColumn(column, Type.DECIMAL); BigDecimal coercedVal = DecimalUtil.coerce(val,typeAttributes.getPrecision(), typeAttributes.getScale()); Bytes.setBigDecimal(rowAlloc, coercedVal, typeAttributes.getPrecision(), getPositionInRowAllocAndSetBitSet(columnIndex)); }