ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-1902: Done.
Date Wed, 18 Nov 2015 07:34:22 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1816 c46ebd5ed -> ff38ae943


IGNITE-1902: Done.


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

Branch: refs/heads/ignite-1816
Commit: ff38ae943b8fba8c64186cc342a85cfc242f44cf
Parents: c46ebd5
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Wed Nov 18 10:35:02 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Nov 18 10:35:02 2015 +0300

----------------------------------------------------------------------
 .../platform/PlatformContextImpl.java           |   4 +-
 .../cpp/PlatformCppConfigurationClosure.java    |   9 +-
 .../PlatformDotNetConfigurationClosure.java     |   9 +-
 .../Config/Compute/compute-grid1.xml            |   1 +
 .../Impl/Binary/BinaryObjectBuilder.cs          |  25 ++--
 .../Impl/Binary/BinaryObjectHeader.cs           | 131 +++++++++++--------
 .../Impl/Binary/BinaryObjectSchemaHolder.cs     |   9 +-
 .../Impl/Binary/BinaryReader.cs                 |   2 +-
 .../Impl/Binary/BinaryWriter.cs                 |  27 ++--
 .../Impl/Binary/IgniteBinary.cs                 |   3 +-
 10 files changed, 141 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ff38ae94/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
index 41598bc..93e9a8a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
@@ -33,8 +33,8 @@ import org.apache.ignite.events.JobEvent;
 import org.apache.ignite.events.SwapSpaceEvent;
 import org.apache.ignite.events.TaskEvent;
 import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.portable.BinaryTypeImpl;
 import org.apache.ignite.internal.portable.GridPortableMarshaller;
-import org.apache.ignite.internal.portable.BinaryMetadata;
 import org.apache.ignite.internal.portable.BinaryRawReaderEx;
 import org.apache.ignite.internal.portable.BinaryRawWriterEx;
 import org.apache.ignite.internal.processors.cache.portable.CacheObjectBinaryProcessorImpl;
