asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Till Westmann (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: less code
Date Thu, 09 Jun 2016 19:54:34 GMT
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 <tillw@apache.org>

Mime
View raw message