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/11/02 14:02:50 UTC
[1/4] ignite git commit: wip
Repository: ignite
Updated Branches:
refs/heads/ignite-1282 12a4a97dd -> 48b775d1f
wip
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/208c5880
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/208c5880
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/208c5880
Branch: refs/heads/ignite-1282
Commit: 208c5880d5f879775d6bacb98ff587b7bc518036
Parents: 12a4a97
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Mon Nov 2 15:41:12 2015 +0300
Committer: Pavel Tupitsyn <pt...@gridgain.com>
Committed: Mon Nov 2 15:41:12 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/208c5880/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 daf325c..b824f94 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
@@ -30,7 +30,7 @@ namespace Apache.Ignite.Core.Impl.Portable
private PortableObjectSchemaField[] _fields = new PortableObjectSchemaField[16];
/** Current field index. */
- private int _idx = 0;
+ private int _idx;
/// <summary>
/// Adds a field to the holder.
[3/4] ignite git commit: wip Writer
Posted by vo...@apache.org.
wip Writer
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/46d3e046
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/46d3e046
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/46d3e046
Branch: refs/heads/ignite-1282
Commit: 46d3e0464ee57385e1428aee7786f1f939e05481
Parents: 7f7111d
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Mon Nov 2 15:55:45 2015 +0300
Committer: Pavel Tupitsyn <pt...@gridgain.com>
Committed: Mon Nov 2 15:55:45 2015 +0300
----------------------------------------------------------------------
.../Impl/Portable/PortableObjectSchemaHolder.cs | 16 ++++++++++++--
.../Impl/Portable/PortableUtils.cs | 12 +++++------
.../Impl/Portable/PortableWriterImpl.cs | 22 ++++++++------------
3 files changed, 29 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/46d3e046/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 0b0cd98..b66bdcc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableObjectSchemaHolder.cs
@@ -62,16 +62,28 @@ namespace Apache.Ignite.Core.Impl.Portable
/// Writes collected schema to the stream and pops it.
/// </summary>
/// <param name="stream">The stream.</param>
- public void WriteAndPop(IPortableStream stream)
+ /// <param name="schemaId">The schema identifier.</param>
+ /// <returns>True if current schema was non empty; false otherwise.</returns>
+ public bool WriteAndPop(IPortableStream stream, out int schemaId)
{
var count = _offsets.Pop();
if (count > 0)
{
- PortableObjectSchemaField.WriteArray(_fields, stream, _idx - count, count);
+ var startIdx = _idx - count;
+
+ PortableObjectSchemaField.WriteArray(_fields, stream, startIdx, count);
+
+ schemaId = PortableUtils.GetSchemaId(_fields, startIdx, count);
_idx -= count;
+
+ return true;
}
+
+ schemaId = PortableUtils.GetSchemaId(null, 0, 0);
+
+ return false;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/46d3e046/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index a0657b2..46c5707 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -1771,20 +1771,20 @@ namespace Apache.Ignite.Core.Impl.Portable
/// Gets the schema id as a Fnv1 hash.
/// </summary>
/// <param name="schema">The schema.</param>
+ /// <param name="start">Start index.</param>
+ /// <param name="count">Count.</param>
/// <returns>
/// Schema id.
/// </returns>
- public static int GetSchemaId(ResizeableArray<PortableObjectSchemaField> schema)
+ public static int GetSchemaId(PortableObjectSchemaField[] schema, int start, int count)
{
var hash = Fnv1Hash.Basis;
- if (schema == null || schema.Count == 0)
+ if (schema == null || schema.Length == 0)
return hash;
- var arr = schema.Array;
-
- for (int i = 0; i < schema.Count; i++)
- hash = Fnv1Hash.Update(hash, arr[i].Id);
+ for (int i = start; i < count; i++)
+ hash = Fnv1Hash.Update(hash, schema[i].Id);
return hash;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/46d3e046/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 e17449d..b24b40d 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,7 @@ namespace Apache.Ignite.Core.Impl.Portable
using System.Collections;
using System.Collections.Generic;
using System.IO;
- using Apache.Ignite.Core.Impl.Common;
+ using System.Threading;
using Apache.Ignite.Core.Impl.Portable.IO;
using Apache.Ignite.Core.Impl.Portable.Metadata;
using Apache.Ignite.Core.Impl.Portable.Structure;
@@ -71,7 +71,8 @@ namespace Apache.Ignite.Core.Impl.Portable
private PortableStructureTracker _curStruct;
/** Current schema. */
- private ResizeableArray<PortableObjectSchemaField> _curSchema;
+ private ThreadLocal<PortableObjectSchemaHolder> _schema =
+ new ThreadLocal<PortableObjectSchemaHolder>(() => new PortableObjectSchemaHolder());
/// <summary>
@@ -1074,7 +1075,6 @@ namespace Apache.Ignite.Core.Impl.Portable
var oldPos = _curPos;
var oldStruct = _curStruct;
- var oldSchema = _curSchema;
// Push new frame.
_curTypeId = desc.TypeId;
@@ -1084,17 +1084,16 @@ namespace Apache.Ignite.Core.Impl.Portable
_curPos = pos;
_curStruct = new PortableStructureTracker(desc, desc.WriterTypeStructure);
- _curSchema = null;
+ _schema.Value.PushSchema();
// Write object fields.
desc.Serializer.WritePortable(obj, this);
// Write schema
- var hasSchema = _curSchema != null;
- var schemaOffset = hasSchema ? _stream.Position - pos : PortableObjectHeader.Size;
+ int schemaId;
+ var hasSchema = _schema.Value.WriteAndPop(_stream, out schemaId);
- if (hasSchema)
- PortableObjectSchemaField.WriteArray(_curSchema.Array, _stream, _curSchema.Count);
+ var schemaOffset = hasSchema ? _stream.Position - pos : PortableObjectHeader.Size;
// Calculate and write header.
if (hasSchema && _curRawPos > 0)
@@ -1103,7 +1102,7 @@ namespace Apache.Ignite.Core.Impl.Portable
var len = _stream.Position - pos;
var header = new PortableObjectHeader(desc.UserType, desc.TypeId, obj.GetHashCode(), len,
- PU.GetSchemaId(_curSchema), schemaOffset, !hasSchema);
+ schemaId, schemaOffset, !hasSchema);
PortableObjectHeader.Write(header, _stream, pos);
@@ -1120,7 +1119,6 @@ namespace Apache.Ignite.Core.Impl.Portable
_curPos = oldPos;
_curStruct = oldStruct;
- _curSchema = oldSchema;
}
else
{
@@ -1372,9 +1370,7 @@ namespace Apache.Ignite.Core.Impl.Portable
var fieldId = _curStruct.GetFieldId(fieldName, fieldTypeId);
- _curSchema = _curSchema ?? new ResizeableArray<PortableObjectSchemaField>(4);
-
- _curSchema.Add(new PortableObjectSchemaField(fieldId, _stream.Position - _curPos));
+ _schema.Value.Push(fieldId, _stream.Position - _curPos);
}
/// <summary>
[2/4] ignite git commit: wip
Posted by vo...@apache.org.
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 <pt...@gridgain.com>
Authored: Mon Nov 2 15:45:03 2015 +0300
Committer: Pavel Tupitsyn <pt...@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;
+ }
}
}
}
[4/4] ignite git commit: Builder done
Posted by vo...@apache.org.
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-1282
Commit: 48b775d1fee0ca8868469ad01f6f192e3c1677fe
Parents: 46d3e04
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Mon Nov 2 16:02:38 2015 +0300
Committer: Pavel Tupitsyn <pt...@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>