use of org.apache.ignite.internal.schema.marshaller.TupleMarshaller in project ignite-3 by apache.
the class NumericTypesSerializerTest method testUpscaleForDecimal.
/**
* Test.
*/
@ParameterizedTest
@MethodSource("stringDecimalRepresentation")
public void testUpscaleForDecimal(String decimalStr) throws TupleMarshallerException {
schema = new SchemaDescriptor(42, new Column[] { new Column("key", NativeTypes.INT64, false) }, new Column[] { new Column("decimalCol1", NativeTypes.decimalOf(9, 0), false) });
final Tuple tup = createTuple().set("key", rnd.nextLong()).set("decimalCol1", new BigDecimal(decimalStr));
TupleMarshaller marshaller = new TupleMarshallerImpl(new DummySchemaManagerImpl(schema));
final Row row = marshaller.marshal(tup);
assertEquals(row.decimalValue(1), new BigDecimal(decimalStr).setScale(0, RoundingMode.HALF_UP));
}
use of org.apache.ignite.internal.schema.marshaller.TupleMarshaller in project ignite-3 by apache.
the class NumericTypesSerializerTest method testNumber.
/**
* Test.
*/
@ParameterizedTest
@MethodSource("numbers")
public void testNumber(Pair<BigInteger, BigInteger> pair) throws TupleMarshallerException {
schema = new SchemaDescriptor(42, new Column[] { new Column("key", NativeTypes.INT64, false) }, new Column[] { new Column("number1", NativeTypes.numberOf(19), false), new Column("number2", NativeTypes.numberOf(10), false) });
TupleMarshaller marshaller = new TupleMarshallerImpl(new DummySchemaManagerImpl(schema));
final Tuple tup = createTuple().set("key", rnd.nextLong()).set("number1", pair.getFirst()).set("number2", pair.getSecond());
final Row row = marshaller.marshal(tup);
assertEquals(row.numberValue(1), row.numberValue(2));
}
Aggregations