use of org.apache.ignite.internal.schema.NumberNativeType in project ignite-3 by apache.
the class RowAssembler method appendNumber.
/**
* Appends BigInteger value for the current column to the chunk.
*
* @param val Column value.
* @return {@code this} for chaining.
* @throws SchemaMismatchException If a value doesn't match the current column type.
*/
public RowAssembler appendNumber(BigInteger val) throws SchemaMismatchException {
checkType(NativeTypeSpec.NUMBER);
Column col = curCols.column(curCol);
NumberNativeType type = (NumberNativeType) col.type();
// 0 is a magic number for "unlimited precision"
if (type.precision() > 0 && new BigDecimal(val).precision() > type.precision()) {
throw new SchemaMismatchException("Failed to set number value for column '" + col.name() + "' " + "(max precision exceeds allocated precision) " + "[number=" + val + ", max precision=" + type.precision() + "]");
}
byte[] bytes = val.toByteArray();
buf.putBytes(curOff, bytes);
writeVarlenOffset(curVartblEntry, curOff - dataOff);
curVartblEntry++;
shiftColumn(bytes.length);
return this;
}
Aggregations