ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [07/29] ignite git commit: Builder done
Date Mon, 02 Nov 2015 17:21:55 GMT
Builder done


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

Branch: refs/heads/ignite-950-new
Commit: 48b775d1fee0ca8868469ad01f6f192e3c1677fe
Parents: 46d3e04
Author: Pavel Tupitsyn <ptupitsyn@gridgain.com>
Authored: Mon Nov 2 16:02:38 2015 +0300
Committer: Pavel Tupitsyn <ptupitsyn@gridgain.com>
Committed: Mon Nov 2 16:02:38 2015 +0300

----------------------------------------------------------------------
 .../Impl/Portable/PortableBuilderImpl.cs        | 30 ++++++++------------
 .../Impl/Portable/PortableObjectSchemaHolder.cs | 13 +++++++++
 .../Impl/Portable/PortableWriterImpl.cs         | 12 ++------
 3 files changed, 28 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/48b775d1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
index 08a1d00..f18f4f5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
@@ -23,7 +23,6 @@ namespace Apache.Ignite.Core.Impl.Portable
     using System.Diagnostics;
     using System.IO;
     using Apache.Ignite.Core.Common;
-    using Apache.Ignite.Core.Impl.Common;
     using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Portable.Metadata;
     using Apache.Ignite.Core.Portable;
@@ -569,7 +568,7 @@ namespace Apache.Ignite.Core.Impl.Portable
         /// <param name="hash">New hash.</param>
         /// <param name="vals">Values to be replaced.</param>
         /// <returns>Mutated object.</returns>
