You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/11/02 18:21:51 UTC
[03/29] ignite git commit: IGNITE-1835 .Net: Use thread-local pool to
store schemas in PortableWriter
IGNITE-1835 .Net: Use thread-local pool to store schemas in PortableWriter
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/12a4a97d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/12a4a97d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/12a4a97d
Branch: refs/heads/ignite-950-new
Commit: 12a4a97dd322b6de542a048e971adff077b85b9f
Parents: 2cdbb2f
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Mon Nov 2 15:40:42 2015 +0300
Committer: Pavel Tupitsyn <pt...@gridgain.com>
Committed: Mon Nov 2 15:40:42 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.csproj | 1 +
.../Impl/Portable/PortableObjectSchemaField.cs | 7 ++-
.../Impl/Portable/PortableObjectSchemaHolder.cs | 64 ++++++++++++++++++++
3 files changed, 69 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/12a4a97d/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index ffe5d9f..d782aec 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -258,6 +258,7 @@
<Compile Include="Impl\Portable\PortableObjectHeader.cs" />
<Compile Include="Impl\Portable\PortableObjectSchema.cs" />
<Compile Include="Impl\Portable\PortableObjectSchemaField.cs" />
+ <Compile Include="Impl\Portable\PortableObjectSchemaHolder.cs" />
<Compile Include="Impl\Portable\PortableReaderExtensions.cs" />
<Compile Include="Impl\Portable\PortableReaderHandleDictionary.cs" />
<Compile Include="Impl\Portable\PortableReaderImpl.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/12a4a97d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaField.cs
index 48fd9c1..b8ed62f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaField.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaField.cs
@@ -53,8 +53,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
/// <param name="fields">Fields.</param>
/// <param name="stream">Stream.</param>
+ /// <param name="start">Start index.</param>
/// <param name="count">Field count to write.</param>
- public static unsafe void WriteArray(PortableObjectSchemaField[] fields, IPortableStream stream, int count)
+ public static unsafe void WriteArray(PortableObjectSchemaField[] fields, IPortableStream stream, int start, int count)
{
Debug.Assert(fields != null);
Debug.Assert(stream != null);
@@ -64,12 +65,12 @@ namespace Apache.Ignite.Core.Impl.Portable
{
fixed (PortableObjectSchemaField* ptr = &fields[0])
{
- stream.Write((byte*) ptr, count * Size);
+ stream.Write((byte*) ptr + start * Size, count * Size);
}
}
else
{
- for (int i = 0; i < count; i++)
+ for (int i = start; i < count + start; i++)
{
var field = fields[i];
http://git-wip-us.apache.org/repos/asf/ignite/blob/12a4a97d/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
new file mode 100644
index 0000000..daf325c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Portable
+{
+ using System;
+ using System.Diagnostics;
+ using Apache.Ignite.Core.Impl.Portable.IO;
+
+ /// <summary>
+ /// Shared schema holder.
+ /// </summary>
+ internal class PortableObjectSchemaHolder
+ {
+ /** Fields. */
+ private PortableObjectSchemaField[] _fields = new PortableObjectSchemaField[16];
+
+ /** Current field index. */
+ private int _idx = 0;
+
+ /// <summary>
+ /// Adds a field to the holder.
+ /// </summary>
+ /// <param name="id">The identifier.</param>
+ /// <param name="offset">The offset.</param>
+ public void Push(int id, int offset)
+ {
+ if (_idx == _fields.Length)
+ Array.Resize(ref _fields, _fields.Length * 2);
+
+ _fields[_idx] = new PortableObjectSchemaField(id, offset);
+
+ _idx++;
+ }
+
+ /// <summary>
+ /// Writes specified number of collected fields and removes them/
+ /// </summary>
+ /// <param name="stream">The stream.</param>
+ /// <param name="count">The count.</param>
+ public void WriteAndPop(IPortableStream stream, int count)
+ {
+ Debug.Assert(count <= _idx);
+
+ PortableObjectSchemaField.WriteArray(_fields, stream, _idx - count, count);
+
+ _idx -= count;
+ }
+ }
+}