ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [3/7] ignite git commit: IGNITE-1418: Applied correct footer boundaries resolution.
Date Mon, 02 Nov 2015 13:00:40 GMT
IGNITE-1418: Applied correct footer boundaries resolution.


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

Branch: refs/heads/ignite-1814-debug
Commit: 28283137330d45ec9838a067135a4a23111b78d2
Parents: 5f16203
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Mon Nov 2 15:28:55 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Mon Nov 2 15:28:55 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/PortableReaderExImpl.java   |  2 +-
 .../ignite/internal/portable/PortableUtils.java   |  6 ++++--
 .../portable/builder/PortableBuilderImpl.java     | 18 +++++++++++++-----
 3 files changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/28283137/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 441cc71..65b0eaa 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
@@ -230,7 +230,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
 
         typeId = in.readIntPositioned(start + GridPortableMarshaller.TYPE_ID_POS);
 
-        IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(in, start);
+        IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(in, start,
offsetSize);
 
         footerStart = footer.get1();
         footerLen = footer.get2() - footerStart;

http://git-wip-us.apache.org/repos/asf/ignite/blob/28283137/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 f08b48a..9b005d4 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
@@ -619,14 +619,16 @@ public class PortableUtils {
      *
      * @param in Input stream.
      * @param start Start position.
+     * @param fieldOffsetSize Field offset size.
      * @return Footer.
      */
-    public static IgniteBiTuple<Integer, Integer> footerAbsolute(PortablePositionReadable
in, int start) {
+    public static IgniteBiTuple<Integer, Integer> footerAbsolute(PortablePositionReadable
in, int start,
+        int fieldOffsetSize) {
         int footerStart = footerStartRelative(in, start);
         int footerEnd = length(in, start);
 
         // Take in count possible raw offset.
-        if ((((footerEnd - footerStart) >> 2) & 0x1) == 0x1)
+        if ((footerEnd - footerStart) % (4 + fieldOffsetSize) != 0)
             footerEnd -= 4;
 
         return F.t(start + footerStart, start + footerEnd);

http://git-wip-us.apache.org/repos/asf/ignite/blob/28283137/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 34e1d6d..d417db4 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
@@ -41,6 +41,7 @@ import java.util.Map;
 import java.util.Set;
 
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.DFLT_HDR_LEN;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.FLAGS_POS;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.HASH_CODE_POS;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROTO_VER_POS;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.TYPE_ID_POS;
@@ -77,12 +78,13 @@ public class PortableBuilderImpl implements PortableBuilder {
     /** Position of object in source array, or -1 if object is not created from PortableObject.
*/
     private final int start;
 
+    /** Flags. */
+    private final short flags;
+
     /** Total header length */
     private final int hdrLen;
 
-    /**
-     * Context of PortableObject reading process. Or {@code null} if object is not created
from PortableObject.
-     */
+    /** Context of PortableObject reading process. Or {@code null} if object is not created
from PortableObject. */
     private final PortableBuilderReader reader;
 
     /** */
@@ -115,6 +117,7 @@ public class PortableBuilderImpl implements PortableBuilder {
         this.ctx = ctx;
 
         start = -1;
+        flags = -1;
         reader = null;
         hdrLen = DFLT_HDR_LEN;
 
@@ -137,6 +140,7 @@ public class PortableBuilderImpl implements PortableBuilder {
     PortableBuilderImpl(PortableBuilderReader reader, int start) {
         this.reader = reader;
         this.start = start;
+        this.flags = reader.readShortPositioned(start + FLAGS_POS);
 
         byte ver = reader.readBytePositioned(start + PROTO_VER_POS);
 
@@ -224,7 +228,9 @@ public class PortableBuilderImpl implements PortableBuilder {
                 assignedFldsById = Collections.emptyMap();
 
             // Get footer details.
-            IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(reader,
start);
+            int fieldOffsetSize = PortableUtils.fieldOffsetSize(flags);
+
+            IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(reader,
start, fieldOffsetSize);
 
             int footerPos = footer.get1();
             int footerEnd = footer.get2();
@@ -418,9 +424,11 @@ public class PortableBuilderImpl implements PortableBuilder {
      */
     private void ensureReadCacheInit() {
         if (readCache == null) {
+            int fieldOffsetSize = PortableUtils.fieldOffsetSize(flags);
+
             Map<Integer, Object> readCache = new HashMap<>();
 
-            IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(reader,
start);
+            IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(reader,
start, fieldOffsetSize);
 
             int footerPos = footer.get1();
             int footerEnd = footer.get2();


Mime
View raw message