Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3E344182F5 for ; Fri, 19 Feb 2016 16:18:13 +0000 (UTC) Received: (qmail 32868 invoked by uid 500); 19 Feb 2016 16:18:12 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 32589 invoked by uid 500); 19 Feb 2016 16:18:12 -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 31343 invoked by uid 99); 19 Feb 2016 16:18:11 -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; Fri, 19 Feb 2016 16:18:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 262D2E0231; Fri, 19 Feb 2016 16:18:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Fri, 19 Feb 2016 16:18:47 -0000 Message-Id: In-Reply-To: <7494845c80934f50b45758055220a1c0@git.apache.org> References: <7494845c80934f50b45758055220a1c0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [38/50] [abbrv] ignite git commit: IGNITE-2625 .NET: Fixed field offset calculation in BinaryReader. IGNITE-2625 .NET: Fixed field offset calculation in BinaryReader. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3dce33f5 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3dce33f5 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3dce33f5 Branch: refs/heads/ignite-961 Commit: 3dce33f5a007aa15adfc1e79b1ac96e86683e9fb Parents: 6c4bad1 Author: Pavel Tupitsyn Authored: Fri Feb 12 16:09:00 2016 +0300 Committer: vozerov-gridgain Committed: Fri Feb 12 16:09:00 2016 +0300 ---------------------------------------------------------------------- .../Binary/BinaryStructureTest.cs | 38 ++++++++++++++------ .../Impl/Binary/BinaryReader.cs | 2 +- 2 files changed, 28 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/3dce33f5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs index 78ee8c0..1ab81c5 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs @@ -20,9 +20,11 @@ namespace Apache.Ignite.Core.Tests.Binary using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; + using System.IO; using Apache.Ignite.Core.Binary; using Apache.Ignite.Core.Impl; using Apache.Ignite.Core.Impl.Binary; + using Apache.Ignite.Core.Impl.Binary.IO; using NUnit.Framework; /// @@ -66,15 +68,29 @@ namespace Apache.Ignite.Core.Tests.Binary Marshaller marsh = new Marshaller(cfg); // 3. Marshal all data and ensure deserialized object is fine. - foreach (BranchedType obj in objs) + // Use single stream to test object offsets + using (var stream = new BinaryHeapStream(128)) { - Console.WriteLine(">>> Write object [mode=" + obj.mode + ']'); + var writer = marsh.StartMarshal(stream); - byte[] data = marsh.Marshal(obj); + foreach (var obj in objs) + { + Console.WriteLine(">>> Write object [mode=" + obj.mode + ']'); - BranchedType other = marsh.Unmarshal(data); + writer.WriteObject(obj); - Assert.IsTrue(obj.Equals(other)); + } + + stream.Seek(0, SeekOrigin.Begin); + + var reader = marsh.StartUnmarshal(stream); + + foreach (var obj in objs) + { + var other = reader.ReadObject(); + + Assert.IsTrue(obj.Equals(other)); + } } Console.WriteLine(); @@ -206,30 +222,30 @@ namespace Apache.Ignite.Core.Tests.Binary break; case 2: - f2 = reader.ReadInt("f2"); - f3 = reader.ReadInt("f3"); f4 = reader.ReadInt("f4"); + f3 = reader.ReadInt("f3"); + f2 = reader.ReadInt("f2"); break; case 3: + f5 = reader.ReadInt("f5"); f2 = reader.ReadInt("f2"); f3 = reader.ReadInt("f3"); - f5 = reader.ReadInt("f5"); break; case 4: - f2 = reader.ReadInt("f2"); - f3 = reader.ReadInt("f3"); f5 = reader.ReadInt("f5"); f6 = reader.ReadInt("f6"); + f2 = reader.ReadInt("f2"); + f3 = reader.ReadInt("f3"); break; case 5: - f2 = reader.ReadInt("f2"); f3 = reader.ReadInt("f3"); + f2 = reader.ReadInt("f2"); f7 = reader.ReadInt("f7"); break; http://git-wip-us.apache.org/repos/asf/ignite/blob/3dce33f5/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 1c5c719..16aae93 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs @@ -938,7 +938,7 @@ namespace Apache.Ignite.Core.Impl.Binary if (!_curSchemaMap.TryGetValue(fieldId, out pos)) return false; - Stream.Seek(pos, SeekOrigin.Begin); + Stream.Seek(pos + _curPos, SeekOrigin.Begin); } return true;