ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [2/2] ignite git commit: IGNITE-1770: Refactoring.
Date Tue, 27 Oct 2015 09:08:36 GMT
IGNITE-1770: Refactoring.


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

Branch: refs/heads/ignite-1770
Commit: 7bc3f2ff5e19bf2210b01e375c097a04907160fb
Parents: a21f12b
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Oct 27 12:09:19 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Oct 27 12:09:19 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/portable/PortableUtils.java  | 19 +++++++++++++++----
 .../portable/builder/PortableBuilderImpl.java    |  4 ++--
 2 files changed, 17 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7bc3f2ff/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 f077293..5dc7d22 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
@@ -574,12 +574,12 @@ public class PortableUtils {
      * @param start Object start position inside the stream.
      * @return Footer start.
      */
-    public static int footerStart(PortablePositionReadable in, int start) {
+    public static int footerStartRelative(PortablePositionReadable in, int start) {
         int schemaId = in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_ID_POS);
 
         if (schemaId == 0)
             // No schema, footer start equals to object end.
-            return in.readIntPositioned(start + GridPortableMarshaller.TOTAL_LEN_POS);
+            return length(in, start);
         else
             // Schema exists, use offset.
             return in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_OR_RAW_OFF_POS);
@@ -590,10 +590,21 @@ public class PortableUtils {
      *
      * @param in Input stream.
      * @param start Start position.
+     * @return Footer start.
+     */
+    public static int footerStartAbsolute(PortablePositionReadable in, int start) {
+        return footerStartRelative(in, start) + start;
+    }
+
+    /**
+     * Get object's footer.
+     *
+     * @param in Input stream.
+     * @param start Start position.
      * @return Footer.
      */
     public static IgniteBiTuple<Integer, Integer> footerAbsolute(PortablePositionReadable
in, int start) {
-        int footerStart = footerStart(in, start);
+        int footerStart = footerStartRelative(in, start);
         int footerEnd = length(in, start);
 
         // Take in count possible raw offset.
@@ -611,7 +622,7 @@ public class PortableUtils {
      * @return Raw offset.
      */
     public static int rawOffsetAbsolute(PortablePositionReadable in, int start) {
-        int len = in.readIntPositioned(start + GridPortableMarshaller.TOTAL_LEN_POS);
+        int len = length(in, start);
         int schemaId = in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_ID_POS);
 
         if (schemaId == 0)

http://git-wip-us.apache.org/repos/asf/ignite/blob/7bc3f2ff/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 da9f86f..d703b15 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
@@ -379,7 +379,7 @@ public class PortableBuilderImpl implements PortableBuilder {
         if (reader != null) {
             // Write raw data if any.
             int rawOff = PortableUtils.rawOffsetAbsolute(reader, start);
-            int footerStart = start + PortableUtils.footerStart(reader, start);
+            int footerStart = PortableUtils.footerStartAbsolute(reader, start);
 
             if (rawOff < footerStart) {
                 writer.rawWriter();
@@ -388,7 +388,7 @@ public class PortableBuilderImpl implements PortableBuilder {
             }
 
             // Shift reader to the end of the object.
-            reader.position(start + reader.readIntPositioned(start + GridPortableMarshaller.TOTAL_LEN_POS));
+            reader.position(start + PortableUtils.length(reader, start));
         }
 
         writer.postWrite();


Mime
View raw message