ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [43/50] incubator-ignite git commit: ignite-950: putting field type instead of field length into the meta
Date Fri, 19 Jun 2015 10:35:29 GMT
ignite-950: putting field type instead of field length into the meta


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

Branch: refs/heads/ignite-950
Commit: 296ff8ce31a1d04f69b07b681b7c4e0f5eb34919
Parents: 5e7fcc1
Author: Denis Magda <dmagda@gridgain.com>
Authored: Thu Jun 18 16:32:57 2015 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Thu Jun 18 16:32:57 2015 +0300

----------------------------------------------------------------------
 .../optimized/ext/OptimizedObjectMetadata.java  | 81 +++++++++++---------
 1 file changed, 43 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/296ff8ce/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/ext/OptimizedObjectMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/ext/OptimizedObjectMetadata.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/ext/OptimizedObjectMetadata.java
index 7154a25..39acece 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/ext/OptimizedObjectMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/ext/OptimizedObjectMetadata.java
@@ -46,40 +46,9 @@ public class OptimizedObjectMetadata implements Externalizable {
         if (fieldsInfo == null)
             fieldsInfo = new ArrayList<>();
 
-        int len = 1;
-
-        switch (fieldType) {
-            case BYTE:
-            case BOOLEAN:
-                len += 1;
-                break;
-
-            case SHORT:
-            case CHAR:
-                len += 2;
-                break;
-
-            case INT:
-            case FLOAT:
-                len += 4;
-                break;
-
-            case LONG:
-            case DOUBLE:
-                len += 8;
-                break;
-
-            case OTHER:
-                len = OptimizedMarshallerExt.VARIABLE_LEN;
-                break;
-
-            default:
-                throw new IgniteException("Unknown field type: " + fieldType);
-        }
 
-        assert len != 1;
 
-        fieldsInfo.add(new FieldInfo(fieldId, len));
+        fieldsInfo.add(new FieldInfo(fieldId, fieldType));
     }
 
     /**
@@ -111,7 +80,7 @@ public class OptimizedObjectMetadata implements Externalizable {
 
         for (FieldInfo fieldInfo : fieldsInfo) {
             out.writeInt(fieldInfo.id);
-            out.writeInt(fieldInfo.len);
+            out.writeByte(fieldInfo.type.ordinal());
         }
     }
 
@@ -122,7 +91,7 @@ public class OptimizedObjectMetadata implements Externalizable {
         fieldsInfo = new ArrayList<>(size);
 
         for (int i = 0; i < size; i++)
-            fieldsInfo.add(new FieldInfo(in.readInt(), in.readInt()));
+            fieldsInfo.add(new FieldInfo(in.readInt(), OptimizedFieldType.values()[in.readByte()]));
     }
 
     /**
@@ -132,18 +101,54 @@ public class OptimizedObjectMetadata implements Externalizable {
         /** Field ID. */
         int id;
 
-        /** Field type. */
+        /** Field len. */
         int len;
 
+        /** Field type. */
+        OptimizedFieldType type;
+
         /**
          * Constructor.
          *
          * @param id Field ID.
-         * @param len Field len.
+         * @param type Field len.
          */
-        public FieldInfo(int id, int len) {
+        public FieldInfo(int id, OptimizedFieldType type) {
             this.id = id;
-            this.len = len;
+            this.type = type;
+
+            len = 1;
+
+            switch (type) {
+                case BYTE:
+                case BOOLEAN:
+                    len += 1;
+                    break;
+
+                case SHORT:
+                case CHAR:
+                    len += 2;
+                    break;
+
+                case INT:
+                case FLOAT:
+                    len += 4;
+                    break;
+
+                case LONG:
+                case DOUBLE:
+                    len += 8;
+                    break;
+
+                case OTHER:
+                    len = OptimizedMarshallerExt.VARIABLE_LEN;
+                    break;
+
+                default:
+                    throw new IgniteException("Unknown field type: " + type);
+            }
+
+            assert len != 1;
         }
     }
 }


Mime
View raw message