ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [18/42] incubator-ignite git commit: ignite-757 - decimal fix
Date Wed, 29 Apr 2015 14:28:19 GMT
ignite-757 - decimal fix


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ab052aca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ab052aca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ab052aca

Branch: refs/heads/ignite-286
Commit: ab052aca5deeb768982be3ebed28b740748c406e
Parents: f674ec7
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Mon Apr 27 12:25:04 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Mon Apr 27 12:25:04 2015 +0300

----------------------------------------------------------------------
 .../query/h2/twostep/msg/GridH2Decimal.java     | 27 +++++++++++++++++---
 1 file changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ab052aca/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Decimal.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Decimal.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Decimal.java
index c51df77..c52e7a9 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Decimal.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2Decimal.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.processors.query.h2.twostep.msg;
 
 import org.apache.ignite.plugin.extensions.communication.*;
-import org.h2.util.*;
 import org.h2.value.*;
 
 import java.math.*;
@@ -29,6 +28,9 @@ import java.nio.*;
  */
 public class GridH2Decimal extends GridH2ValueMessage {
     /** */
+    private int scale;
+
+    /** */
     private byte[] b;
 
     /**
@@ -44,12 +46,15 @@ public class GridH2Decimal extends GridH2ValueMessage {
     public GridH2Decimal(Value val) {
         assert val.getType() == Value.DECIMAL : val.getType();
 
-        b = Utils.serialize(val.getBigDecimal(), null);
+        BigDecimal x = val.getBigDecimal();
+
+        scale = x.scale();
+        b = x.unscaledValue().toByteArray();
     }
 
     /** {@inheritDoc} */
     @Override public Value value() {
-        return ValueDecimal.get((BigDecimal)Utils.deserialize(b, null));
+        return ValueDecimal.get(new BigDecimal(new BigInteger(b), scale));
     }
 
     /** {@inheritDoc} */
@@ -73,6 +78,12 @@ public class GridH2Decimal extends GridH2ValueMessage {
 
                 writer.incrementState();
 
+            case 1:
+                if (!writer.writeInt("scale", scale))
+                    return false;
+
+                writer.incrementState();
+
         }
 
         return true;
@@ -97,6 +108,14 @@ public class GridH2Decimal extends GridH2ValueMessage {
 
                 reader.incrementState();
 
+            case 1:
+                scale = reader.readInt("scale");
+
+                if (!reader.isLastRead())
+                    return false;
+
+                reader.incrementState();
+
         }
 
         return true;
@@ -109,6 +128,6 @@ public class GridH2Decimal extends GridH2ValueMessage {
 
     /** {@inheritDoc} */
     @Override public byte fieldsCount() {
-        return 1;
+        return 2;
     }
 }


Mime
View raw message