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 81756200ACA for ; Thu, 9 Jun 2016 21:54:40 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 80158160A58; Thu, 9 Jun 2016 19:54:40 +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 A1A79160A29 for ; Thu, 9 Jun 2016 21:54:39 +0200 (CEST) Received: (qmail 39106 invoked by uid 500); 9 Jun 2016 19:54:38 -0000 Mailing-List: contact notifications-help@asterixdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.apache.org Delivered-To: mailing list notifications@asterixdb.apache.org Received: (qmail 39097 invoked by uid 99); 9 Jun 2016 19:54:38 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2016 19:54:38 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 536371804A8 for ; Thu, 9 Jun 2016 19:54:38 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.919 X-Spam-Level: X-Spam-Status: No, score=0.919 tagged_above=-999 required=6.31 tests=[SPF_FAIL=0.919] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id TXrKw3h0w-lU for ; Thu, 9 Jun 2016 19:54:36 +0000 (UTC) Received: from unhygienix.ics.uci.edu (unhygienix.ics.uci.edu [128.195.14.130]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 45E555F4E8 for ; Thu, 9 Jun 2016 19:54:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by unhygienix.ics.uci.edu (Postfix) with ESMTP id 54E042418E5; Thu, 9 Jun 2016 12:54:34 -0700 (PDT) Date: Thu, 9 Jun 2016 12:54:34 -0700 From: "Till Westmann (Code Review)" To: Michael Blow Message-ID: Reply-To: tillw@apache.org X-Gerrit-MessageType: newchange Subject: Change in asterixdb[master]: less code X-Gerrit-Change-Id: I179a16fc183bd50d5d58cc12321234df1615abfd X-Gerrit-ChangeURL: X-Gerrit-Commit: 35237527e35784da0708042c497b670aa5e3a69e MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.8.4 archived-at: Thu, 09 Jun 2016 19:54:40 -0000 Till Westmann has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/916 Change subject: less code ...................................................................... less code Change-Id: I179a16fc183bd50d5d58cc12321234df1615abfd --- M asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java M asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java M asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java 3 files changed, 18 insertions(+), 35 deletions(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/16/916/1 diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java index c922054..b155895 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java @@ -230,39 +230,24 @@ if (serRecord[0 + offset] == ATypeTag.RECORD.serialize()) { // 5 is the index of the byte that determines whether the record // is expanded or not, i.e. it has an open part. - if (serRecord[5 + offset] == 1) { // true - if (nullBitmapSize > 0) { - // 14 = tag (1) + record Size (4) + isExpanded (1) + - // offset of openPart (4) + number of closed fields (4) - int pos = 14 + offset + fieldId / 4; - if ((serRecord[pos] & nullTestCode) == 0) { - // the field value is null - return 0; - } - if ((serRecord[pos] & missingTestCode) == 0) { - // the field value is missing - return -1; - } + // 14 = tag (1) + record Size (4) + isExpanded (1) + + // offset of openPart (4) + number of closed fields (4) + // 10 = tag (1) + record Size (4) + isExpanded (1) + + // number of closed fields (4) + final int baseOffset = (serRecord[5 + offset] == 1) ? 14 : 10; + if (nullBitmapSize > 0) { + final byte flagsForField = serRecord[baseOffset + offset + fieldId / 4]; + if ((flagsForField & nullTestCode) == 0) { + // the field value is null + return 0; } - return offset + AInt32SerializerDeserializer.getInt(serRecord, - 14 + offset + nullBitmapSize + (4 * fieldId)); - } else { - if (nullBitmapSize > 0) { - // 9 = tag (1) + record Size (4) + isExpanded (1) + - // number of closed fields (4) - int pos = 10 + offset + fieldId / 4; - if ((serRecord[pos] & nullTestCode) == 0) { - // the field value is null - return 0; - } - if ((serRecord[pos] & missingTestCode) == 0) { - // the field value is missing - return -1; - } + if ((flagsForField & missingTestCode) == 0) { + // the field value is missing + return -1; } - return offset + AInt32SerializerDeserializer.getInt(serRecord, - 10 + offset + nullBitmapSize + (4 * fieldId)); } + return offset + AInt32SerializerDeserializer.getInt(serRecord, + baseOffset + offset + nullBitmapSize + (4 * fieldId)); } else { return -1; } diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java index 68fff2f..78e7306 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java @@ -65,8 +65,6 @@ private final PointableAllocator allocator = new PointableAllocator(); private final ResettableByteArrayOutputStream typeBos = new ResettableByteArrayOutputStream(); - private final DataOutputStream typeDos = new DataOutputStream(typeBos); - private final UTF8StringWriter utf8Writer = new UTF8StringWriter(); private final ResettableByteArrayOutputStream dataBos = new ResettableByteArrayOutputStream(); private final DataOutputStream dataDos = new DataOutputStream(dataBos); @@ -95,8 +93,9 @@ // initialize the buffer for closed parts(fieldName bytes+ type bytes) + // constant(null bytes) - typeBos.reset(); try { + final DataOutputStream typeDos = new DataOutputStream(typeBos); + final UTF8StringWriter utf8Writer = new UTF8StringWriter(); for (int i = 0; i < numberOfSchemaFields; i++) { ATypeTag ftypeTag = fieldTypes[i].getTypeTag(); diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java index ec29857..7c58301 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java @@ -328,8 +328,7 @@ case ANY: return DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE; case UNION: - AUnionType u = (AUnionType) type0; - IAType t1 = u.getActualType(); + IAType t1 = ((AUnionType) type0).getActualType(); if (t1.getTypeTag() == ATypeTag.RECORD) { return (ARecordType) t1; } else if (t1.getTypeTag() == ATypeTag.ANY) { -- To view, visit https://asterix-gerrit.ics.uci.edu/916 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I179a16fc183bd50d5d58cc12321234df1615abfd Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Till Westmann