From 1f8d3f0453c1fce6699652fb1f47b8a631f4a21c Mon Sep 17 00:00:00 2001 From: Martin Vahlensieck Date: Thu, 28 Mar 2024 12:01:44 +0100 Subject: [PATCH] Remove BigDecimal precision field --- .../db/protointerface/utils/PolyValueSerializer.java | 1 - .../db/protointerface/utils/ProtoValueDeserializer.java | 3 +-- plugins/proto-interface/src/main/proto/polyprism/value.proto | 4 ++-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/PolyValueSerializer.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/PolyValueSerializer.java index 27e1631490..d299450f95 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/PolyValueSerializer.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/PolyValueSerializer.java @@ -389,7 +389,6 @@ private static ProtoBigDecimal serializeBigDecimal( BigDecimal bigDecimal ) { return ProtoBigDecimal.newBuilder() .setUnscaledValue( ByteString.copyFrom( bigDecimal.unscaledValue().toByteArray() ) ) .setScale( bigDecimal.scale() ) - .setPrecision( bigDecimal.precision() ) .build(); } diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/ProtoValueDeserializer.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/ProtoValueDeserializer.java index d958d2f812..0e13a3373d 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/ProtoValueDeserializer.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/ProtoValueDeserializer.java @@ -170,9 +170,8 @@ private static PolyBigDecimal deserializeToPolyBigDecimal( ProtoValue protoValue private static BigDecimal deserializeToBigDecimal( ProtoValue protoValue ) { ProtoBigDecimal protoBigDecimal = protoValue.getBigDecimal(); - MathContext context = new MathContext( protoBigDecimal.getPrecision() ); byte[] unscaledValue = protoBigDecimal.getUnscaledValue().toByteArray(); - return new BigDecimal( new BigInteger( unscaledValue ), protoBigDecimal.getScale(), context ); + return new BigDecimal( new BigInteger( unscaledValue ), protoBigDecimal.getScale() ); } } diff --git a/plugins/proto-interface/src/main/proto/polyprism/value.proto b/plugins/proto-interface/src/main/proto/polyprism/value.proto index 5d00b098c4..690641120f 100644 --- a/plugins/proto-interface/src/main/proto/polyprism/value.proto +++ b/plugins/proto-interface/src/main/proto/polyprism/value.proto @@ -199,9 +199,9 @@ Represents a BigDecimal value with specified precision and scale. */ message ProtoBigDecimal { // The scale of the BigDecimal. - uint32 scale = 1; + int32 scale = 1; // The precision of the BigDecimal. - uint32 precision = 2; + uint32 precision = 2; // TODO: Currently unused // The unscaled value of the BigDecimal. bytes unscaled_value = 3; }