ptupitsyn commented on a change in pull request #296:
URL: https://github.com/apache/ignite-3/pull/296#discussion_r697274100



##########
File path: 
modules/client-common/src/main/java/org/apache/ignite/client/proto/ClientMessagePacker.java
##########
@@ -330,63 +330,132 @@ public ClientMessagePacker packUuid(UUID val) {
      *
      * @param val Decimal value.
      * @return This instance.
-     * @throws UnsupportedOperationException Not supported.
      */
     public ClientMessagePacker packDecimal(BigDecimal val) {
         assert !closed : "Packer is closed";
 
-        throw new UnsupportedOperationException("TODO: IGNITE-15163");
+        // TODO: Pack directly to ByteBuf without allocating IGNITE-15234.
+        byte[] unscaledValue = val.unscaledValue().toByteArray();

Review comment:
       Would it be possible to decode those bytes on other platforms, like .NET 
or Python? 

##########
File path: 
modules/client-common/src/main/java/org/apache/ignite/client/proto/ClientMessagePacker.java
##########
@@ -330,63 +330,132 @@ public ClientMessagePacker packUuid(UUID val) {
      *
      * @param val Decimal value.
      * @return This instance.
-     * @throws UnsupportedOperationException Not supported.
      */
     public ClientMessagePacker packDecimal(BigDecimal val) {
         assert !closed : "Packer is closed";
 
-        throw new UnsupportedOperationException("TODO: IGNITE-15163");
+        // TODO: Pack directly to ByteBuf without allocating IGNITE-15234.
+        byte[] unscaledValue = val.unscaledValue().toByteArray();
+
+        packExtensionTypeHeader(ClientMsgPackType.DECIMAL, 4 + 
unscaledValue.length); // Scale length + data length
+
+        addPayload(ByteBuffer.wrap(new byte[4]).putInt(val.scale()).array());
+        addPayload(unscaledValue);
+
+        return this;
+    }
+
+    /**
+     * Writes a decimal.
+     *
+     * @param val Decimal value.
+     * @return This instance.
+     */
+    public ClientMessagePacker packNumber(BigInteger val) {
+        assert !closed : "Packer is closed";
+
+        // TODO: Pack directly to ByteBuf without allocating IGNITE-15234.

Review comment:
       Looks like there is no way around `BigInteger#toByteArray()` call even 
if we have `ByteBuf` at hand (here and other TODOs like this).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to