ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [4/7] ignite git commit: IGNITE-1418: Correct raw offset resolution.
Date Mon, 02 Nov 2015 13:00:41 GMT
IGNITE-1418: Correct raw offset resolution.


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

Branch: refs/heads/ignite-1814-debug
Commit: 75f01dfdfb0a1ec1d0d00664651a16a802b9e293
Parents: 2828313
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Mon Nov 2 15:40:13 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Mon Nov 2 15:40:13 2015 +0300

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


http://git-wip-us.apache.org/repos/asf/ignite/blob/75f01dfd/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 65b0eaa..b2e9320 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
@@ -237,7 +237,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
 
         schemaId = in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_ID_POS);
 
-        rawOff = PortableUtils.rawOffsetAbsolute(in, start);
+        rawOff = PortableUtils.rawOffsetAbsolute(in, start, offsetSize);
 
         if (typeId == UNREGISTERED_TYPE_ID) {
             // Skip to the class name position.

http://git-wip-us.apache.org/repos/asf/ignite/blob/75f01dfd/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 9b005d4..4e9248c 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
@@ -639,9 +639,10 @@ public class PortableUtils {
      *
      * @param in Input stream.
      * @param start Object start position inside the stream.
+     * @param fieldOffsetSize Field offset size.
      * @return Raw offset.
      */
-    public static int rawOffsetAbsolute(PortablePositionReadable in, int start) {
+    public static int rawOffsetAbsolute(PortablePositionReadable in, int start, int fieldOffsetSize)
{
         int len = length(in, start);
 
         short flags = in.readShortPositioned(start + GridPortableMarshaller.FLAGS_POS);
@@ -653,7 +654,7 @@ public class PortableUtils {
             // Schema exists.
             int schemaOff = in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
 
-            if ((((len - schemaOff) >> 2) & 0x1) == 0x0)
+            if (((len - schemaOff) % (4 + fieldOffsetSize)) == 0x0)
                 // Even amount of records in schema => no raw offset.
                 return start + schemaOff;
             else

http://git-wip-us.apache.org/repos/asf/ignite/blob/75f01dfd/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 d417db4..482b2f6 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
@@ -236,7 +236,7 @@ public class PortableBuilderImpl implements PortableBuilder {
             int footerEnd = footer.get2();
 
             // Get raw position.
-            int rawPos = PortableUtils.rawOffsetAbsolute(reader, start);
+            int rawPos = PortableUtils.rawOffsetAbsolute(reader, start, fieldOffsetSize);
 
             // Position reader on data.
             reader.position(start + hdrLen);
@@ -368,7 +368,9 @@ public class PortableBuilderImpl implements PortableBuilder {
 
         if (reader != null) {
             // Write raw data if any.
-            int rawOff = PortableUtils.rawOffsetAbsolute(reader, start);
+            int fieldOffsetSize = PortableUtils.fieldOffsetSize(flags);
+
+            int rawOff = PortableUtils.rawOffsetAbsolute(reader, start, fieldOffsetSize);
             int footerStart = PortableUtils.footerStartAbsolute(reader, start);
 
             if (rawOff < footerStart) {
@@ -433,7 +435,7 @@ public class PortableBuilderImpl implements PortableBuilder {
             int footerPos = footer.get1();
             int footerEnd = footer.get2();
 
-            int rawPos = PortableUtils.rawOffsetAbsolute(reader, start);
+            int rawPos = PortableUtils.rawOffsetAbsolute(reader, start, fieldOffsetSize);
 
             while (footerPos < footerEnd) {
                 int fieldId = reader.readIntPositioned(footerPos);


Mime
View raw message