@@ -390,7 +390,7 @@ public class PlatformContextImpl implements PlatformContext {
         else {
             writer.writeBoolean(true);
 
-            Map<String, Integer> fields = ((BinaryMetadata)meta).fieldsMap();
+            Map<String, Integer> fields = ((BinaryTypeImpl)meta).metadata().fieldsMap();
 
             writer.writeInt(typeId);
             writer.writeString(meta.typeName());

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff38ae94/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
index 9f17bdd..e9cd1e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
@@ -71,7 +71,11 @@ public class PlatformCppConfigurationClosure extends PlatformAbstractConfigurati
         Marshaller marsh = igniteCfg.getMarshaller();
 
         if (marsh == null) {
-            igniteCfg.setMarshaller(new PortableMarshaller());
+            PortableMarshaller marsh0 = new PortableMarshaller();
+
+            marsh0.setCompactFooter(false);
+
+            igniteCfg.setMarshaller(marsh0);
 
             cppCfg0.warnings(Collections.singleton("Marshaller is automatically set to "
+
                 PortableMarshaller.class.getName() + " (other nodes must have the same marshaller
type)."));
@@ -79,6 +83,9 @@ public class PlatformCppConfigurationClosure extends PlatformAbstractConfigurati
         else if (!(marsh instanceof PortableMarshaller))
             throw new IgniteException("Unsupported marshaller (only " + PortableMarshaller.class.getName()
+
                 " can be used when running Apache Ignite C++): " + marsh.getClass().getName());
+        else if (((PortableMarshaller)marsh).isCompactFooter())
+            throw new IgniteException("Unsupported " + PortableMarshaller.class.getName()
+
+                " \"compactFooter\" flag: must be false when running Apache Ignite C++.");
 
         // Set Ignite home so that marshaller context works.
         String ggHome = igniteCfg.getIgniteHome();

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff38ae94/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index d0462e9..a59fd22 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -92,7 +92,11 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
         Marshaller marsh = igniteCfg.getMarshaller();
 
         if (marsh == null) {
-            igniteCfg.setMarshaller(new PortableMarshaller());
+            PortableMarshaller marsh0 = new PortableMarshaller();
+
+            marsh0.setCompactFooter(false);
+
+            igniteCfg.setMarshaller(marsh0);
 
             dotNetCfg0.warnings(Collections.singleton("Marshaller is automatically set to
" +
                 PortableMarshaller.class.getName() + " (other nodes must have the same marshaller
type)."));
@@ -100,6 +104,9 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
         else if (!(marsh instanceof PortableMarshaller))
             throw new IgniteException("Unsupported marshaller (only " + PortableMarshaller.class.getName()
+
                 " can be used when running Apache Ignite.NET): " + marsh.getClass().getName());
+        else if (((PortableMarshaller)marsh).isCompactFooter())
+            throw new IgniteException("Unsupported " + PortableMarshaller.class.getName()
+
+                " \"compactFooter\" flag: must be false when running Apache Ignite.NET.");
 
         // Set Ignite home so that marshaller context works.
         String ggHome = igniteCfg.getIgniteHome();

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff38ae94/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
index 0ad0070..6cb87ad 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid1.xml
@@ -70,6 +70,7 @@
         <!-- Portable marshaller configuration -->
         <property name="marshaller">
             <bean class="org.apache.ignite.marshaller.portable.PortableMarshaller">
+                <property name="compactFooter" value="false" />
                 <property name="typeConfigurations">
                     <list>
                         <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff38ae94/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
index 1840ab9..97cc381 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs
@@ -678,28 +678,37 @@ namespace Apache.Ignite.Core.Impl.Binary
                                 WriteField(ctx, valEntry.Value);
                             }
 
+                            var flags = inHeader.IsUserType
+                                ? BinaryObjectHeader.Flag.UserType
+                                : BinaryObjectHeader.Flag.None;
+
                             // Write raw data.
                             int outRawOff = outStream.Position - outStartPos;
 
-                            int inRawOff = inHeader.GetRawOffset(inStream, inStartPos);
-                            int inRawLen = inHeader.SchemaOffset - inRawOff;
+                            if (inHeader.HasRaw)
+                            {
+                                var inRawOff = inHeader.GetRawOffset(inStream, inStartPos);
+                                var inRawLen = inHeader.SchemaOffset - inRawOff;
+
+                                flags |= BinaryObjectHeader.Flag.HasRaw;
 
-                            if (inRawLen > 0)
                                 outStream.Write(inStream.InternalArray, inStartPos + inRawOff,
inRawLen);
+                            }
 
                             // Write schema
                             int outSchemaOff = outRawOff;
                             var schemaPos = outStream.Position;
                             int outSchemaId;
-                            short flags;
 
-                            var hasSchema = outSchema.WriteSchema(outStream, schemaIdx, out
outSchemaId, out flags);
+                            var hasSchema = outSchema.WriteSchema(outStream, schemaIdx, out
outSchemaId, ref flags);
 
                             if (hasSchema)
                             {
                                 outSchemaOff = schemaPos - outStartPos;
+                                
+                                flags |= BinaryObjectHeader.Flag.HasSchema;
 
-                                if (inRawLen > 0)
+                                if (inHeader.HasRaw)
                                     outStream.WriteInt(outRawOff);
                             }
 
@@ -707,8 +716,8 @@ namespace Apache.Ignite.Core.Impl.Binary
 
                             var outHash = changeHash ? hash : inHeader.HashCode;
 
-                            var outHeader = new BinaryObjectHeader(inHeader.IsUserType, inHeader.TypeId,
outHash,
-                                outLen, outSchemaId, outSchemaOff, !hasSchema, flags);
+                            var outHeader = new BinaryObjectHeader(inHeader.TypeId, outHash,
outLen, 
+                                outSchemaId, outSchemaOff, flags);
 
                             BinaryObjectHeader.Write(outHeader, outStream, outStartPos);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff38ae94/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
index 59cb29c1..573e014 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectHeader.cs
@@ -33,22 +33,38 @@ namespace Apache.Ignite.Core.Impl.Binary
         /** Size, equals to sizeof(BinaryObjectHeader). */
         public const int Size = 24;
 
-        /** User type flag. */
-        public const short FlagUserType = 0x1;
+        /// <summary>
+        /// Flags.
+        /// </summary>
+        [Flags]
+        public enum Flag : short
+        {
+            /** No flags. */
+            None            = 0x00,
+
+            /** Flag: user type. */
+            UserType        = 0x01,
+            
+            /** Flag: schema exists. */
+            HasSchema       = 0x02,
+
+            /** Flag indicating that object has raw data. */
+            HasRaw          = 0x04,
 
-        /** Raw only flag. */
-        public const short FlagRawOnly = 0x2;
+            /** Flag: offsets take 1 byte. */
+            OffsetOneByte   = 0x08,
 
-        /** Byte-sized field offsets flag. */
-        public const short FlagByteOffsets = 0x4;
+            /** Flag: offsets take 2 bytes. */
+            OffsetTwoBytes  = 0x10,
 
-        /** Short-sized field offsets flag. */
-        public const short FlagShortOffsets = 0x8;
+            /** Flag: compact footer, no field IDs. */
+            CompactFooter   = 0x20
+        }
 
         /** Actual header layout */
         public readonly byte Header;        // Header code, always 103 (HdrFull)
         public readonly byte Version;       // Protocol version
-        public readonly short Flags;        // Flags
+        public readonly Flag Flags;         // Flags
         public readonly int TypeId;         // Type ID
         public readonly int HashCode;       // Hash code
         public readonly int Length;         // Length, including header
@@ -58,16 +74,13 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// <summary>
         /// Initializes a new instance of the <see cref="BinaryObjectHeader" /> struct.
         /// </summary>
-        /// <param name="userType">User type flag.</param>
         /// <param name="typeId">Type ID.</param>
         /// <param name="hashCode">Hash code.</param>
         /// <param name="length">Length.</param>
         /// <param name="schemaId">Schema ID.</param>
         /// <param name="schemaOffset">Schema offset.</param>
-        /// <param name="rawOnly">Raw flag.</param>
         /// <param name="flags">The flags.</param>
-        public BinaryObjectHeader(bool userType, int typeId, int hashCode, int length, int
schemaId, int schemaOffset, 
-            bool rawOnly, short flags)
+        public BinaryObjectHeader(int typeId, int hashCode, int length, int schemaId, int
schemaOffset, Flag flags)
         {
             Header = BinaryUtils.HdrFull;
             Version = BinaryUtils.ProtoVer;
@@ -75,12 +88,6 @@ namespace Apache.Ignite.Core.Impl.Binary
             Debug.Assert(schemaOffset <= length);
             Debug.Assert(schemaOffset >= Size);
 
-            if (userType)
-                flags |= FlagUserType;
-
-            if (rawOnly)
-                flags |= FlagRawOnly;
-
             Flags = flags;
 
             TypeId = typeId;
@@ -98,7 +105,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             Header = stream.ReadByte();
             Version = stream.ReadByte();
-            Flags = stream.ReadShort();
+            Flags = (Flag) stream.ReadShort();
             Length = stream.ReadInt();
             TypeId = stream.ReadInt();
             HashCode = stream.ReadInt();
@@ -114,7 +121,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             stream.WriteByte(Header);
             stream.WriteByte(Version);
-            stream.WriteShort(Flags);
+            stream.WriteShort((short) Flags);
             stream.WriteInt(Length);
             stream.WriteInt(TypeId);
             stream.WriteInt(HashCode);
@@ -123,31 +130,35 @@ namespace Apache.Ignite.Core.Impl.Binary
         }
 
         /// <summary>
-        /// Gets a user type flag.
+        /// Gets the user type flag.
         /// </summary>
         public bool IsUserType
         {
-            get { return (Flags & FlagUserType) == FlagUserType; }
+            get { return (Flags & Flag.UserType) == Flag.UserType; }
         }
 
         /// <summary>
-        /// Gets a raw-only flag.
+        /// Gets the schema flag.
         /// </summary>
-        public bool IsRawOnly
+        public bool HasSchema
         {
-            get { return (Flags & FlagRawOnly) == FlagRawOnly; }
+            get { return (Flags & Flag.HasSchema) == Flag.HasSchema; }
         }
 
         /// <summary>
-        /// Gets a value indicating whether this instance has raw offset.
+        /// Gets the raw flag.
         /// </summary>
-        public bool HasRawOffset
+        public bool HasRaw
         {
-            get
-            {
-                // Remainder => raw offset is the very last 4 bytes in object.
-                return !IsRawOnly && ((Length - SchemaOffset) % SchemaFieldSize)
== 4;
-            }
+            get { return (Flags & Flag.HasRaw) == Flag.HasRaw; }
+        }
+
+        /// <summary>
+        /// Gets the compact footer flag.
+        /// </summary>
+        public bool IsCompactFooter
+        {
+            get { return (Flags & Flag.CompactFooter) == Flag.CompactFooter; }
         }
 
         /// <summary>
@@ -157,10 +168,10 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             get
             {
-                if ((Flags & FlagByteOffsets) == FlagByteOffsets)
+                if ((Flags & Flag.OffsetOneByte) == Flag.OffsetOneByte)
                     return 1;
 
-                if ((Flags & FlagShortOffsets) == FlagShortOffsets)
+                if ((Flags & Flag.OffsetTwoBytes) == Flag.OffsetTwoBytes)
                     return 2;
 
                 return 4;
@@ -182,7 +193,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             get
             {
-                if (IsRawOnly)
+                if (!HasSchema)
                     return 0;
 
                 var schemaSize = Length - SchemaOffset;
@@ -201,7 +212,7 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             Debug.Assert(stream != null);
 
-            if (!HasRawOffset)
+            if (!HasRaw || !HasSchema)
                 return SchemaOffset;
 
             stream.Seek(position + Length - 4, SeekOrigin.Begin);
@@ -219,6 +230,8 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             Debug.Assert(stream != null);
 
+            ThrowIfUnsupported();
+
             var schemaSize = SchemaFieldCount;
 
             if (schemaSize == 0)
@@ -259,6 +272,8 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             Debug.Assert(stream != null);
 
+            ThrowIfUnsupported();
+
             var schemaSize = SchemaFieldCount;
 
             if (schemaSize == 0)
@@ -297,10 +312,10 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// <param name="offset">Offset in the array.</param>
         /// <param name="count">Field count to write.</param>
         /// <returns>
-        /// Flags according to offset sizes: <see cref="BinaryObjectHeader.FlagByteOffsets"
/>,
-        /// <see cref="BinaryObjectHeader.FlagShortOffsets" />, or 0.
+        /// Flags according to offset sizes: <see cref="Flag.OffsetOneByte" />,
+        /// <see cref="Flag.OffsetTwoBytes" />, or 0.
         /// </returns>
-        public static unsafe short WriteSchema(BinaryObjectSchemaField[] fields, IBinaryStream
stream, int offset,
+        public static unsafe Flag WriteSchema(BinaryObjectSchemaField[] fields, IBinaryStream
stream, int offset,
             int count)
         {
             Debug.Assert(fields != null);
@@ -324,7 +339,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                         stream.WriteByte((byte)field.Offset);
                     }
 
-                    return FlagByteOffsets;
+                    return Flag.OffsetOneByte;
                 }
 
                 if (maxFieldOffset <= ushort.MaxValue)
@@ -338,7 +353,7 @@ namespace Apache.Ignite.Core.Impl.Binary
                         stream.WriteShort((short)field.Offset);
                     }
 
-                    return FlagShortOffsets;
+                    return Flag.OffsetTwoBytes;
                 }
 
                 if (BitConverter.IsLittleEndian)
@@ -359,9 +374,8 @@ namespace Apache.Ignite.Core.Impl.Binary
                     }
                 }
 
-                return 0;
+                return Flag.None;
             }
-
         }
 
         /// <summary>
@@ -396,24 +410,27 @@ namespace Apache.Ignite.Core.Impl.Binary
 
             stream.Seek(position, SeekOrigin.Begin);
 
+            BinaryObjectHeader hdr;
+
             if (BitConverter.IsLittleEndian)
             {
-                var hdr = new BinaryObjectHeader();
-
                 stream.Read((byte*) &hdr, Size);
 
                 Debug.Assert(hdr.Version == BinaryUtils.ProtoVer);
                 Debug.Assert(hdr.SchemaOffset <= hdr.Length);
                 Debug.Assert(hdr.SchemaOffset >= Size);
 
-                // Only one of the flags can be set
-                var f = hdr.Flags;
-                Debug.Assert((f & (FlagShortOffsets | FlagByteOffsets)) != (FlagShortOffsets
| FlagByteOffsets));
-
-                return hdr;
             }
+            else
+                hdr = new BinaryObjectHeader(stream);
+
+            hdr.ThrowIfUnsupported();
 
-            return new BinaryObjectHeader(stream);
+            // Only one of the flags can be set
+            var f = hdr.Flags;
+            Debug.Assert((f & (Flag.OffsetOneByte | Flag.OffsetTwoBytes)) !=
+                         (Flag.OffsetOneByte | Flag.OffsetTwoBytes));
+            return hdr;
         }
 
         /** <inheritdoc> */
