ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [03/11] ignite git commit: IGNITE-1770: Schema ID for reflective classes.
Date Tue, 27 Oct 2015 14:32:08 GMT
IGNITE-1770: Schema ID for reflective classes.


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

Branch: refs/heads/ignite-1770
Commit: 0e491349352159b2041692000fdb0fe88308bbdf
Parents: ea23354
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Oct 27 15:42:16 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Oct 27 15:42:16 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/PortableClassDescriptor.java  | 16 +++++++++++++---
 .../internal/portable/PortableWriterExImpl.java     |  7 +------
 .../portable/builder/PortableBuilderImpl.java       |  2 +-
 3 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0e491349/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index 25ec856..9fe04f4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -81,6 +81,9 @@ public class PortableClassDescriptor {
     /** */
     private final Collection<FieldInfo> fields;
 
+    /** Schema ID for constant-time lookup. */
+    private final int schemaId;
+
     /** */
     private final Method writeReplaceMtd;
 
@@ -141,6 +144,8 @@ public class PortableClassDescriptor {
         this.keepDeserialized = keepDeserialized;
         this.registered = registered;
 
+        int schemaId = 0;
+
         excluded = MarshallerExclusions.isExcluded(cls);
 
         useOptMarshaller = !predefined && initUseOptimizedMarshallerFlag();
@@ -233,6 +238,9 @@ public class PortableClassDescriptor {
 
                             if (metaDataEnabled)
                                 fieldsMeta.put(name, fieldInfo.fieldMode().typeName());
+
+                            // Track schema ID.
+                            schemaId = 31 * schemaId + fieldId;
                         }
                     }
                 }
@@ -252,6 +260,8 @@ public class PortableClassDescriptor {
             readResolveMtd = null;
             writeReplaceMtd = null;
         }
+
+        this.schemaId = schemaId;
     }
 
     /**
@@ -515,7 +525,7 @@ public class PortableClassDescriptor {
                     else
                         ((PortableMarshalAware)obj).writePortable(writer);
 
-                    writer.postWrite(userType);
+                    writer.postWrite(schemaId, userType);
 
                     if (obj.getClass() != PortableMetaDataImpl.class
                         && ctx.isMetaDataChanged(typeId, writer.metaDataHashSum()))
{
@@ -543,7 +553,7 @@ public class PortableClassDescriptor {
                         throw new PortableException("Failed to write Externalizable object:
" + obj, e);
                     }
 
-                    writer.postWrite(userType);
+                    writer.postWrite(schemaId, userType);
                 }
 
                 break;
@@ -553,7 +563,7 @@ public class PortableClassDescriptor {
                     for (FieldInfo info : fields)
                         info.write(obj, writer);
 
-                    writer.postWrite(userType);
+                    writer.postWrite(schemaId, userType);
                 }
 
                 break;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e491349/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
index f2af9d4..6e4c430 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
@@ -125,9 +125,6 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
     // TODO: Optimize.
     private List<Integer> schema;
 
-    /** Schema ID. */
-    private int schemaId;
-
     /**
      * @param ctx Context.
      */
@@ -319,7 +316,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
      *
      * @param userType User type flag.
      */
-    public void postWrite(boolean userType) {
+    public void postWrite(int schemaId, boolean userType) {
         if (schema != null) {
             // Write schema ID.
             out.writeInt(start + SCHEMA_ID_POS, schemaId);
@@ -1714,8 +1711,6 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
 
         schema.add(id);
         schema.add(off);
-
-        schemaId = 31 * schemaId + id;
     }
 
      /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0e491349/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 90104e3..fa0ddde 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
@@ -376,7 +376,7 @@ public class PortableBuilderImpl implements PortableBuilder {
             reader.position(start + PortableUtils.length(reader, start));
         }
 
-        writer.postWrite(true);
+        writer.postWrite(0, true);
     }
 
     /** {@inheritDoc} */


Mime
View raw message