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 5A916189FD for ; Sun, 22 Nov 2015 16:41:34 +0000 (UTC) Received: (qmail 78631 invoked by uid 500); 22 Nov 2015 16:41:34 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 78490 invoked by uid 500); 22 Nov 2015 16:41:34 -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 77845 invoked by uid 99); 22 Nov 2015 16:41:33 -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; Sun, 22 Nov 2015 16:41:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B49D0E0A50; Sun, 22 Nov 2015 16:41:33 +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: Sun, 22 Nov 2015 16:41:55 -0000 Message-Id: <4b011e41888441e994c267572087c41f@git.apache.org> In-Reply-To: <06f2287f4f5b4870aba523bfc8518452@git.apache.org> References: <06f2287f4f5b4870aba523bfc8518452@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [23/50] [abbrv] ignite git commit: IGNITE-1970: Binaries: simplified header reading. IGNITE-1970: Binaries: simplified header reading. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f37863a4 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f37863a4 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f37863a4 Branch: refs/heads/ignite-single-op-get Commit: f37863a43bceebcc38af750c403efb35955b70df Parents: 9c71785 Author: vozerov-gridgain Authored: Fri Nov 20 15:19:00 2015 +0300 Committer: vozerov-gridgain Committed: Fri Nov 20 15:19:00 2015 +0300 ---------------------------------------------------------------------- .../internal/portable/BinaryReaderExImpl.java | 65 ++++++++++++-------- 1 file changed, 38 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/f37863a4/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java index 356aaae..5d31670 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java @@ -28,7 +28,6 @@ import org.apache.ignite.internal.portable.streams.PortableInputStream; import org.apache.ignite.internal.util.lang.GridMapEntry; import org.apache.ignite.internal.util.typedef.internal.SB; import org.apache.ignite.internal.util.typedef.internal.U; -import org.apache.ignite.lang.IgniteBiTuple; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -186,47 +185,59 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje start = in.position(); - // Parse header if possible. - byte hdr = in.readBytePositioned(start); + byte hdr = in.readByte(); + // Perform full header parsing in case of portable object. if (hdr == GridPortableMarshaller.OBJ) { - // Skip header. - in.readByte(); - // Ensure protocol is fine. PortableUtils.checkProtocolVersion(in.readByte()); - // Read and parse flags. + // Read header content. short flags = in.readShort(); + int typeId0 = in.readInt(); - userType = PortableUtils.isUserType(flags); + in.readInt(); // Skip hash code. + int len = in.readInt(); + schemaId = in.readInt(); + int offset = in.readInt(); + + // Get trivial flag values. + userType = PortableUtils.isUserType(flags); fieldIdLen = PortableUtils.fieldIdLength(flags); fieldOffsetLen = PortableUtils.fieldOffsetLength(flags); - int typeId0 = in.readIntPositioned(start + GridPortableMarshaller.TYPE_ID_POS); + // Calculate footer borders and raw offset. + if (PortableUtils.hasSchema(flags)) { + // Schema exists. + footerStart = start + offset; - IgniteBiTuple footer = PortableUtils.footerAbsolute(in, start); - - footerStart = footer.get1(); - footerLen = footer.get2() - footerStart; - - schemaId = in.readIntPositioned(start + GridPortableMarshaller.SCHEMA_ID_POS); + if (PortableUtils.hasRaw(flags)) { + footerLen = len - offset - 4; + rawOff = start + in.readIntPositioned(start + len - 4); + } + else { + footerLen = len - offset; + rawOff = start + len; + } + } + else { + // No schema. + footerStart = start + len; + footerLen = 0; - rawOff = PortableUtils.rawOffsetAbsolute(in, start); + if (PortableUtils.hasRaw(flags)) + rawOff = start + offset; + else + rawOff = start + len; + } + // Finally, we have to resolve real type ID. if (typeId0 == UNREGISTERED_TYPE_ID) { - // Skip to the class name position. - in.position(start + GridPortableMarshaller.DFLT_HDR_LEN); - int off = in.position(); - Class cls = doReadClass(typeId0); - - // registers class by typeId, at least locally if the cache is not ready yet. - PortableClassDescriptor desc = ctx.descriptorForClass(cls); - - typeId = desc.typeId(); + // Registers class by type ID, at least locally if the cache is not ready yet. + typeId = ctx.descriptorForClass(doReadClass(typeId0)).typeId(); int clsNameLen = in.position() - off; @@ -240,8 +251,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje idMapper = userType ? ctx.userTypeIdMapper(typeId) : null; schema = PortableUtils.hasSchema(flags) ? getOrCreateSchema() : null; - - in.position(start); } else { typeId = 0; @@ -256,6 +265,8 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje fieldOffsetLen = 0; schema = null; } + + in.position(start); } /**