You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/10/23 16:57:31 UTC

[3/4] ignite git commit: IGNITE-1770: Added space for schema offset.

IGNITE-1770: Added space for schema offset.


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

Branch: refs/heads/ignite-1770
Commit: 0a024013f0b23fc1108b610a1ccb955163ee4d31
Parents: 90cb588
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Oct 23 17:53:39 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Oct 23 17:53:39 2015 +0300

----------------------------------------------------------------------
 .../portable/GridPortableMarshaller.java        |  2 +-
 .../portable/PortableClassDescriptor.java       | 19 +++--------
 .../ignite/internal/portable/PortableUtils.java | 30 ++++++++++++++++
 .../portable/builder/PortableBuilderImpl.java   | 36 +++++++++-----------
 4 files changed, 52 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0a024013/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
index dcbadba..e1621f0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
@@ -217,7 +217,7 @@ public class GridPortableMarshaller {
     public static final int SCHEMA_OFF_POS = 20;
 
     /** */
-    public static final byte DFLT_HDR_LEN = 20;
+    public static final byte DFLT_HDR_LEN = 24;
 
     /** */
     private final PortableContext ctx;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0a024013/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 c093a19..81c828c 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
@@ -648,20 +648,11 @@ public class PortableClassDescriptor {
 
         int pos = writer.position();
 
-        writer.doWriteByte(GridPortableMarshaller.OBJ);
-        writer.doWriteByte(GridPortableMarshaller.PROTO_VER);
-
-        PortableUtils.writeFlags(writer, userType);
-
-        writer.doWriteInt(registered ? typeId : GridPortableMarshaller.UNREGISTERED_TYPE_ID);
-        writer.doWriteInt(obj instanceof CacheObjectImpl ? 0 : obj.hashCode());
-
-        // For length and raw offset.
-        int reserved = writer.reserve(8);
-
-        // Class name in case if typeId registration is failed.
-        if (!registered)
-            writer.doWriteString(cls.getName());
+        int reserved = PortableUtils.writeHeader(writer,
+            userType,
+            registered ? typeId : GridPortableMarshaller.UNREGISTERED_TYPE_ID,
+            obj instanceof CacheObjectImpl ? 0 : obj.hashCode(),
+            registered ? null : cls.getName());
 
         int current = writer.position();
         int len = current - pos;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0a024013/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 4a866fd..0697fb7 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
@@ -525,4 +525,34 @@ public class PortableUtils {
         if (PROTO_VER != protoVer)
             throw new PortableException("Unsupported protocol version: " + protoVer);
     }
+
+    /**
+     * Write portable header.
+     *
+     * @param writer Writer.
+     * @param usrTyp User type flag.
+     * @param typeId Type ID.
+     * @param hashCode Hash code.
+     * @param clsName Class name (optional).
+     * @return Position where length should be written.
+     */
+    public static int writeHeader(PortableWriterExImpl writer, boolean usrTyp, int typeId, int hashCode,
+        @Nullable String clsName) {
+        writer.doWriteByte(GridPortableMarshaller.OBJ);
+        writer.doWriteByte(GridPortableMarshaller.PROTO_VER);
+
+        PortableUtils.writeFlags(writer, usrTyp);
+
+        writer.doWriteInt(typeId);
+        writer.doWriteInt(hashCode);
+
+        int reserved = writer.reserve(8);
+
+        writer.doWriteInt(0); // TODO: Write schema offset here.
+
+        if (clsName != null)
+            writer.doWriteString(clsName);
+
+        return reserved;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0a024013/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 c16d00d..2c2173e 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
@@ -17,11 +17,11 @@
 
 package org.apache.ignite.internal.portable.builder;
 
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
+import org.apache.ignite.internal.portable.PortableContext;
+import org.apache.ignite.internal.portable.PortableObjectImpl;
+import org.apache.ignite.internal.portable.PortableObjectOffheapImpl;
+import org.apache.ignite.internal.portable.PortableUtils;
+import org.apache.ignite.internal.portable.PortableWriterExImpl;
 import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
 import org.apache.ignite.internal.util.GridArgumentCheck;
 import org.apache.ignite.internal.util.typedef.internal.U;
@@ -31,11 +31,15 @@ import org.apache.ignite.portable.PortableInvalidClassException;
 import org.apache.ignite.portable.PortableMetadata;
 import org.apache.ignite.portable.PortableObject;
 import org.jetbrains.annotations.Nullable;
-import org.apache.ignite.internal.portable.*;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
 
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.DFLT_HDR_LEN;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.HASH_CODE_POS;
-import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROTO_VER;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROTO_VER_POS;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.RAW_DATA_OFF_POS;
 import static org.apache.ignite.internal.portable.GridPortableMarshaller.TOTAL_LEN_POS;
@@ -194,19 +198,11 @@ public class PortableBuilderImpl implements PortableBuilder {
      * @param serializer Serializer.
      */
     void serializeTo(PortableWriterExImpl writer, PortableBuilderSerializer serializer) {
-        writer.doWriteByte(GridPortableMarshaller.OBJ);
-        writer.doWriteByte(PROTO_VER);
-
-        PortableUtils.writeFlags(writer, true);
-
-        writer.doWriteInt(registeredType ? typeId : UNREGISTERED_TYPE_ID);
-        writer.doWriteInt(hashCode);
-
-        // Length and raw offset.
-        writer.reserve(8);
-
-        if (!registeredType)
-            writer.writeString(clsNameToWrite);
+        PortableUtils.writeHeader(writer,
+            true,
+            registeredType ? typeId : UNREGISTERED_TYPE_ID,
+            hashCode,
+            registeredType ? null : clsNameToWrite);
 
         Set<Integer> remainsFlds = null;