@@ -465,5 +482,15 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             return !left.Equals(right);
         }
+
+        /// <summary>
+        /// Throws an exception if current header represents unsupported mode.
+        /// </summary>
+        private void ThrowIfUnsupported()
+        {
+            // Compact schema is not supported
+            if (IsCompactFooter)
+                throw new NotSupportedException("Compact binary object footer is not supported
in Ignite.NET.");
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff38ae94/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs
index 75ff2c5..65b6fc0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaHolder.cs
@@ -82,22 +82,21 @@ namespace Apache.Ignite.Core.Impl.Binary
         /// <param name="stream">The stream.</param>
         /// <param name="schemaOffset">The schema offset.</param>
         /// <param name="schemaId">The schema identifier.</param>
-        /// <param name="flags">Flags according to offset sizes: <see cref="BinaryObjectHeader.FlagByteOffsets"
/>,
-        /// <see cref="BinaryObjectHeader.FlagShortOffsets" />, or 0.</param>
+        /// <param name="flags">Flags according to offset sizes.</param>
         /// <returns>
         /// True if current schema was non empty; false otherwise.
         /// </returns>
-        public bool WriteSchema(IBinaryStream stream, int schemaOffset, out int schemaId,
out short flags)
+        public bool WriteSchema(IBinaryStream stream, int schemaOffset, out int schemaId,

+            ref BinaryObjectHeader.Flag flags)
         {
             schemaId = Fnv1Hash.Basis;
-            flags = 0;
 
             var count = _idx - schemaOffset;
 
             if (count == 0) 
                 return false;
 
-            flags = BinaryObjectHeader.WriteSchema(_fields, stream, schemaOffset, count);
+            flags |= BinaryObjectHeader.WriteSchema(_fields, stream, schemaOffset, count);
 
             for (var i = schemaOffset; i < _idx; i++)
                 schemaId = Fnv1Hash.Update(schemaId, _fields[i].Id);

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff38ae94/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
index 1dec7ba..ccbb7b8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
@@ -873,7 +873,7 @@ namespace Apache.Ignite.Core.Impl.Binary
             if (_curRaw)
                 throw new BinaryObjectException("Cannot read named fields after raw data
is read.");
 
-            if (_curHdr.IsRawOnly)
+            if (!_curHdr.HasSchema)
                 return false;
 
             var actionId = _curStruct.CurStructAction;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff38ae94/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
index 58973f7..e09a7f4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryWriter.cs
@@ -1090,20 +1090,31 @@ namespace Apache.Ignite.Core.Impl.Binary
                     var schemaOffset = _stream.Position - pos;
 
                     int schemaId;
-                    short flags;
-                    var hasSchema = _schema.WriteSchema(_stream, schemaIdx, out schemaId,
out flags);
+                    
+                    var flags = desc.UserType
+                        ? BinaryObjectHeader.Flag.UserType
+                        : BinaryObjectHeader.Flag.None;
 
-                    if (!hasSchema)
+                    var hasSchema = _schema.WriteSchema(_stream, schemaIdx, out schemaId,
ref flags);
+
+                    if (hasSchema)
+                    {
+                        flags |= BinaryObjectHeader.Flag.HasSchema;
+
+                        // Calculate and write header.
+                        if (_curRawPos > 0)
+                            _stream.WriteInt(_curRawPos - pos); // raw offset is in the last
4 bytes
+                    }
+                    else
                         schemaOffset = BinaryObjectHeader.Size;
 
-                    // Calculate and write header.
-                    if (hasSchema && _curRawPos > 0)
-                        _stream.WriteInt(_curRawPos - pos); // raw offset is in the last
4 bytes
+                    if (_curRawPos > 0)
+                        flags |= BinaryObjectHeader.Flag.HasRaw;
 
                     var len = _stream.Position - pos;
 
-                    var header = new BinaryObjectHeader(desc.UserType, desc.TypeId, obj.GetHashCode(),
len,
-                        schemaId, schemaOffset, !hasSchema, flags);
+                    var header = new BinaryObjectHeader(desc.TypeId, obj.GetHashCode(), len,
+                        schemaId, schemaOffset, flags);
 
                     BinaryObjectHeader.Write(header, _stream, pos);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ff38ae94/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs
index 927ebaf..ecc6807 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/IgniteBinary.cs
@@ -166,7 +166,8 @@ namespace Apache.Ignite.Core.Impl.Binary
         {
             var len = BinaryObjectHeader.Size;
 
-            var hdr = new BinaryObjectHeader(desc.UserType, desc.TypeId, 0, len, 0, len,
true, 0);
+            var hdr = new BinaryObjectHeader(desc.TypeId, 0, len, 0, len,
+                desc.UserType ? BinaryObjectHeader.Flag.UserType : BinaryObjectHeader.Flag.None);
 
             var stream = new BinaryHeapStream(len);
 


Mime
View raw message