ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [1/7] ignite git commit: IGNITE-1418: Applied schema changes.
Date Mon, 02 Nov 2015 13:00:38 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1814-debug 531e1e9a6 -> 2c0ee0e1a


IGNITE-1418: Applied schema changes.


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

Branch: refs/heads/ignite-1814-debug
Commit: 24180f3e84c6e7cfa9949b5ed99f372865a64f82
Parents: 531e1e9
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Mon Nov 2 15:24:23 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Mon Nov 2 15:24:23 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/PortableFieldImpl.java    | 10 +--
 .../internal/portable/PortableReaderExImpl.java | 19 ++++--
 .../internal/portable/PortableSchema.java       | 70 ++++++++++----------
 .../ignite/internal/portable/PortableUtils.java | 14 ++++
 4 files changed, 67 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/24180f3e/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 5780b76..d85d7df 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
@@ -45,7 +45,7 @@ public class PortableFieldImpl implements PortableField {
     @Override public boolean exists(PortableObject obj) {
         PortableObjectEx obj0 = (PortableObjectEx)obj;
 
-        return fieldOffset(obj0) != 0;
+        return fieldOrder(obj0) != 0;
     }
 
     /** {@inheritDoc} */
@@ -53,9 +53,9 @@ public class PortableFieldImpl implements PortableField {
     @Override public <T> T value(PortableObject obj) {
         PortableObjectEx obj0 = (PortableObjectEx)obj;
 
-        int offset = fieldOffset(obj0);
+        int order = fieldOrder(obj0);
 
-        return offset != 0 ? (T)obj0.fieldByOffset(offset) : null;
+        return order != 0 ? (T)obj0.fieldByOffset(order * 8 + 4) : null;
     }
 
     /**
@@ -64,7 +64,7 @@ public class PortableFieldImpl implements PortableField {
      * @param obj Object.
      * @return Field offset.
      */
-    private int fieldOffset(PortableObjectEx obj) {
+    private int fieldOrder(PortableObjectEx obj) {
         int schemaId = obj.schemaId();
 
         PortableSchema schema = schemas.schema(schemaId);
@@ -77,6 +77,6 @@ public class PortableFieldImpl implements PortableField {
 
         assert schema != null;
 
-        return schema.offset(fieldId);
+        return schema.order(fieldId);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/24180f3e/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 aa1519d..441cc71 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
@@ -163,6 +163,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
     /** Schema Id. */
     private int schemaId;
 
+    /** Offset size in bytes. */
+    private int offsetSize;
+
     /** Object schema. */
     private PortableSchema schema;
 
@@ -221,7 +224,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
 
         PortableUtils.checkProtocolVersion(in.readByte());
 
-        in.position(in.position() + 2); // Skip flags.
+        short flags = in.readShort();
+
+        offsetSize = PortableUtils.fieldOffsetSize(flags);
 
         typeId = in.readIntPositioned(start + GridPortableMarshaller.TYPE_ID_POS);
 
@@ -2567,12 +2572,14 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
         int searchPos = footerStart;
         int searchEnd = searchPos + footerLen;
 
+        int idx = 0;
+
         while (searchPos < searchEnd) {
             int fieldId = in.readIntPositioned(searchPos);
 
-            fields.put(fieldId, searchPos + 4 - footerStart);
+            fields.put(fieldId, idx++);
 
-            searchPos += 8;
+            searchPos += 4 + offsetSize;
         }
 
         return new PortableSchema(fields);
@@ -2624,10 +2631,10 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
                 schema = schema0;
             }
 
-            int fieldOffsetPos = schema.offset(id);
+            int order = schema.order(id);
 
-            if (fieldOffsetPos != 0) {
-                int pos = start + in.readIntPositioned(footerStart + fieldOffsetPos);
+            if (order != 0) {
+                int pos = start + in.readIntPositioned(footerStart + order * 8 + 4);
 
                 in.position(pos);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/24180f3e/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
index 09bfe35..250598a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableSchema.java
@@ -39,49 +39,49 @@ public class PortableSchema {
     private final int id1;
 
     /** Offset 1. */
-    private final int offset1;
+    private final int pos1;
 
     /** ID 2. */
     private final int id2;
 
     /** Offset 2. */
-    private final int offset2;
+    private final int pos2;
 
     /** ID 3. */
     private final int id3;
 
     /** Offset 3. */
-    private final int offset3;
+    private final int pos3;
 
     /** ID 4. */
     private final int id4;
 
     /** Offset 4. */
-    private final int offset4;
+    private final int pos4;
 
     /** ID 1. */
     private final int id5;
 
     /** Offset 1. */
-    private final int offset5;
+    private final int pos5;
 
     /** ID 2. */
     private final int id6;
 
     /** Offset 2. */
-    private final int offset6;
+    private final int pos6;
 
     /** ID 3. */
     private final int id7;
 
     /** Offset 3. */
-    private final int offset7;
+    private final int pos7;
 
     /** ID 4. */
     private final int id8;
 
     /** Offset 4. */
-    private final int offset8;
+    private final int pos8;
 
     /**
      * Constructor.
@@ -98,74 +98,74 @@ public class PortableSchema {
 
             if (entry != null) {
                 id1 = entry.getKey();
-                offset1 = entry.getValue();
+                pos1 = entry.getValue();
             }
             else{
                 id1 = 0;
-                offset1 = 0;
+                pos1 = 0;
             }
 
             if ((entry = iter.hasNext() ? iter.next() : null) != null) {
                 id2 = entry.getKey();
-                offset2 = entry.getValue();
+                pos2 = entry.getValue();
             }
             else{
                 id2 = 0;
-                offset2 = 0;
+                pos2 = 0;
             }
 
             if ((entry = iter.hasNext() ? iter.next() : null) != null) {
                 id3 = entry.getKey();
-                offset3 = entry.getValue();
+                pos3 = entry.getValue();
             }
             else{
                 id3 = 0;
-                offset3 = 0;
+                pos3 = 0;
             }
 
             if ((entry = iter.hasNext() ? iter.next() : null) != null) {
                 id4 = entry.getKey();
-                offset4 = entry.getValue();
+                pos4 = entry.getValue();
             }
             else{
                 id4 = 0;
-                offset4 = 0;
+                pos4 = 0;
             }
 
             if ((entry = iter.hasNext() ? iter.next() : null) != null) {
                 id5 = entry.getKey();
-                offset5 = entry.getValue();
+                pos5 = entry.getValue();
             }
             else{
                 id5 = 0;
-                offset5 = 0;
+                pos5 = 0;
             }
 
             if ((entry = iter.hasNext() ? iter.next() : null) != null) {
                 id6 = entry.getKey();
-                offset6 = entry.getValue();
+                pos6 = entry.getValue();
             }
             else{
                 id6 = 0;
-                offset6 = 0;
+                pos6 = 0;
             }
 
             if ((entry = iter.hasNext() ? iter.next() : null) != null) {
                 id7 = entry.getKey();
-                offset7 = entry.getValue();
+                pos7 = entry.getValue();
             }
             else{
                 id7 = 0;
-                offset7 = 0;
+                pos7 = 0;
             }
 
             if ((entry = iter.hasNext() ? iter.next() : null) != null) {
                 id8 = entry.getKey();
-                offset8 = entry.getValue();
+                pos8 = entry.getValue();
             }
             else{
                 id8 = 0;
-                offset8 = 0;
+                pos8 = 0;
             }
 
             map = null;
@@ -174,43 +174,43 @@ public class PortableSchema {
             inline = false;
 
             id1 = id2 = id3 = id4 = id5 = id6 = id7 = id8 = 0;
-            offset1 = offset2 = offset3 = offset4 = offset5 = offset6 = offset7 = offset8
= 0;
+            pos1 = pos2 = pos3 = pos4 = pos5 = pos6 = pos7 = pos8 = 0;
 
             map = new HashMap<>(vals);
         }
     }
 
     /**
-     * Get offset for the given field ID.
+     * Get field position in footer by schema ID.
      *
      * @param id Field ID.
      * @return Offset or {@code 0} if there is no such field.
      */
-    public int offset(int id) {
+    public int order(int id) {
         if (inline) {
             if (id == id1)
-                return offset1;
+                return pos1;
 
             if (id == id2)
-                return offset2;
+                return pos2;
 
             if (id == id3)
-                return offset3;
+                return pos3;
 
             if (id == id4)
-                return offset4;
+                return pos4;
 
             if (id == id5)
-                return offset5;
+                return pos5;
 
             if (id == id6)
-                return offset6;
+                return pos6;
 
             if (id == id7)
-                return offset7;
+                return pos7;
 
             if (id == id8)
-                return offset8;
+                return pos8;
 
             return 0;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/24180f3e/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 f57a29b..f08b48a 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
@@ -659,4 +659,18 @@ public class PortableUtils {
                 return start + in.readIntPositioned(start + len - 4);
         }
     }
+
+    /**
+     * Get offset size for the given flags.
+     * @param flags Flags.
+     * @return Offset size.
+     */
+    public static int fieldOffsetSize(short flags) {
+        if ((flags & FLAG_OFFSET_ONE_BYTE) == FLAG_OFFSET_ONE_BYTE)
+            return OFFSET_1;
+        else if ((flags & FLAG_OFFSET_TWO_BYTES) == FLAG_OFFSET_TWO_BYTES)
+            return OFFSET_2;
+        else
+            return OFFSET_4;
+    }
 }
\ No newline at end of file


Mime
View raw message