ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [1/4] ignite git commit: IGNITE-1917: IDs are always initialized in schema.
Date Thu, 19 Nov 2015 10:10:34 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1917 29762a291 -> 16194b14b


IGNITE-1917: IDs are always initialized in schema.


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

Branch: refs/heads/ignite-1917
Commit: db988fe1742a13719772454e3f1c7731a63f4cb5
Parents: 29762a2
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Thu Nov 19 11:55:30 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Thu Nov 19 11:55:30 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/PortableSchema.java       | 89 +++++++++-----------
 1 file changed, 39 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/db988fe1/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 ff7124e..af4b1b2 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
@@ -99,6 +99,13 @@ public class PortableSchema implements Externalizable {
     private PortableSchema(int schemaId, List<Integer> fieldIds) {
         this.schemaId = schemaId;
 
+        ids = new int[fieldIds.size()];
+
+        for (int i = 0; i < fieldIds.size(); i++)
+            ids[i] = fieldIds.get(i);
+
+        names = new String[fieldIds.size()];
+
         if (fieldIds.size() <= 8) {
             Iterator<Integer> iter = fieldIds.iterator();
 
@@ -114,15 +121,8 @@ public class PortableSchema implements Externalizable {
         else {
             id0 = id1 = id2 = id3 = id4 = id5 = id6 = id7 = 0;
 
-            ids = new int[fieldIds.size()];
-
-            for (int i = 0; i < fieldIds.size(); i++)
-                ids[i] = fieldIds.get(i);
-
             initializeMap(ids);
         }
-
-        names = new String[fieldIds.size()];
     }
 
     /**
@@ -177,41 +177,7 @@ public class PortableSchema implements Externalizable {
      * @return Field ID.
      */
     public int fieldId(int order) {
-        if (idToOrderData == null) {
-            switch (order) {
-                case 0:
-                    return id0;
-
-                case 1:
-                    return id1;
-
-                case 2:
-                    return id2;
-
-                case 3:
-                    return id3;
-
-                case 4:
-                    return id4;
-
-                case 5:
-                    return id5;
-
-                case 6:
-                    return id6;
-
-                case 7:
-                    return id7;
-
-                default:
-                    assert false : "Should not reach here.";
-
-                    return 0;
-            }
-        }
-        else
-            // TODO: Fix possible out of bounds problem.
-            return ids[order];
+        return order < ids.length ? ids[order] : 0;
     }
 
     /**
@@ -320,37 +286,60 @@ public class PortableSchema implements Externalizable {
         if (in.readBoolean()) {
             int size = 0;
 
+            List<Integer> ids0 = new ArrayList<>();
+
             id0 = in.readInt();
-            if (id0 != 0)
+            if (id0 != 0) {
+                ids0.add(id0);
                 size++;
+            }
 
             id1 = in.readInt();
-            if (id1 != 0)
+            if (id1 != 0) {
+                ids0.add(id1);
                 size++;
+            }
 
             id2 = in.readInt();
-            if (id2 != 0)
+            if (id2 != 0) {
+                ids0.add(id2);
                 size++;
+            }
 
             id3 = in.readInt();
-            if (id3 != 0)
+            if (id3 != 0) {
+                ids0.add(id3);
                 size++;
+            }
 
             id4 = in.readInt();
-            if (id4 != 0)
+            if (id4 != 0) {
+                ids0.add(id4);
                 size++;
+            }
 
             id5 = in.readInt();
-            if (id5 != 0)
+            if (id5 != 0) {
+                ids0.add(id5);
                 size++;
+            }
 
             id6 = in.readInt();
-            if (id6 != 0)
+            if (id6 != 0) {
+                ids0.add(id6);
                 size++;
+            }
 
             id7 = in.readInt();
-            if (id7 != 0)
+            if (id7 != 0) {
+                ids0.add(id7);
                 size++;
+            }
+
+            ids = new int[size];
+
+            for (int i = 0; i < size; i++)
+                ids[i] = ids0.get(i);
 
             names = new String[size];
         }


Mime
View raw message