-        private unsafe void Mutate0(Context ctx, PortableHeapStream inStream, IPortableStream
outStream,
+        private void Mutate0(Context ctx, PortableHeapStream inStream, IPortableStream outStream,
             bool changeHash, int hash, IDictionary<int, PortableBuilderField> vals)
         {
             int inStartPos = inStream.Position;
@@ -626,10 +625,7 @@ namespace Apache.Ignite.Core.Impl.Portable
                         // New object, write in full form.
                         var inSchema = inHeader.ReadSchema(inStream, inStartPos);
 
-                        var outSchemaLen = vals.Count + (inSchema == null ? 0 : inSchema.Length);
-                        var outSchema = outSchemaLen > 0 
-                            ? new ResizeableArray<PortableObjectSchemaField>(outSchemaLen)
-                            : null;
+                        PortableObjectSchemaHolder.Current.PushSchema();
 
                         // Skip header as it is not known at this point.
                         outStream.Seek(PortableObjectHeader.Size, SeekOrigin.Current);
@@ -646,7 +642,7 @@ namespace Apache.Ignite.Core.Impl.Portable
                                     continue;
 
                                 // ReSharper disable once PossibleNullReferenceException
(can't be null)
-                                outSchema.Add(new PortableObjectSchemaField(inField.Id, outStream.Position
- outStartPos));
+                                PortableObjectSchemaHolder.Current.Push(inField.Id, outStream.Position
- outStartPos);
 
                                 if (!fieldFound)
                                     fieldFound = _parent._cache != null &&
@@ -675,14 +671,11 @@ namespace Apache.Ignite.Core.Impl.Portable
                                 continue;
 
                             // ReSharper disable once PossibleNullReferenceException (can't
be null)
-                            outSchema.Add(new PortableObjectSchemaField(valEntry.Key, outStream.Position
- outStartPos));
+                            PortableObjectSchemaHolder.Current.Push(valEntry.Key, outStream.Position
- outStartPos);
 
                             WriteField(ctx, valEntry.Value);
                         }
 
-                        if (outSchema != null && outSchema.Count == 0)
-                            outSchema = null;
-
                         // Write raw data.
                         int outRawOff = outStream.Position - outStartPos;
 
@@ -695,24 +688,25 @@ namespace Apache.Ignite.Core.Impl.Portable
                         // Write schema
                         int outSchemaOff = outRawOff;
 
-                        if (outSchema != null)
-                        {
-                            outSchemaOff = outStream.Position - outStartPos;
+                        int schemaPos = outStream.Position;
 
-                            PortableObjectSchemaField.WriteArray(outSchema.Array, outStream,
outSchema.Count);
+                        int outSchemaId;
+                        var hasSchema = PortableObjectSchemaHolder.Current.WriteAndPop(outStream,
out outSchemaId);
+
+                        if (hasSchema)
+                        {
+                            outSchemaOff = schemaPos - outStartPos;
 
                             if (inRawLen > 0)
                                 outStream.WriteInt(outRawOff);
                         }
 
-                        var outSchemaId = PortableUtils.GetSchemaId(outSchema);
-
                         var outLen = outStream.Position - outStartPos;
 
                         var outHash = changeHash ? hash : inHeader.HashCode;
 
                         var outHeader = new PortableObjectHeader(inHeader.IsUserType, inHeader.TypeId,
outHash, 
-                            outLen, outSchemaId, outSchemaOff, outSchema == null);
+                            outLen, outSchemaId, outSchemaOff, !hasSchema);
 
                         PortableObjectHeader.Write(outHeader, outStream, outStartPos);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/48b775d1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
index b66bdcc..f577458 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Portable
 {
     using System;
     using System.Collections.Generic;
+    using System.Threading;
     using Apache.Ignite.Core.Impl.Portable.IO;
 
     /// <summary>
@@ -26,6 +27,10 @@ namespace Apache.Ignite.Core.Impl.Portable
     /// </summary>
     internal class PortableObjectSchemaHolder
     {
+        /** Current schema. */
+        private static readonly ThreadLocal<PortableObjectSchemaHolder> CurrentHolder
=
+            new ThreadLocal<PortableObjectSchemaHolder>(() => new PortableObjectSchemaHolder());
+
         /** Fields. */
         private PortableObjectSchemaField[] _fields = new PortableObjectSchemaField[16];
 
@@ -36,6 +41,14 @@ namespace Apache.Ignite.Core.Impl.Portable
         private int _idx;
 
         /// <summary>
+        /// Gets the schema holder for the current thread.
+        /// </summary>
+        public static PortableObjectSchemaHolder Current
+        {
+            get { return CurrentHolder.Value; }
+        }
+
+        /// <summary>
         /// Adds a field to the holder.
         /// </summary>
         /// <param name="id">The identifier.</param>

http://git-wip-us.apache.org/repos/asf/ignite/blob/48b775d1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
index b24b40d..a4ddc51 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
@@ -21,7 +21,6 @@ namespace Apache.Ignite.Core.Impl.Portable
     using System.Collections;
     using System.Collections.Generic;
     using System.IO;
-    using System.Threading;
     using Apache.Ignite.Core.Impl.Portable.IO;
     using Apache.Ignite.Core.Impl.Portable.Metadata;
     using Apache.Ignite.Core.Impl.Portable.Structure;
@@ -70,11 +69,6 @@ namespace Apache.Ignite.Core.Impl.Portable
         /** Current type structure tracker, */
         private PortableStructureTracker _curStruct;
 
-        /** Current schema. */
-        private ThreadLocal<PortableObjectSchemaHolder> _schema =
-            new ThreadLocal<PortableObjectSchemaHolder>(() => new PortableObjectSchemaHolder());
-
-
         /// <summary>
         /// Gets the marshaller.
         /// </summary>
@@ -1084,14 +1078,14 @@ namespace Apache.Ignite.Core.Impl.Portable
                 _curPos = pos;
 
                 _curStruct = new PortableStructureTracker(desc, desc.WriterTypeStructure);
-                _schema.Value.PushSchema();
+                PortableObjectSchemaHolder.Current.PushSchema();
 
                 // Write object fields.
                 desc.Serializer.WritePortable(obj, this);
 
                 // Write schema
                 int schemaId;
-                var hasSchema = _schema.Value.WriteAndPop(_stream, out schemaId);
+                var hasSchema = PortableObjectSchemaHolder.Current.WriteAndPop(_stream, out
schemaId);
 
                 var schemaOffset = hasSchema ? _stream.Position - pos : PortableObjectHeader.Size;
 
@@ -1370,7 +1364,7 @@ namespace Apache.Ignite.Core.Impl.Portable
 
             var fieldId = _curStruct.GetFieldId(fieldName, fieldTypeId);
 
-            _schema.Value.Push(fieldId, _stream.Position - _curPos);
+            PortableObjectSchemaHolder.Current.Push(fieldId, _stream.Position - _curPos);
         }
 
         /// <summary>


Mime
View raw message