ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [6/7] ignite git commit: IGNITE-1418: Fixed builder.
Date Mon, 02 Nov 2015 13:00:43 GMT
IGNITE-1418: Fixed builder.


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

Branch: refs/heads/ignite-1814-debug
Commit: 763ebadecadf155638d66b8a274b47c35bc74614
Parents: 049353b
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Mon Nov 2 15:51:20 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Mon Nov 2 15:51:20 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/PortableFieldImpl.java    |  1 +
 .../portable/builder/PortableBuilderImpl.java   | 25 ++++++++++++--------
 2 files changed, 16 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/763ebade/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableFieldImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableFieldImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableFieldImpl.java
index d85d7df..2ba2bf9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableFieldImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableFieldImpl.java
@@ -55,6 +55,7 @@ public class PortableFieldImpl implements PortableField {
 
         int order = fieldOrder(obj0);
 
+        // TODO: Fix me!
         return order != 0 ? (T)obj0.fieldByOffset(order * 8 + 4) : null;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/763ebade/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
index 482b2f6..4edb792 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderImpl.java
@@ -241,11 +241,11 @@ public class PortableBuilderImpl implements PortableBuilder {
             // Position reader on data.
             reader.position(start + hdrLen);
 
-            while (reader.position() < rawPos) {
+            while (reader.position() + 4 < rawPos) {
                 int fieldId = reader.readIntPositioned(footerPos);
-                int fieldLen = fieldPositionAndLength(footerPos, footerEnd, rawPos).get2();
+                int fieldLen = fieldPositionAndLength(footerPos, footerEnd, rawPos, fieldOffsetSize).get2();
 
-                footerPos += 8;
+                footerPos += 4 + fieldOffsetSize;
 
                 if (assignedFldsById.containsKey(fieldId)) {
                     Object assignedVal = assignedFldsById.remove(fieldId);
@@ -399,21 +399,25 @@ public class PortableBuilderImpl implements PortableBuilder {
      * @param footerPos Field position inside the footer (absolute).
      * @param footerEnd Footer end (absolute).
      * @param rawPos Raw data position (absolute).
+     * @param fieldOffsetSize Size of field's offset.
      * @return Tuple with field position and length.
      */
-    private IgniteBiTuple<Integer, Integer> fieldPositionAndLength(int footerPos, int
footerEnd, int rawPos) {
-        int fieldOffset = reader.readIntPositioned(footerPos + 4);
+    private IgniteBiTuple<Integer, Integer> fieldPositionAndLength(int footerPos, int
footerEnd, int rawPos,
+        int fieldOffsetSize) {
+        // Get field offset first.
+        int fieldOffset = PortableUtils.fieldOffsetRelative(reader, footerPos + 4, fieldOffsetSize);
         int fieldPos = start + fieldOffset;
 
         // Get field length.
         int fieldLen;
 
-        if (footerPos + 8 == footerEnd)
+        if (footerPos + 4 + fieldOffsetSize == footerEnd)
             // This is the last field, compare to raw offset.
             fieldLen = rawPos - fieldPos;
         else {
             // Field is somewhere in the middle, get difference with the next offset.
-            int nextFieldOffset = reader.readIntPositioned(footerPos + 8 + 4);
+            int nextFieldOffset = PortableUtils.fieldOffsetRelative(reader, footerPos + 4
+ fieldOffsetSize + 4,
+                fieldOffsetSize);
 
             fieldLen = nextFieldOffset - fieldOffset;
         }
@@ -437,17 +441,18 @@ public class PortableBuilderImpl implements PortableBuilder {
 
             int rawPos = PortableUtils.rawOffsetAbsolute(reader, start, fieldOffsetSize);
 
-            while (footerPos < footerEnd) {
+            while (footerPos + 4 < footerEnd) {
                 int fieldId = reader.readIntPositioned(footerPos);
 
-                IgniteBiTuple<Integer, Integer> posAndLen = fieldPositionAndLength(footerPos,
footerEnd, rawPos);
+                IgniteBiTuple<Integer, Integer> posAndLen =
+                    fieldPositionAndLength(footerPos, footerEnd, rawPos, fieldOffsetSize);
 
                 Object val = reader.getValueQuickly(posAndLen.get1(), posAndLen.get2());
 
                 readCache.put(fieldId, val);
 
                 // Shift current footer position.
-                footerPos += 8;
+                footerPos += 4 + fieldOffsetSize;
             }
 
             this.readCache = readCache;


Mime
View raw message