Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2DCB8200CF7 for ; Mon, 4 Sep 2017 10:14:12 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 2C833163980; Mon, 4 Sep 2017 08:14:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E1411163976 for ; Mon, 4 Sep 2017 10:14:09 +0200 (CEST) Received: (qmail 25160 invoked by uid 500); 4 Sep 2017 08:14:09 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 24963 invoked by uid 99); 4 Sep 2017 08:14:08 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Sep 2017 08:14:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AC5A1F5614; Mon, 4 Sep 2017 08:14:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Mon, 04 Sep 2017 08:14:12 -0000 Message-Id: In-Reply-To: <4ac72154dd764147b68a74eef20ca4c7@git.apache.org> References: <4ac72154dd764147b68a74eef20ca4c7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [06/13] ignite git commit: IGNITE-6233 .NET: Extract type codes to a separate class archived-at: Mon, 04 Sep 2017 08:14:12 -0000 IGNITE-6233 .NET: Extract type codes to a separate class This closes #2570 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/55e0b5c9 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/55e0b5c9 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/55e0b5c9 Branch: refs/heads/ignite-3478 Commit: 55e0b5c9bf3b0b12ed930dbffea8e5bfced1ef18 Parents: 5738d7e Author: Pavel Tupitsyn Authored: Fri Sep 1 11:49:48 2017 +0300 Committer: Pavel Tupitsyn Committed: Fri Sep 1 11:49:48 2017 +0300 ---------------------------------------------------------------------- .../Apache.Ignite.Core.csproj | 1 + .../Impl/Binary/BinaryObjectBuilder.cs | 132 +++++------ .../Impl/Binary/BinaryObjectSchemaSerializer.cs | 2 +- .../Impl/Binary/BinaryProcessor.cs | 2 +- .../Impl/Binary/BinaryReader.cs | 110 ++++----- .../Impl/Binary/BinarySystemHandlers.cs | 157 ++++--------- .../Impl/Binary/BinaryTypeId.cs | 228 +++++++++++++++++++ .../Impl/Binary/BinaryUtils.cs | 155 +------------ .../Impl/Binary/BinaryWriter.cs | 152 ++++++------- .../Impl/Binary/Marshaller.cs | 28 +-- .../Impl/Binary/Metadata/BinaryType.cs | 62 ++--- 11 files changed, 528 insertions(+), 501 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/55e0b5c9/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 ee301be..241e1c6 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj @@ -99,6 +99,7 @@ + http://git-wip-us.apache.org/repos/asf/ignite/blob/55e0b5c9/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 c310b3a..fac7d18 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectBuilder.cs @@ -124,209 +124,209 @@ namespace Apache.Ignite.Core.Impl.Binary public IBinaryObjectBuilder SetField(string fieldName, T val) { return SetField0(fieldName, - new BinaryBuilderField(typeof (T), val, BinarySystemHandlers.GetTypeId(typeof (T)))); + new BinaryBuilderField(typeof (T), val, BinaryTypeId.GetTypeId(typeof (T)))); } /** */ public IBinaryObjectBuilder SetArrayField(string fieldName, T[] val) { return SetField0(fieldName, - new BinaryBuilderField(typeof (T[]), val, BinaryUtils.TypeArray, WriteArrayAction)); + new BinaryBuilderField(typeof (T[]), val, BinaryTypeId.Array, WriteArrayAction)); } /** */ public IBinaryObjectBuilder SetBooleanField(string fieldName, bool val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (bool), val, BinaryUtils.TypeBool, + return SetField0(fieldName, new BinaryBuilderField(typeof (bool), val, BinaryTypeId.Bool, (w, o) => w.WriteBooleanField((bool) o))); } /** */ public IBinaryObjectBuilder SetBooleanArrayField(string fieldName, bool[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (bool[]), val, BinaryUtils.TypeArrayBool, + return SetField0(fieldName, new BinaryBuilderField(typeof (bool[]), val, BinaryTypeId.ArrayBool, (w, o) => w.WriteBooleanArray((bool[]) o))); } /** */ public IBinaryObjectBuilder SetByteField(string fieldName, byte val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (byte), val, BinaryUtils.TypeByte, + return SetField0(fieldName, new BinaryBuilderField(typeof (byte), val, BinaryTypeId.Byte, (w, o) => w.WriteByteField((byte) o))); } /** */ public IBinaryObjectBuilder SetByteArrayField(string fieldName, byte[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (byte[]), val, BinaryUtils.TypeArrayByte, + return SetField0(fieldName, new BinaryBuilderField(typeof (byte[]), val, BinaryTypeId.ArrayByte, (w, o) => w.WriteByteArray((byte[]) o))); } /** */ public IBinaryObjectBuilder SetCharField(string fieldName, char val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (char), val, BinaryUtils.TypeChar, + return SetField0(fieldName, new BinaryBuilderField(typeof (char), val, BinaryTypeId.Char, (w, o) => w.WriteCharField((char) o))); } /** */ public IBinaryObjectBuilder SetCharArrayField(string fieldName, char[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (char[]), val, BinaryUtils.TypeArrayChar, + return SetField0(fieldName, new BinaryBuilderField(typeof (char[]), val, BinaryTypeId.ArrayChar, (w, o) => w.WriteCharArray((char[]) o))); } /** */ public IBinaryObjectBuilder SetCollectionField(string fieldName, ICollection val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (ICollection), val, BinaryUtils.TypeCollection, + return SetField0(fieldName, new BinaryBuilderField(typeof (ICollection), val, BinaryTypeId.Collection, WriteCollectionAction)); } /** */ public IBinaryObjectBuilder SetDecimalField(string fieldName, decimal? val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (decimal?), val, BinaryUtils.TypeDecimal, + return SetField0(fieldName, new BinaryBuilderField(typeof (decimal?), val, BinaryTypeId.Decimal, (w, o) => w.WriteDecimal((decimal?) o))); } /** */ public IBinaryObjectBuilder SetDecimalArrayField(string fieldName, decimal?[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (decimal?[]), val, BinaryUtils.TypeArrayDecimal, + return SetField0(fieldName, new BinaryBuilderField(typeof (decimal?[]), val, BinaryTypeId.ArrayDecimal, (w, o) => w.WriteDecimalArray((decimal?[]) o))); } /** */ public IBinaryObjectBuilder SetDictionaryField(string fieldName, IDictionary val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (IDictionary), val, BinaryUtils.TypeDictionary, + return SetField0(fieldName, new BinaryBuilderField(typeof (IDictionary), val, BinaryTypeId.Dictionary, (w, o) => w.WriteDictionary((IDictionary) o))); } /** */ public IBinaryObjectBuilder SetDoubleField(string fieldName, double val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (double), val, BinaryUtils.TypeDouble, + return SetField0(fieldName, new BinaryBuilderField(typeof (double), val, BinaryTypeId.Double, (w, o) => w.WriteDoubleField((double) o))); } /** */ public IBinaryObjectBuilder SetDoubleArrayField(string fieldName, double[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (double[]), val, BinaryUtils.TypeArrayDouble, + return SetField0(fieldName, new BinaryBuilderField(typeof (double[]), val, BinaryTypeId.ArrayDouble, (w, o) => w.WriteDoubleArray((double[]) o))); } /** */ public IBinaryObjectBuilder SetEnumField(string fieldName, T val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (T), val, BinaryUtils.TypeEnum, + return SetField0(fieldName, new BinaryBuilderField(typeof (T), val, BinaryTypeId.Enum, (w, o) => w.WriteEnum((T) o))); } /** */ public IBinaryObjectBuilder SetEnumArrayField(string fieldName, T[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (T[]), val, BinaryUtils.TypeArrayEnum, + return SetField0(fieldName, new BinaryBuilderField(typeof (T[]), val, BinaryTypeId.ArrayEnum, (w, o) => w.WriteEnumArray((T[]) o))); } /** */ public IBinaryObjectBuilder SetFloatField(string fieldName, float val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (float), val, BinaryUtils.TypeFloat, + return SetField0(fieldName, new BinaryBuilderField(typeof (float), val, BinaryTypeId.Float, (w, o) => w.WriteFloatField((float) o))); } /** */ public IBinaryObjectBuilder SetFloatArrayField(string fieldName, float[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (float[]), val, BinaryUtils.TypeArrayFloat, + return SetField0(fieldName, new BinaryBuilderField(typeof (float[]), val, BinaryTypeId.ArrayFloat, (w, o) => w.WriteFloatArray((float[]) o))); } /** */ public IBinaryObjectBuilder SetGuidField(string fieldName, Guid? val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (Guid?), val, BinaryUtils.TypeGuid, + return SetField0(fieldName, new BinaryBuilderField(typeof (Guid?), val, BinaryTypeId.Guid, (w, o) => w.WriteGuid((Guid?) o))); } /** */ public IBinaryObjectBuilder SetGuidArrayField(string fieldName, Guid?[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (Guid?[]), val, BinaryUtils.TypeArrayGuid, + return SetField0(fieldName, new BinaryBuilderField(typeof (Guid?[]), val, BinaryTypeId.ArrayGuid, (w, o) => w.WriteGuidArray((Guid?[]) o))); } /** */ public IBinaryObjectBuilder SetIntField(string fieldName, int val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (int), val, BinaryUtils.TypeInt, + return SetField0(fieldName, new BinaryBuilderField(typeof (int), val, BinaryTypeId.Int, (w, o) => w.WriteIntField((int) o))); } /** */ public IBinaryObjectBuilder SetIntArrayField(string fieldName, int[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (int[]), val, BinaryUtils.TypeArrayInt, + return SetField0(fieldName, new BinaryBuilderField(typeof (int[]), val, BinaryTypeId.ArrayInt, (w, o) => w.WriteIntArray((int[]) o))); } /** */ public IBinaryObjectBuilder SetLongField(string fieldName, long val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (long), val, BinaryUtils.TypeLong, + return SetField0(fieldName, new BinaryBuilderField(typeof (long), val, BinaryTypeId.Long, (w, o) => w.WriteLongField((long) o))); } /** */ public IBinaryObjectBuilder SetLongArrayField(string fieldName, long[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (long[]), val, BinaryUtils.TypeArrayLong, + return SetField0(fieldName, new BinaryBuilderField(typeof (long[]), val, BinaryTypeId.ArrayLong, (w, o) => w.WriteLongArray((long[]) o))); } /** */ public IBinaryObjectBuilder SetShortField(string fieldName, short val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (short), val, BinaryUtils.TypeShort, + return SetField0(fieldName, new BinaryBuilderField(typeof (short), val, BinaryTypeId.Short, (w, o) => w.WriteShortField((short) o))); } /** */ public IBinaryObjectBuilder SetShortArrayField(string fieldName, short[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (short[]), val, BinaryUtils.TypeArrayShort, + return SetField0(fieldName, new BinaryBuilderField(typeof (short[]), val, BinaryTypeId.ArrayShort, (w, o) => w.WriteShortArray((short[]) o))); } /** */ public IBinaryObjectBuilder SetStringField(string fieldName, string val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (string), val, BinaryUtils.TypeString, + return SetField0(fieldName, new BinaryBuilderField(typeof (string), val, BinaryTypeId.String, (w, o) => w.WriteString((string) o))); } /** */ public IBinaryObjectBuilder SetStringArrayField(string fieldName, string[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (string[]), val, BinaryUtils.TypeArrayString, + return SetField0(fieldName, new BinaryBuilderField(typeof (string[]), val, BinaryTypeId.ArrayString, (w, o) => w.WriteStringArray((string[]) o))); } /** */ public IBinaryObjectBuilder SetTimestampField(string fieldName, DateTime? val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (DateTime?), val, BinaryUtils.TypeTimestamp, + return SetField0(fieldName, new BinaryBuilderField(typeof (DateTime?), val, BinaryTypeId.Timestamp, WriteTimestampAction)); } /** */ public IBinaryObjectBuilder SetTimestampArrayField(string fieldName, DateTime?[] val) { - return SetField0(fieldName, new BinaryBuilderField(typeof (DateTime?[]), val, BinaryUtils.TypeArrayTimestamp, + return SetField0(fieldName, new BinaryBuilderField(typeof (DateTime?[]), val, BinaryTypeId.ArrayTimestamp, WriteTimestampArrayAction)); } @@ -440,19 +440,19 @@ namespace Apache.Ignite.Core.Impl.Binary switch (header) { - case BinaryUtils.TypeArray: + case BinaryTypeId.Array: return WriteArrayAction; - case BinaryUtils.TypeCollection: + case BinaryTypeId.Collection: return WriteCollectionAction; - case BinaryUtils.TypeTimestamp: + case BinaryTypeId.Timestamp: return WriteTimestampAction; - case BinaryUtils.TypeArrayTimestamp: + case BinaryTypeId.ArrayTimestamp: return WriteTimestampArrayAction; - case BinaryUtils.TypeArrayEnum: + case BinaryTypeId.ArrayEnum: using (var stream = new BinaryHeapStream(_obj.Data)) { stream.Seek(pos, SeekOrigin.Begin + 1); @@ -826,47 +826,47 @@ namespace Apache.Ignite.Core.Impl.Binary { switch (hdr) { - case BinaryUtils.TypeByte: + case BinaryTypeId.Byte: TransferBytes(inStream, outStream, 1); break; - case BinaryUtils.TypeShort: + case BinaryTypeId.Short: TransferBytes(inStream, outStream, 2); break; - case BinaryUtils.TypeInt: + case BinaryTypeId.Int: TransferBytes(inStream, outStream, 4); break; - case BinaryUtils.TypeLong: + case BinaryTypeId.Long: TransferBytes(inStream, outStream, 8); break; - case BinaryUtils.TypeFloat: + case BinaryTypeId.Float: TransferBytes(inStream, outStream, 4); break; - case BinaryUtils.TypeDouble: + case BinaryTypeId.Double: TransferBytes(inStream, outStream, 8); break; - case BinaryUtils.TypeChar: + case BinaryTypeId.Char: TransferBytes(inStream, outStream, 2); break; - case BinaryUtils.TypeBool: + case BinaryTypeId.Bool: TransferBytes(inStream, outStream, 1); break; - case BinaryUtils.TypeDecimal: + case BinaryTypeId.Decimal: TransferBytes(inStream, outStream, 4); // Transfer scale int magLen = inStream.ReadInt(); // Transfer magnitude length. @@ -877,65 +877,65 @@ namespace Apache.Ignite.Core.Impl.Binary break; - case BinaryUtils.TypeString: + case BinaryTypeId.String: BinaryUtils.WriteString(BinaryUtils.ReadString(inStream), outStream); break; - case BinaryUtils.TypeGuid: + case BinaryTypeId.Guid: TransferBytes(inStream, outStream, 16); break; - case BinaryUtils.TypeTimestamp: + case BinaryTypeId.Timestamp: TransferBytes(inStream, outStream, 12); break; - case BinaryUtils.TypeArrayByte: + case BinaryTypeId.ArrayByte: TransferArray(inStream, outStream, 1); break; - case BinaryUtils.TypeArrayShort: + case BinaryTypeId.ArrayShort: TransferArray(inStream, outStream, 2); break; - case BinaryUtils.TypeArrayInt: + case BinaryTypeId.ArrayInt: TransferArray(inStream, outStream, 4); break; - case BinaryUtils.TypeArrayLong: + case BinaryTypeId.ArrayLong: TransferArray(inStream, outStream, 8); break; - case BinaryUtils.TypeArrayFloat: + case BinaryTypeId.ArrayFloat: TransferArray(inStream, outStream, 4); break; - case BinaryUtils.TypeArrayDouble: + case BinaryTypeId.ArrayDouble: TransferArray(inStream, outStream, 8); break; - case BinaryUtils.TypeArrayChar: + case BinaryTypeId.ArrayChar: TransferArray(inStream, outStream, 2); break; - case BinaryUtils.TypeArrayBool: + case BinaryTypeId.ArrayBool: TransferArray(inStream, outStream, 1); break; - case BinaryUtils.TypeArrayDecimal: - case BinaryUtils.TypeArrayString: - case BinaryUtils.TypeArrayGuid: - case BinaryUtils.TypeArrayTimestamp: + case BinaryTypeId.ArrayDecimal: + case BinaryTypeId.ArrayString: + case BinaryTypeId.ArrayGuid: + case BinaryTypeId.ArrayTimestamp: int arrLen = inStream.ReadInt(); outStream.WriteInt(arrLen); @@ -945,13 +945,13 @@ namespace Apache.Ignite.Core.Impl.Binary break; - case BinaryUtils.TypeArrayEnum: - case BinaryUtils.TypeArray: + case BinaryTypeId.ArrayEnum: + case BinaryTypeId.Array: int type = inStream.ReadInt(); outStream.WriteInt(type); - if (type == BinaryUtils.TypeUnregistered) + if (type == BinaryTypeId.Unregistered) { outStream.WriteByte(inStream.ReadByte()); // String header. @@ -967,7 +967,7 @@ namespace Apache.Ignite.Core.Impl.Binary break; - case BinaryUtils.TypeCollection: + case BinaryTypeId.Collection: int colLen = inStream.ReadInt(); outStream.WriteInt(colLen); @@ -979,7 +979,7 @@ namespace Apache.Ignite.Core.Impl.Binary break; - case BinaryUtils.TypeDictionary: + case BinaryTypeId.Dictionary: int dictLen = inStream.ReadInt(); outStream.WriteInt(dictLen); @@ -994,13 +994,13 @@ namespace Apache.Ignite.Core.Impl.Binary break; - case BinaryUtils.TypeBinary: + case BinaryTypeId.Binary: TransferArray(inStream, outStream, 1); // Data array. TransferBytes(inStream, outStream, 4); // Offset in array. break; - case BinaryUtils.TypeEnum: + case BinaryTypeId.Enum: TransferBytes(inStream, outStream, 8); // int typeId, int value. break; http://git-wip-us.apache.org/repos/asf/ignite/blob/55e0b5c9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaSerializer.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaSerializer.cs index 2f66f66..0a1b2d1 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaSerializer.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryObjectSchemaSerializer.cs @@ -254,7 +254,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// private static int[] GetFieldIds(BinaryObjectHeader hdr, IIgniteInternal ignite) { - Debug.Assert(hdr.TypeId != BinaryUtils.TypeUnregistered); + Debug.Assert(hdr.TypeId != BinaryTypeId.Unregistered); int[] fieldIds = null; http://git-wip-us.apache.org/repos/asf/ignite/blob/55e0b5c9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs index 69056b3..26b3f15 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryProcessor.cs @@ -183,7 +183,7 @@ namespace Apache.Ignite.Core.Impl.Binary public bool RegisterType(int id, string typeName) { Debug.Assert(typeName != null); - Debug.Assert(id != BinaryUtils.TypeUnregistered); + Debug.Assert(id != BinaryTypeId.Unregistered); return DoOutOp((int) Op.RegisterType, w => { http://git-wip-us.apache.org/repos/asf/ignite/blob/55e0b5c9/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 76237c4..c0fcc7f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs @@ -98,7 +98,7 @@ namespace Apache.Ignite.Core.Impl.Binary /** */ public bool ReadBoolean(string fieldName) { - return ReadField(fieldName, r => r.ReadBoolean(), BinaryUtils.TypeBool); + return ReadField(fieldName, r => r.ReadBoolean(), BinaryTypeId.Bool); } /** */ @@ -110,19 +110,19 @@ namespace Apache.Ignite.Core.Impl.Binary /** */ public bool[] ReadBooleanArray(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadBooleanArray, BinaryUtils.TypeArrayBool); + return ReadField(fieldName, BinaryUtils.ReadBooleanArray, BinaryTypeId.ArrayBool); } /** */ public bool[] ReadBooleanArray() { - return Read(BinaryUtils.ReadBooleanArray, BinaryUtils.TypeArrayBool); + return Read(BinaryUtils.ReadBooleanArray, BinaryTypeId.ArrayBool); } /** */ public byte ReadByte(string fieldName) { - return ReadField(fieldName, ReadByte, BinaryUtils.TypeByte); + return ReadField(fieldName, ReadByte, BinaryTypeId.Byte); } /** */ @@ -134,19 +134,19 @@ namespace Apache.Ignite.Core.Impl.Binary /** */ public byte[] ReadByteArray(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadByteArray, BinaryUtils.TypeArrayByte); + return ReadField(fieldName, BinaryUtils.ReadByteArray, BinaryTypeId.ArrayByte); } /** */ public byte[] ReadByteArray() { - return Read(BinaryUtils.ReadByteArray, BinaryUtils.TypeArrayByte); + return Read(BinaryUtils.ReadByteArray, BinaryTypeId.ArrayByte); } /** */ public short ReadShort(string fieldName) { - return ReadField(fieldName, ReadShort, BinaryUtils.TypeShort); + return ReadField(fieldName, ReadShort, BinaryTypeId.Short); } /** */ @@ -158,19 +158,19 @@ namespace Apache.Ignite.Core.Impl.Binary /** */ public short[] ReadShortArray(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadShortArray, BinaryUtils.TypeArrayShort); + return ReadField(fieldName, BinaryUtils.ReadShortArray, BinaryTypeId.ArrayShort); } /** */ public short[] ReadShortArray() { - return Read(BinaryUtils.ReadShortArray, BinaryUtils.TypeArrayShort); + return Read(BinaryUtils.ReadShortArray, BinaryTypeId.ArrayShort); } /** */ public char ReadChar(string fieldName) { - return ReadField(fieldName, ReadChar, BinaryUtils.TypeChar); + return ReadField(fieldName, ReadChar, BinaryTypeId.Char); } /** */ @@ -182,19 +182,19 @@ namespace Apache.Ignite.Core.Impl.Binary /** */ public char[] ReadCharArray(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadCharArray, BinaryUtils.TypeArrayChar); + return ReadField(fieldName, BinaryUtils.ReadCharArray, BinaryTypeId.ArrayChar); } /** */ public char[] ReadCharArray() { - return Read(BinaryUtils.ReadCharArray, BinaryUtils.TypeArrayChar); + return Read(BinaryUtils.ReadCharArray, BinaryTypeId.ArrayChar); } /** */ public int ReadInt(string fieldName) { - return ReadField(fieldName, ReadInt, BinaryUtils.TypeInt); + return ReadField(fieldName, ReadInt, BinaryTypeId.Int); } /** */ @@ -206,19 +206,19 @@ namespace Apache.Ignite.Core.Impl.Binary /** */ public int[] ReadIntArray(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadIntArray, BinaryUtils.TypeArrayInt); + return ReadField(fieldName, BinaryUtils.ReadIntArray, BinaryTypeId.ArrayInt); } /** */ public int[] ReadIntArray() { - return Read(BinaryUtils.ReadIntArray, BinaryUtils.TypeArrayInt); + return Read(BinaryUtils.ReadIntArray, BinaryTypeId.ArrayInt); } /** */ public long ReadLong(string fieldName) { - return ReadField(fieldName, ReadLong, BinaryUtils.TypeLong); + return ReadField(fieldName, ReadLong, BinaryTypeId.Long); } /** */ @@ -230,19 +230,19 @@ namespace Apache.Ignite.Core.Impl.Binary /** */ public long[] ReadLongArray(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadLongArray, BinaryUtils.TypeArrayLong); + return ReadField(fieldName, BinaryUtils.ReadLongArray, BinaryTypeId.ArrayLong); } /** */ public long[] ReadLongArray() { - return Read(BinaryUtils.ReadLongArray, BinaryUtils.TypeArrayLong); + return Read(BinaryUtils.ReadLongArray, BinaryTypeId.ArrayLong); } /** */ public float ReadFloat(string fieldName) { - return ReadField(fieldName, ReadFloat, BinaryUtils.TypeFloat); + return ReadField(fieldName, ReadFloat, BinaryTypeId.Float); } /** */ @@ -254,19 +254,19 @@ namespace Apache.Ignite.Core.Impl.Binary /** */ public float[] ReadFloatArray(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadFloatArray, BinaryUtils.TypeArrayFloat); + return ReadField(fieldName, BinaryUtils.ReadFloatArray, BinaryTypeId.ArrayFloat); } /** */ public float[] ReadFloatArray() { - return Read(BinaryUtils.ReadFloatArray, BinaryUtils.TypeArrayFloat); + return Read(BinaryUtils.ReadFloatArray, BinaryTypeId.ArrayFloat); } /** */ public double ReadDouble(string fieldName) { - return ReadField(fieldName, ReadDouble, BinaryUtils.TypeDouble); + return ReadField(fieldName, ReadDouble, BinaryTypeId.Double); } /** */ @@ -278,109 +278,109 @@ namespace Apache.Ignite.Core.Impl.Binary /** */ public double[] ReadDoubleArray(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadDoubleArray, BinaryUtils.TypeArrayDouble); + return ReadField(fieldName, BinaryUtils.ReadDoubleArray, BinaryTypeId.ArrayDouble); } /** */ public double[] ReadDoubleArray() { - return Read(BinaryUtils.ReadDoubleArray, BinaryUtils.TypeArrayDouble); + return Read(BinaryUtils.ReadDoubleArray, BinaryTypeId.ArrayDouble); } /** */ public decimal? ReadDecimal(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadDecimal, BinaryUtils.TypeDecimal); + return ReadField(fieldName, BinaryUtils.ReadDecimal, BinaryTypeId.Decimal); } /** */ public decimal? ReadDecimal() { - return Read(BinaryUtils.ReadDecimal, BinaryUtils.TypeDecimal); + return Read(BinaryUtils.ReadDecimal, BinaryTypeId.Decimal); } /** */ public decimal?[] ReadDecimalArray(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadDecimalArray, BinaryUtils.TypeArrayDecimal); + return ReadField(fieldName, BinaryUtils.ReadDecimalArray, BinaryTypeId.ArrayDecimal); } /** */ public decimal?[] ReadDecimalArray() { - return Read(BinaryUtils.ReadDecimalArray, BinaryUtils.TypeArrayDecimal); + return Read(BinaryUtils.ReadDecimalArray, BinaryTypeId.ArrayDecimal); } /** */ public DateTime? ReadTimestamp(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadTimestamp, BinaryUtils.TypeTimestamp); + return ReadField(fieldName, BinaryUtils.ReadTimestamp, BinaryTypeId.Timestamp); } /** */ public DateTime? ReadTimestamp() { - return Read(BinaryUtils.ReadTimestamp, BinaryUtils.TypeTimestamp); + return Read(BinaryUtils.ReadTimestamp, BinaryTypeId.Timestamp); } /** */ public DateTime?[] ReadTimestampArray(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadTimestampArray, BinaryUtils.TypeArrayTimestamp); + return ReadField(fieldName, BinaryUtils.ReadTimestampArray, BinaryTypeId.ArrayTimestamp); } /** */ public DateTime?[] ReadTimestampArray() { - return Read(BinaryUtils.ReadTimestampArray, BinaryUtils.TypeArrayTimestamp); + return Read(BinaryUtils.ReadTimestampArray, BinaryTypeId.ArrayTimestamp); } /** */ public string ReadString(string fieldName) { - return ReadField(fieldName, BinaryUtils.ReadString, BinaryUtils.TypeString); + return ReadField(fieldName, BinaryUtils.ReadString, BinaryTypeId.String); } /** */ public string ReadString() { - return Read(BinaryUtils.ReadString, BinaryUtils.TypeString); + return Read(BinaryUtils.ReadString, BinaryTypeId.String); } /** */ public string[] ReadStringArray(string fieldName) { - return ReadField(fieldName, r => BinaryUtils.ReadArray(r, false), BinaryUtils.TypeArrayString); + return ReadField(fieldName, r => BinaryUtils.ReadArray(r, false), BinaryTypeId.ArrayString); } /** */ public string[] ReadStringArray() { - return Read(r => BinaryUtils.ReadArray(r, false), BinaryUtils.TypeArrayString); + return Read(r => BinaryUtils.ReadArray(r, false), BinaryTypeId.ArrayString); } /** */ public Guid? ReadGuid(string fieldName) { - return ReadField(fieldName, r => BinaryUtils.ReadGuid(r), BinaryUtils.TypeGuid); + return ReadField(fieldName, r => BinaryUtils.ReadGuid(r), BinaryTypeId.Guid); } /** */ public Guid? ReadGuid() { - return Read(r => BinaryUtils.ReadGuid(r), BinaryUtils.TypeGuid); + return Read(r => BinaryUtils.ReadGuid(r), BinaryTypeId.Guid); } /** */ public Guid?[] ReadGuidArray(string fieldName) { - return ReadField(fieldName, r => BinaryUtils.ReadArray(r, false), BinaryUtils.TypeArrayGuid); + return ReadField(fieldName, r => BinaryUtils.ReadArray(r, false), BinaryTypeId.ArrayGuid); } /** */ public Guid?[] ReadGuidArray() { - return Read(r => BinaryUtils.ReadArray(r, false), BinaryUtils.TypeArrayGuid); + return Read(r => BinaryUtils.ReadArray(r, false), BinaryTypeId.ArrayGuid); } /** */ @@ -399,10 +399,10 @@ namespace Apache.Ignite.Core.Impl.Binary case BinaryUtils.HdrNull: return default(T); - case BinaryUtils.TypeEnum: + case BinaryTypeId.Enum: return ReadEnum0(this, _mode == BinaryMode.ForceBinary); - case BinaryUtils.TypeBinaryEnum: + case BinaryTypeId.BinaryEnum: return ReadEnum0(this, _mode != BinaryMode.Deserialize); case BinaryUtils.HdrFull: @@ -414,20 +414,20 @@ namespace Apache.Ignite.Core.Impl.Binary default: throw new BinaryObjectException(string.Format( "Invalid header on enum deserialization. Expected: {0} or {1} or {2} but was: {3}", - BinaryUtils.TypeEnum, BinaryUtils.TypeBinaryEnum, BinaryUtils.HdrFull, hdr)); + BinaryTypeId.Enum, BinaryTypeId.BinaryEnum, BinaryUtils.HdrFull, hdr)); } } /** */ public T[] ReadEnumArray(string fieldName) { - return ReadField(fieldName, r => BinaryUtils.ReadArray(r, true), BinaryUtils.TypeArrayEnum); + return ReadField(fieldName, r => BinaryUtils.ReadArray(r, true), BinaryTypeId.ArrayEnum); } /** */ public T[] ReadEnumArray() { - return Read(r => BinaryUtils.ReadArray(r, true), BinaryUtils.TypeArrayEnum); + return Read(r => BinaryUtils.ReadArray(r, true), BinaryTypeId.ArrayEnum); } /** */ @@ -451,13 +451,13 @@ namespace Apache.Ignite.Core.Impl.Binary /** */ public T[] ReadArray(string fieldName) { - return ReadField(fieldName, r => BinaryUtils.ReadArray(r, true), BinaryUtils.TypeArray); + return ReadField(fieldName, r => BinaryUtils.ReadArray(r, true), BinaryTypeId.Array); } /** */ public T[] ReadArray() { - return Read(r => BinaryUtils.ReadArray(r, true), BinaryUtils.TypeArray); + return Read(r => BinaryUtils.ReadArray(r, true), BinaryTypeId.Array); } /** */ @@ -476,13 +476,13 @@ namespace Apache.Ignite.Core.Impl.Binary public ICollection ReadCollection(string fieldName, Func factory, Action adder) { - return ReadField(fieldName, r => BinaryUtils.ReadCollection(r, factory, adder), BinaryUtils.TypeCollection); + return ReadField(fieldName, r => BinaryUtils.ReadCollection(r, factory, adder), BinaryTypeId.Collection); } /** */ public ICollection ReadCollection(Func factory, Action adder) { - return Read(r => BinaryUtils.ReadCollection(r, factory, adder), BinaryUtils.TypeCollection); + return Read(r => BinaryUtils.ReadCollection(r, factory, adder), BinaryTypeId.Collection); } /** */ @@ -500,13 +500,13 @@ namespace Apache.Ignite.Core.Impl.Binary /** */ public IDictionary ReadDictionary(string fieldName, Func factory) { - return ReadField(fieldName, r => BinaryUtils.ReadDictionary(r, factory), BinaryUtils.TypeDictionary); + return ReadField(fieldName, r => BinaryUtils.ReadDictionary(r, factory), BinaryTypeId.Dictionary); } /** */ public IDictionary ReadDictionary(Func factory) { - return Read(r => BinaryUtils.ReadDictionary(r, factory), BinaryUtils.TypeDictionary); + return Read(r => BinaryUtils.ReadDictionary(r, factory), BinaryTypeId.Dictionary); } /// @@ -577,17 +577,17 @@ namespace Apache.Ignite.Core.Impl.Binary return true; - case BinaryUtils.TypeBinary: + case BinaryTypeId.Binary: res = ReadBinaryObject(doDetach); return true; - case BinaryUtils.TypeEnum: + case BinaryTypeId.Enum: res = ReadEnum0(this, _mode == BinaryMode.ForceBinary); return true; - case BinaryUtils.TypeBinaryEnum: + case BinaryTypeId.BinaryEnum: res = ReadEnum0(this, _mode != BinaryMode.Deserialize); return true; @@ -716,7 +716,7 @@ namespace Apache.Ignite.Core.Impl.Binary else { // Find descriptor. - var desc = hdr.TypeId == BinaryUtils.TypeUnregistered + var desc = hdr.TypeId == BinaryTypeId.Unregistered ? _marsh.GetDescriptor(ReadUnregisteredType(typeOverride)) : _marsh.GetDescriptor(hdr.IsUserType, hdr.TypeId, true, null, typeOverride); http://git-wip-us.apache.org/repos/asf/ignite/blob/55e0b5c9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs index 95a0be3..f55a11f 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinarySystemHandlers.cs @@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Impl.Binary { using System; using System.Collections; - using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using Apache.Ignite.Core.Impl.Binary.IO; @@ -37,45 +36,6 @@ namespace Apache.Ignite.Core.Impl.Binary /** Read handlers. */ private static readonly IBinarySystemReader[] ReadHandlers = new IBinarySystemReader[255]; - /** Type ids. */ - private static readonly Dictionary TypeIds = new Dictionary - { - {typeof (bool), BinaryUtils.TypeBool}, - {typeof (byte), BinaryUtils.TypeByte}, - {typeof (sbyte), BinaryUtils.TypeByte}, - {typeof (short), BinaryUtils.TypeShort}, - {typeof (ushort), BinaryUtils.TypeShort}, - {typeof (char), BinaryUtils.TypeChar}, - {typeof (int), BinaryUtils.TypeInt}, - {typeof (uint), BinaryUtils.TypeInt}, - {typeof (long), BinaryUtils.TypeLong}, - {typeof (ulong), BinaryUtils.TypeLong}, - {typeof (float), BinaryUtils.TypeFloat}, - {typeof (double), BinaryUtils.TypeDouble}, - {typeof (string), BinaryUtils.TypeString}, - {typeof (decimal), BinaryUtils.TypeDecimal}, - {typeof (Guid), BinaryUtils.TypeGuid}, - {typeof (Guid?), BinaryUtils.TypeGuid}, - {typeof (ArrayList), BinaryUtils.TypeCollection}, - {typeof (Hashtable), BinaryUtils.TypeDictionary}, - {typeof (bool[]), BinaryUtils.TypeArrayBool}, - {typeof (byte[]), BinaryUtils.TypeArrayByte}, - {typeof (sbyte[]), BinaryUtils.TypeArrayByte}, - {typeof (short[]), BinaryUtils.TypeArrayShort}, - {typeof (ushort[]), BinaryUtils.TypeArrayShort}, - {typeof (char[]), BinaryUtils.TypeArrayChar}, - {typeof (int[]), BinaryUtils.TypeArrayInt}, - {typeof (uint[]), BinaryUtils.TypeArrayInt}, - {typeof (long[]), BinaryUtils.TypeArrayLong}, - {typeof (ulong[]), BinaryUtils.TypeArrayLong}, - {typeof (float[]), BinaryUtils.TypeArrayFloat}, - {typeof (double[]), BinaryUtils.TypeArrayDouble}, - {typeof (string[]), BinaryUtils.TypeArrayString}, - {typeof (decimal?[]), BinaryUtils.TypeArrayDecimal}, - {typeof (Guid?[]), BinaryUtils.TypeArrayGuid}, - {typeof (object[]), BinaryUtils.TypeArray} - }; - /// /// Initializes the class. /// @@ -84,75 +44,75 @@ namespace Apache.Ignite.Core.Impl.Binary static BinarySystemHandlers() { // 1. Primitives. - ReadHandlers[BinaryUtils.TypeBool] = new BinarySystemReader(s => s.ReadBool()); - ReadHandlers[BinaryUtils.TypeByte] = new BinarySystemReader(s => s.ReadByte()); - ReadHandlers[BinaryUtils.TypeShort] = new BinarySystemReader(s => s.ReadShort()); - ReadHandlers[BinaryUtils.TypeChar] = new BinarySystemReader(s => s.ReadChar()); - ReadHandlers[BinaryUtils.TypeInt] = new BinarySystemReader(s => s.ReadInt()); - ReadHandlers[BinaryUtils.TypeLong] = new BinarySystemReader(s => s.ReadLong()); - ReadHandlers[BinaryUtils.TypeFloat] = new BinarySystemReader(s => s.ReadFloat()); - ReadHandlers[BinaryUtils.TypeDouble] = new BinarySystemReader(s => s.ReadDouble()); - ReadHandlers[BinaryUtils.TypeDecimal] = new BinarySystemReader(BinaryUtils.ReadDecimal); + ReadHandlers[BinaryTypeId.Bool] = new BinarySystemReader(s => s.ReadBool()); + ReadHandlers[BinaryTypeId.Byte] = new BinarySystemReader(s => s.ReadByte()); + ReadHandlers[BinaryTypeId.Short] = new BinarySystemReader(s => s.ReadShort()); + ReadHandlers[BinaryTypeId.Char] = new BinarySystemReader(s => s.ReadChar()); + ReadHandlers[BinaryTypeId.Int] = new BinarySystemReader(s => s.ReadInt()); + ReadHandlers[BinaryTypeId.Long] = new BinarySystemReader(s => s.ReadLong()); + ReadHandlers[BinaryTypeId.Float] = new BinarySystemReader(s => s.ReadFloat()); + ReadHandlers[BinaryTypeId.Double] = new BinarySystemReader(s => s.ReadDouble()); + ReadHandlers[BinaryTypeId.Decimal] = new BinarySystemReader(BinaryUtils.ReadDecimal); // 2. Date. - ReadHandlers[BinaryUtils.TypeTimestamp] = new BinarySystemReader(BinaryUtils.ReadTimestamp); + ReadHandlers[BinaryTypeId.Timestamp] = new BinarySystemReader(BinaryUtils.ReadTimestamp); // 3. String. - ReadHandlers[BinaryUtils.TypeString] = new BinarySystemReader(BinaryUtils.ReadString); + ReadHandlers[BinaryTypeId.String] = new BinarySystemReader(BinaryUtils.ReadString); // 4. Guid. - ReadHandlers[BinaryUtils.TypeGuid] = new BinarySystemReader(s => BinaryUtils.ReadGuid(s)); + ReadHandlers[BinaryTypeId.Guid] = new BinarySystemReader(s => BinaryUtils.ReadGuid(s)); // 5. Primitive arrays. - ReadHandlers[BinaryUtils.TypeArrayBool] = new BinarySystemReader(BinaryUtils.ReadBooleanArray); + ReadHandlers[BinaryTypeId.ArrayBool] = new BinarySystemReader(BinaryUtils.ReadBooleanArray); - ReadHandlers[BinaryUtils.TypeArrayByte] = + ReadHandlers[BinaryTypeId.ArrayByte] = new BinarySystemDualReader(BinaryUtils.ReadByteArray, BinaryUtils.ReadSbyteArray); - ReadHandlers[BinaryUtils.TypeArrayShort] = + ReadHandlers[BinaryTypeId.ArrayShort] = new BinarySystemDualReader(BinaryUtils.ReadShortArray, BinaryUtils.ReadUshortArray); - ReadHandlers[BinaryUtils.TypeArrayChar] = + ReadHandlers[BinaryTypeId.ArrayChar] = new BinarySystemReader(BinaryUtils.ReadCharArray); - ReadHandlers[BinaryUtils.TypeArrayInt] = + ReadHandlers[BinaryTypeId.ArrayInt] = new BinarySystemDualReader(BinaryUtils.ReadIntArray, BinaryUtils.ReadUintArray); - ReadHandlers[BinaryUtils.TypeArrayLong] = + ReadHandlers[BinaryTypeId.ArrayLong] = new BinarySystemDualReader(BinaryUtils.ReadLongArray, BinaryUtils.ReadUlongArray); - ReadHandlers[BinaryUtils.TypeArrayFloat] = + ReadHandlers[BinaryTypeId.ArrayFloat] = new BinarySystemReader(BinaryUtils.ReadFloatArray); - ReadHandlers[BinaryUtils.TypeArrayDouble] = + ReadHandlers[BinaryTypeId.ArrayDouble] = new BinarySystemReader(BinaryUtils.ReadDoubleArray); - ReadHandlers[BinaryUtils.TypeArrayDecimal] = + ReadHandlers[BinaryTypeId.ArrayDecimal] = new BinarySystemReader(BinaryUtils.ReadDecimalArray); // 6. Date array. - ReadHandlers[BinaryUtils.TypeArrayTimestamp] = + ReadHandlers[BinaryTypeId.ArrayTimestamp] = new BinarySystemReader(BinaryUtils.ReadTimestampArray); // 7. String array. - ReadHandlers[BinaryUtils.TypeArrayString] = new BinarySystemTypedArrayReader(); + ReadHandlers[BinaryTypeId.ArrayString] = new BinarySystemTypedArrayReader(); // 8. Guid array. - ReadHandlers[BinaryUtils.TypeArrayGuid] = new BinarySystemTypedArrayReader(); + ReadHandlers[BinaryTypeId.ArrayGuid] = new BinarySystemTypedArrayReader(); // 9. Array. - ReadHandlers[BinaryUtils.TypeArray] = new BinarySystemReader(ReadArray); + ReadHandlers[BinaryTypeId.Array] = new BinarySystemReader(ReadArray); // 11. Arbitrary collection. - ReadHandlers[BinaryUtils.TypeCollection] = new BinarySystemReader(ReadCollection); + ReadHandlers[BinaryTypeId.Collection] = new BinarySystemReader(ReadCollection); // 13. Arbitrary dictionary. - ReadHandlers[BinaryUtils.TypeDictionary] = new BinarySystemReader(ReadDictionary); + ReadHandlers[BinaryTypeId.Dictionary] = new BinarySystemReader(ReadDictionary); // 14. Enum. - ReadHandlers[BinaryUtils.TypeArrayEnum] = new BinarySystemReader(ReadEnumArray); + ReadHandlers[BinaryTypeId.ArrayEnum] = new BinarySystemReader(ReadEnumArray); } /// @@ -266,27 +226,6 @@ namespace Apache.Ignite.Core.Impl.Binary } /// - /// Find write handler for type. - /// - /// Type. - /// Write handler or NULL. - public static byte GetTypeId(Type type) - { - byte res; - - if (TypeIds.TryGetValue(type, out res)) - return res; - - if (BinaryUtils.IsIgniteEnum(type)) - return BinaryUtils.TypeEnum; - - if (type.IsArray && BinaryUtils.IsIgniteEnum(type.GetElementType())) - return BinaryUtils.TypeArrayEnum; - - return BinaryUtils.TypeObject; - } - - /// /// Reads an object of predefined type. /// public static bool TryReadSystemType(byte typeId, BinaryReader ctx, out T res) @@ -310,7 +249,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteDecimal(BinaryWriter ctx, decimal obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeDecimal); + ctx.Stream.WriteByte(BinaryTypeId.Decimal); BinaryUtils.WriteDecimal(obj, ctx.Stream); } @@ -322,7 +261,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Object. private static void WriteString(BinaryWriter ctx, string obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeString); + ctx.Stream.WriteByte(BinaryTypeId.String); BinaryUtils.WriteString(obj, ctx.Stream); } @@ -334,7 +273,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteGuid(BinaryWriter ctx, Guid obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeGuid); + ctx.Stream.WriteByte(BinaryTypeId.Guid); BinaryUtils.WriteGuid(obj, ctx.Stream); } @@ -346,7 +285,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteBoolArray(BinaryWriter ctx, bool[] obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayBool); + ctx.Stream.WriteByte(BinaryTypeId.ArrayBool); BinaryUtils.WriteBooleanArray(obj, ctx.Stream); } @@ -358,7 +297,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteByteArray(BinaryWriter ctx, byte[] obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayByte); + ctx.Stream.WriteByte(BinaryTypeId.ArrayByte); BinaryUtils.WriteByteArray(obj, ctx.Stream); } @@ -370,7 +309,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteShortArray(BinaryWriter ctx, short[] obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayShort); + ctx.Stream.WriteByte(BinaryTypeId.ArrayShort); BinaryUtils.WriteShortArray(obj, ctx.Stream); } @@ -382,7 +321,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteCharArray(BinaryWriter ctx, object obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayChar); + ctx.Stream.WriteByte(BinaryTypeId.ArrayChar); BinaryUtils.WriteCharArray((char[])obj, ctx.Stream); } @@ -394,7 +333,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteIntArray(BinaryWriter ctx, int[] obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayInt); + ctx.Stream.WriteByte(BinaryTypeId.ArrayInt); BinaryUtils.WriteIntArray(obj, ctx.Stream); } @@ -406,7 +345,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteLongArray(BinaryWriter ctx, long[] obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayLong); + ctx.Stream.WriteByte(BinaryTypeId.ArrayLong); BinaryUtils.WriteLongArray(obj, ctx.Stream); } @@ -418,7 +357,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteFloatArray(BinaryWriter ctx, float[] obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayFloat); + ctx.Stream.WriteByte(BinaryTypeId.ArrayFloat); BinaryUtils.WriteFloatArray(obj, ctx.Stream); } @@ -430,7 +369,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteDoubleArray(BinaryWriter ctx, double[] obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayDouble); + ctx.Stream.WriteByte(BinaryTypeId.ArrayDouble); BinaryUtils.WriteDoubleArray(obj, ctx.Stream); } @@ -442,7 +381,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteDecimalArray(BinaryWriter ctx, decimal?[] obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayDecimal); + ctx.Stream.WriteByte(BinaryTypeId.ArrayDecimal); BinaryUtils.WriteDecimalArray(obj, ctx.Stream); } @@ -454,7 +393,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteStringArray(BinaryWriter ctx, string[] obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayString); + ctx.Stream.WriteByte(BinaryTypeId.ArrayString); BinaryUtils.WriteStringArray(obj, ctx.Stream); } @@ -466,7 +405,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// Value. private static void WriteGuidArray(BinaryWriter ctx, Guid?[] obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayGuid); + ctx.Stream.WriteByte(BinaryTypeId.ArrayGuid); BinaryUtils.WriteGuidArray(obj, ctx.Stream); } @@ -476,7 +415,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// private static void WriteEnumArray(BinaryWriter ctx, object obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArrayEnum); + ctx.Stream.WriteByte(BinaryTypeId.ArrayEnum); BinaryUtils.WriteArray((Array) obj, ctx); } @@ -486,7 +425,7 @@ namespace Apache.Ignite.Core.Impl.Binary /// private static void WriteArray(BinaryWriter ctx, object obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeArray); + ctx.Stream.WriteByte(BinaryTypeId.Array); BinaryUtils.WriteArray((Array) obj, ctx); } @@ -496,7 +435,7 @@ namespace Apache.Ignite.Core.Impl.Binary */ private static void WriteArrayList(BinaryWriter ctx, ICollection obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeCollection); + ctx.Stream.WriteByte(BinaryTypeId.Collection); BinaryUtils.WriteCollection(obj, ctx, BinaryUtils.CollectionArrayList); } @@ -506,7 +445,7 @@ namespace Apache.Ignite.Core.Impl.Binary */ private static void WriteHashtable(BinaryWriter ctx, IDictionary obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeDictionary); + ctx.Stream.WriteByte(BinaryTypeId.Dictionary); BinaryUtils.WriteDictionary(obj, ctx, BinaryUtils.MapHashMap); } @@ -516,7 +455,7 @@ namespace Apache.Ignite.Core.Impl.Binary */ private static void WriteBinary(BinaryWriter ctx, BinaryObject obj) { - ctx.Stream.WriteByte(BinaryUtils.TypeBinary); + ctx.Stream.WriteByte(BinaryTypeId.Binary); BinaryUtils.WriteBinary(ctx.Stream, obj); } @@ -528,7 +467,7 @@ namespace Apache.Ignite.Core.Impl.Binary { var binEnum = obj; - ctx.Stream.WriteByte(BinaryUtils.TypeBinaryEnum); + ctx.Stream.WriteByte(BinaryTypeId.BinaryEnum); ctx.WriteInt(binEnum.TypeId); ctx.WriteInt(binEnum.EnumValue); http://git-wip-us.apache.org/repos/asf/ignite/blob/55e0b5c9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryTypeId.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryTypeId.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryTypeId.cs new file mode 100644 index 0000000..1d3d9c4 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryTypeId.cs @@ -0,0 +1,228 @@ +/* + * 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.Binary +{ + using System; + using System.Collections; + using System.Collections.Generic; + + /// + /// Binary type IDs. + /// + internal static class BinaryTypeId + { + /** Type: object. */ + public const byte Object = BinaryUtils.HdrFull; + + /** Type: unregistered. */ + public const byte Unregistered = 0; + + /** Type: unsigned byte. */ + public const byte Byte = 1; + + /** Type: short. */ + public const byte Short = 2; + + /** Type: int. */ + public const byte Int = 3; + + /** Type: long. */ + public const byte Long = 4; + + /** Type: float. */ + public const byte Float = 5; + + /** Type: double. */ + public const byte Double = 6; + + /** Type: char. */ + public const byte Char = 7; + + /** Type: boolean. */ + public const byte Bool = 8; + + /** Type: decimal. */ + public const byte Decimal = 30; + + /** Type: string. */ + public const byte String = 9; + + /** Type: GUID. */ + public const byte Guid = 10; + + /** Type: date. */ + public const byte Timestamp = 33; + + /** Type: unsigned byte array. */ + public const byte ArrayByte = 12; + + /** Type: short array. */ + public const byte ArrayShort = 13; + + /** Type: int array. */ + public const byte ArrayInt = 14; + + /** Type: long array. */ + public const byte ArrayLong = 15; + + /** Type: float array. */ + public const byte ArrayFloat = 16; + + /** Type: double array. */ + public const byte ArrayDouble = 17; + + /** Type: char array. */ + public const byte ArrayChar = 18; + + /** Type: boolean array. */ + public const byte ArrayBool = 19; + + /** Type: decimal array. */ + public const byte ArrayDecimal = 31; + + /** Type: string array. */ + public const byte ArrayString = 20; + + /** Type: GUID array. */ + public const byte ArrayGuid = 21; + + /** Type: date array. */ + public const byte ArrayTimestamp = 34; + + /** Type: object array. */ + public const byte Array = 23; + + /** Type: collection. */ + public const byte Collection = 24; + + /** Type: map. */ + public const byte Dictionary = 25; + + /** Type: binary object. */ + public const byte Binary = 27; + + /** Type: enum. */ + public const byte Enum = 28; + + /** Type: enum array. */ + public const byte ArrayEnum = 29; + + /** Type: binary enum. */ + public const byte BinaryEnum = 38; + + /** Type: native job holder. */ + public const byte NativeJobHolder = 77; + + /** Type: function wrapper. */ + public const byte ComputeOutFuncJob = 80; + + /** Type: function wrapper. */ + public const byte ComputeFuncJob = 81; + + /** Type: continuous query remote filter. */ + public const byte ContinuousQueryRemoteFilterHolder = 82; + + /** Type: Compute out func wrapper. */ + public const byte ComputeOutFuncWrapper = 83; + + /** Type: Compute func wrapper. */ + public const byte ComputeFuncWrapper = 85; + + /** Type: Compute job wrapper. */ + public const byte ComputeJobWrapper = 86; + + /** Type: action wrapper. */ + public const byte ComputeActionJob = 88; + + /** Type: entry processor holder. */ + public const byte CacheEntryProcessorHolder = 89; + + /** Type: entry predicate holder. */ + public const byte CacheEntryPredicateHolder = 90; + + /** Type: message filter holder. */ + public const byte MessageListenerHolder = 92; + + /** Type: stream receiver holder. */ + public const byte StreamReceiverHolder = 94; + + /** Type: platform object proxy. */ + public const byte PlatformJavaObjectFactoryProxy = 99; + + /** Type: platform object proxy. */ + public const int IgniteUuid = 2018070327; + + /** Type ids. */ + private static readonly Dictionary TypeIds = new Dictionary + { + {typeof (bool), Bool}, + {typeof (byte), Byte}, + {typeof (sbyte), Byte}, + {typeof (short), Short}, + {typeof (ushort), Short}, + {typeof (char), Char}, + {typeof (int), Int}, + {typeof (uint), Int}, + {typeof (long), Long}, + {typeof (ulong), Long}, + {typeof (float), Float}, + {typeof (double), Double}, + {typeof (string), String}, + {typeof (decimal), Decimal}, + {typeof (Guid), Guid}, + {typeof (Guid?), Guid}, + {typeof (ArrayList), Collection}, + {typeof (Hashtable), Dictionary}, + {typeof (bool[]), ArrayBool}, + {typeof (byte[]), ArrayByte}, + {typeof (sbyte[]), ArrayByte}, + {typeof (short[]), ArrayShort}, + {typeof (ushort[]), ArrayShort}, + {typeof (char[]), ArrayChar}, + {typeof (int[]), ArrayInt}, + {typeof (uint[]), ArrayInt}, + {typeof (long[]), ArrayLong}, + {typeof (ulong[]), ArrayLong}, + {typeof (float[]), ArrayFloat}, + {typeof (double[]), ArrayDouble}, + {typeof (string[]), ArrayString}, + {typeof (decimal?[]), ArrayDecimal}, + {typeof (Guid?[]), ArrayGuid}, + {typeof (object[]), Array} + }; + + /// + /// Get binary type id for a type. + /// + internal static byte GetTypeId(Type type) + { + byte res; + + if (TypeIds.TryGetValue(type, out res)) + return res; + + if (BinaryUtils.IsIgniteEnum(type)) + return Enum; + + if (type.IsArray && BinaryUtils.IsIgniteEnum(type.GetElementType())) + return ArrayEnum; + + return Object; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/55e0b5c9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs index 91a536e..1146f35 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs @@ -47,147 +47,6 @@ namespace Apache.Ignite.Core.Impl.Binary /** Protocol versnion. */ public const byte ProtoVer = 1; - /** Type: object. */ - public const byte TypeObject = HdrFull; - - /** Type: unregistered. */ - public const byte TypeUnregistered = 0; - - /** Type: unsigned byte. */ - public const byte TypeByte = 1; - - /** Type: short. */ - public const byte TypeShort = 2; - - /** Type: int. */ - public const byte TypeInt = 3; - - /** Type: long. */ - public const byte TypeLong = 4; - - /** Type: float. */ - public const byte TypeFloat = 5; - - /** Type: double. */ - public const byte TypeDouble = 6; - - /** Type: char. */ - public const byte TypeChar = 7; - - /** Type: boolean. */ - public const byte TypeBool = 8; - - /** Type: decimal. */ - public const byte TypeDecimal = 30; - - /** Type: string. */ - public const byte TypeString = 9; - - /** Type: GUID. */ - public const byte TypeGuid = 10; - - /** Type: date. */ - public const byte TypeTimestamp = 33; - - /** Type: unsigned byte array. */ - public const byte TypeArrayByte = 12; - - /** Type: short array. */ - public const byte TypeArrayShort = 13; - - /** Type: int array. */ - public const byte TypeArrayInt = 14; - - /** Type: long array. */ - public const byte TypeArrayLong = 15; - - /** Type: float array. */ - public const byte TypeArrayFloat = 16; - - /** Type: double array. */ - public const byte TypeArrayDouble = 17; - - /** Type: char array. */ - public const byte TypeArrayChar = 18; - - /** Type: boolean array. */ - public const byte TypeArrayBool = 19; - - /** Type: decimal array. */ - public const byte TypeArrayDecimal = 31; - - /** Type: string array. */ - public const byte TypeArrayString = 20; - - /** Type: GUID array. */ - public const byte TypeArrayGuid = 21; - - /** Type: date array. */ - public const byte TypeArrayTimestamp = 34; - - /** Type: object array. */ - public const byte TypeArray = 23; - - /** Type: collection. */ - public const byte TypeCollection = 24; - - /** Type: map. */ - public const byte TypeDictionary = 25; - - /** Type: binary object. */ - public const byte TypeBinary = 27; - - /** Type: enum. */ - public const byte TypeEnum = 28; - - /** Type: enum array. */ - public const byte TypeArrayEnum = 29; - - /** Type: binary enum. */ - public const byte TypeBinaryEnum = 38; - - /** Type: native job holder. */ - public const byte TypeNativeJobHolder = 77; - - /** Type: function wrapper. */ - public const byte TypeComputeOutFuncJob = 80; - - /** Type: function wrapper. */ - public const byte TypeComputeFuncJob = 81; - - /** Type: continuous query remote filter. */ - public const byte TypeContinuousQueryRemoteFilterHolder = 82; - - /** Type: Compute out func wrapper. */ - public const byte TypeComputeOutFuncWrapper = 83; - - /** Type: Compute func wrapper. */ - public const byte TypeComputeFuncWrapper = 85; - - /** Type: Compute job wrapper. */ - public const byte TypeComputeJobWrapper = 86; - - /** Type: action wrapper. */ - public const byte TypeComputeActionJob = 88; - - /** Type: entry processor holder. */ - public const byte TypeCacheEntryProcessorHolder = 89; - - /** Type: entry predicate holder. */ - public const byte TypeCacheEntryPredicateHolder = 90; - - /** Type: message filter holder. */ - public const byte TypeMessageListenerHolder = 92; - - /** Type: stream receiver holder. */ - public const byte TypeStreamReceiverHolder = 94; - - /** Type: platform object proxy. */ - public const byte TypePlatformJavaObjectFactoryProxy = 99; - - /** Type: platform object proxy. */ - public const int TypeIgniteUuid = 2018070327; - /** Collection: custom. */ public const byte CollectionCustom = 0; @@ -563,7 +422,7 @@ namespace Apache.Ignite.Core.Impl.Binary { if (val.HasValue) { - stream.WriteByte(TypeTimestamp); + stream.WriteByte(BinaryTypeId.Timestamp); WriteTimestamp(val.Value, stream); } @@ -781,7 +640,7 @@ namespace Apache.Ignite.Core.Impl.Binary { if (val != null) { - stream.WriteByte(TypeString); + stream.WriteByte(BinaryTypeId.String); WriteString(val, stream); } else @@ -985,7 +844,7 @@ namespace Apache.Ignite.Core.Impl.Binary { if (val.HasValue) { - stream.WriteByte(TypeDecimal); + stream.WriteByte(BinaryTypeId.Decimal); WriteDecimal(val.Value, stream); } @@ -1147,7 +1006,7 @@ namespace Apache.Ignite.Core.Impl.Binary { if (val.HasValue) { - stream.WriteByte(TypeGuid); + stream.WriteByte(BinaryTypeId.Guid); WriteGuid(val.Value, stream); } @@ -1168,7 +1027,7 @@ namespace Apache.Ignite.Core.Impl.Binary IBinaryStream stream = ctx.Stream; - if (elemTypeId != null && elemTypeId != TypeUnregistered) + if (elemTypeId != null && elemTypeId != BinaryTypeId.Unregistered) { stream.WriteInt(elemTypeId.Value); } @@ -1183,7 +1042,7 @@ namespace Apache.Ignite.Core.Impl.Binary stream.WriteInt(typeId); - if (typeId == TypeUnregistered) + if (typeId == BinaryTypeId.Unregistered) ctx.WriteString(elemType.FullName); } @@ -1229,7 +1088,7 @@ namespace Apache.Ignite.Core.Impl.Binary { int typeId = stream.ReadInt(); - if (typeId == TypeUnregistered) + if (typeId == BinaryTypeId.Unregistered) ctx.ReadString(); }