ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [5/7] ignite git commit: IGNITE-1418: Better field offset calculation.
Date Mon, 02 Nov 2015 13:00:42 GMT
IGNITE-1418: Better field offset calculation.


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

Branch: refs/heads/ignite-1814-debug
Commit: 049353b63f7ac50b2d44e5474f219b234a2399a2
Parents: 75f01df
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Mon Nov 2 15:44:37 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Mon Nov 2 15:44:37 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/PortableReaderExImpl.java |  8 +++++---
 .../ignite/internal/portable/PortableUtils.java | 21 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/049353b6/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
index b2e9320..91e1ae5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
@@ -2606,14 +2606,14 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
                 int id0 = in.readIntPositioned(searchPos);
 
                 if (id0 == id) {
-                    int pos = start + in.readIntPositioned(searchPos + 4);
+                    int pos = start + PortableUtils.fieldOffsetRelative(in, searchPos + 4,
offsetSize);
 
                     in.position(pos);
 
                     return pos;
                 }
 
-                searchPos += 8;
+                searchPos += 4 + offsetSize;
             }
         }
         else {
@@ -2634,7 +2634,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
             int order = schema.order(id);
 
             if (order != 0) {
-                int pos = start + in.readIntPositioned(footerStart + order * 8 + 4);
+                int offsetPos = footerStart + order * (4 + offsetSize) + 4;
+
+                int pos = start + PortableUtils.fieldOffsetRelative(in, offsetPos, offsetSize);
 
                 in.position(pos);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/049353b6/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
index 4e9248c..4e3538c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
@@ -676,4 +676,25 @@ public class PortableUtils {
         else
             return OFFSET_4;
     }
+
+    /**
+     * Get relative field offset.
+     *
+     * @param stream Stream.
+     * @param pos Position.
+     * @param fieldOffsetSize Field offset size.
+     * @return Relative field offset.
+     */
+    public static int fieldOffsetRelative(PortablePositionReadable stream, int pos, int fieldOffsetSize)
{
+        int res;
+
+        if (fieldOffsetSize == PortableUtils.OFFSET_1)
+            res = (int)stream.readBytePositioned(pos) & 0xFF;
+        else if (fieldOffsetSize == PortableUtils.OFFSET_2)
+            res = (int)stream.readShortPositioned(pos) & 0xFFFF;
+        else
+            res = stream.readIntPositioned(pos);
+
+        return res;
+    }
 }
\ No newline at end of file


Mime
View raw message