ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [2/4] ignite git commit: wip
Date Mon, 02 Nov 2015 13:02:51 GMT
wip


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

Branch: refs/heads/ignite-1282
Commit: 7f7111da5b1da99a443920952063c3080791adb8
Parents: 208c588
Author: Pavel Tupitsyn <ptupitsyn@gridgain.com>
Authored: Mon Nov 2 15:45:03 2015 +0300
Committer: Pavel Tupitsyn <ptupitsyn@gridgain.com>
Committed: Mon Nov 2 15:45:03 2015 +0300

----------------------------------------------------------------------
 .../Impl/Portable/PortableObjectSchemaHolder.cs | 27 +++++++++++++++-----
 1 file changed, 20 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7f7111da/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 b824f94..0b0cd98 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
@@ -18,7 +18,7 @@
 namespace Apache.Ignite.Core.Impl.Portable
 {
     using System;
-    using System.Diagnostics;
+    using System.Collections.Generic;
     using Apache.Ignite.Core.Impl.Portable.IO;
 
     /// <summary>
@@ -29,6 +29,9 @@ namespace Apache.Ignite.Core.Impl.Portable
         /** Fields. */
         private PortableObjectSchemaField[] _fields = new PortableObjectSchemaField[16];
 
+        /** Offsets for different schemas. */
+        private readonly Stack<int> _offsets = new Stack<int>();
+
         /** Current field index. */
         private int _idx;
 
@@ -48,17 +51,27 @@ namespace Apache.Ignite.Core.Impl.Portable
         }
 
         /// <summary>
-        /// Writes specified number of collected fields and removes them/
+        /// Marks the start of a new schema.
+        /// </summary>
+        public void PushSchema()
+        {
+            _offsets.Push(_idx);
+        }
+
+        /// <summary>
+        /// Writes collected schema to the stream and pops it.
         /// </summary>
         /// <param name="stream">The stream.</param>
-        /// <param name="count">The count.</param>
-        public void WriteAndPop(IPortableStream stream, int count)
+        public void WriteAndPop(IPortableStream stream)
         {
-            Debug.Assert(count <= _idx);
+            var count = _offsets.Pop();
 
-            PortableObjectSchemaField.WriteArray(_fields, stream, _idx - count, count);
+            if (count > 0)
+            {
+                PortableObjectSchemaField.WriteArray(_fields, stream, _idx - count, count);
 
-            _idx -= count;
+                _idx -= count;
+            }
         }
     }
 }


Mime
View raw message