asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject [1/3] incubator-asterixdb git commit: Some exception cleanup
Date Tue, 02 Feb 2016 05:19:14 GMT
Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master f79a896da -> 9dcba3c9f


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java b/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
index a36238d..ffef923 100644
--- a/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
+++ b/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
@@ -26,7 +26,6 @@ import java.io.DataOutput;
 import java.io.IOException;
 import java.util.Arrays;
 
-import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.dataflow.data.nontagged.serde.SerializerDeserializerUtil;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.ATypeTag;
@@ -177,29 +176,20 @@ public class RecordBuilder implements IARecordBuilder {
     }
 
     @Override
-    public void addField(IValueReference name, IValueReference value) throws AsterixException
{
+    public void addField(IValueReference name, IValueReference value) throws HyracksDataException
{
         if (numberOfOpenFields == openPartOffsets.length) {
             openPartOffsets = Arrays.copyOf(openPartOffsets, openPartOffsets.length + DEFAULT_NUM_OPEN_FIELDS);
             openFieldNameLengths = Arrays.copyOf(openFieldNameLengths,
                     openFieldNameLengths.length + DEFAULT_NUM_OPEN_FIELDS);
         }
-        int fieldNameHashCode;
-        try {
-            fieldNameHashCode = utf8HashFunction.hash(name.getByteArray(), name.getStartOffset()
+ 1,
+        int fieldNameHashCode = utf8HashFunction.hash(name.getByteArray(), name.getStartOffset()
+ 1,
                     name.getLength() - 1);
-        } catch (HyracksDataException e1) {
-            throw new AsterixException(e1);
-        }
         if (recType != null) {
             int cFieldPos;
-            try {
                 cFieldPos = recTypeInfo.getFieldIndex(name.getByteArray(), name.getStartOffset()
+ 1,
                         name.getLength() - 1);
-            } catch (HyracksDataException e) {
-                throw new AsterixException(e);
-            }
             if (cFieldPos >= 0) {
-                throw new AsterixException("Open field \"" + recType.getFieldNames()[cFieldPos]
+                throw new HyracksDataException("Open field \"" + recType.getFieldNames()[cFieldPos]
                         + "\" has the same field name as closed field at index " + cFieldPos);
             }
         }
@@ -212,7 +202,7 @@ public class RecordBuilder implements IARecordBuilder {
     }
 
     @Override
-    public void write(DataOutput out, boolean writeTypeTag) throws IOException, AsterixException
{
+    public void write(DataOutput out, boolean writeTypeTag) throws HyracksDataException {
         int h = headerSize;
         int recordLength;
         // prepare the open part
@@ -231,7 +221,7 @@ public class RecordBuilder implements IARecordBuilder {
                             openBytes, (int) openPartOffsets[i], openFieldNameLengths[i])
== 0) {
                         String field = utf8SerDer.deserialize(new DataInputStream(new ByteArrayInputStream(openBytes,
                                 (int) openPartOffsets[i], openFieldNameLengths[i])));
-                        throw new AsterixException(
+                        throw new HyracksDataException(
                                 "Open fields " + (i - 1) + " and " + i + " have the same
field name \"" + field + "\"");
                     }
                 }
@@ -248,37 +238,46 @@ public class RecordBuilder implements IARecordBuilder {
                 offsetPosition += 8;
             }
             recordLength = openPartOffset + 4 + openPartOffsetArraySize + openPartOutputStream.size();
-        } else
+        } else {
             recordLength = h + numberOfSchemaFields * 4 + closedPartOutputStream.size();
-
-        // write the record header
-        if (writeTypeTag) {
-            out.writeByte(ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
-        }
-        out.writeInt(recordLength);
-        if (isOpen) {
-            if (this.numberOfOpenFields > 0) {
-                out.writeBoolean(true);
-                out.writeInt(openPartOffset);
-            } else
-                out.writeBoolean(false);
         }
+        writeRecord(out, writeTypeTag, h, recordLength);
+    }
 
-        // write the closed part
-        if (numberOfSchemaFields > 0) {
-            out.writeInt(numberOfClosedFields);
-            if (isNullable)
-                out.write(nullBitMap, 0, nullBitMapSize);
-            for (int i = 0; i < numberOfSchemaFields; i++)
-                out.writeInt(closedPartOffsets[i] + h + (numberOfSchemaFields * 4));
-            out.write(closedPartOutputStream.toByteArray());
-        }
+    private void writeRecord(DataOutput out, boolean writeTypeTag, int headerSize, int recordLength)
+            throws HyracksDataException {
+        try {
+            // write the record header
+            if (writeTypeTag) {
+                out.writeByte(ATypeTag.SERIALIZED_RECORD_TYPE_TAG);
+            }
+            out.writeInt(recordLength);
+            if (isOpen) {
+                if (this.numberOfOpenFields > 0) {
+                    out.writeBoolean(true);
+                    out.writeInt(openPartOffset);
+                } else
+                    out.writeBoolean(false);
+            }
 
-        // write the open part
-        if (numberOfOpenFields > 0) {
-            out.writeInt(numberOfOpenFields);
-            out.write(openPartOffsetArray, 0, openPartOffsetArraySize);
-            out.write(openPartOutputStream.toByteArray());
+            // write the closed part
+            if (numberOfSchemaFields > 0) {
+                out.writeInt(numberOfClosedFields);
+                if (isNullable)
+                    out.write(nullBitMap, 0, nullBitMapSize);
+                for (int i = 0; i < numberOfSchemaFields; i++)
+                    out.writeInt(closedPartOffsets[i] + headerSize + (numberOfSchemaFields
* 4));
+                out.write(closedPartOutputStream.toByteArray());
+            }
+
+            // write the open part
+            if (numberOfOpenFields > 0) {
+                out.writeInt(numberOfOpenFields);
+                out.write(openPartOffsetArray, 0, openPartOffsetArraySize);
+                out.write(openPartOutputStream.toByteArray());
+            }
+        } catch (IOException e) {
+            throw new HyracksDataException(e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
index 543b20e..53943b8 100644
--- a/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
+++ b/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
@@ -182,11 +182,7 @@ public class ARecordSerializerDeserializer implements ISerializerDeserializer<AR
                 serializers[fieldIndex].serialize(instance.getValueByPos(fieldIndex), fieldValue.getDataOutput());
                 recordBuilder.addField(fieldIndex, fieldValue);
             }
-            try {
-                recordBuilder.write(out, writeTypeTag);
-            } catch (IOException | AsterixException e) {
-                throw new HyracksDataException(e);
-            }
+            recordBuilder.write(out, writeTypeTag);
         } else {
             throw new NotImplementedException("Serializer for schemaless records is not implemented.");
         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-om/src/main/java/org/apache/asterix/om/base/AMutableInterval.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/om/base/AMutableInterval.java b/asterix-om/src/main/java/org/apache/asterix/om/base/AMutableInterval.java
index fa9b587..15bda6b 100644
--- a/asterix-om/src/main/java/org/apache/asterix/om/base/AMutableInterval.java
+++ b/asterix-om/src/main/java/org/apache/asterix/om/base/AMutableInterval.java
@@ -18,7 +18,7 @@
  */
 package org.apache.asterix.om.base;
 
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 public class AMutableInterval extends AInterval {
 
@@ -26,9 +26,9 @@ public class AMutableInterval extends AInterval {
         super(intervalStart, intervalEnd, typetag);
     }
 
-    public void setValue(long intervalStart, long intervalEnd, byte typetag) throws AlgebricksException
{
+    public void setValue(long intervalStart, long intervalEnd, byte typetag) throws HyracksDataException
{
         if (intervalStart >= intervalEnd) {
-            throw new AlgebricksException("Invalid interval: the starting time should be
less than the ending time.");
+            throw new HyracksDataException("Invalid interval: the starting time should be
less than the ending time.");
         }
         this.intervalStart = intervalStart;
         this.intervalEnd = intervalEnd;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
b/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
index 4f8d1f2..05002a6 100644
--- a/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
+++ b/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
@@ -19,7 +19,6 @@
 
 package org.apache.asterix.om.typecomputer.impl;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -85,16 +84,12 @@ public class RecordAddFieldsTypeComputer implements IResultTypeComputer
{
         Collections.sort(resultFieldNames);
 
         for (String fieldName : resultFieldNames) {
-            try {
-                if (inputRecordType.getFieldType(fieldName).getTypeTag() == ATypeTag.RECORD)
{
-                    ARecordType nestedType = (ARecordType) inputRecordType.getFieldType(fieldName);
-                    //Deep Copy prevents altering of input types
-                    resultFieldTypes.add(nestedType.deepCopy(nestedType));
-                } else {
-                    resultFieldTypes.add(inputRecordType.getFieldType(fieldName));
-                }
-            } catch (IOException e) {
-                throw new IllegalStateException(e);
+            if (inputRecordType.getFieldType(fieldName).getTypeTag() == ATypeTag.RECORD)
{
+                ARecordType nestedType = (ARecordType) inputRecordType.getFieldType(fieldName);
+                //Deep Copy prevents altering of input types
+                resultFieldTypes.add(nestedType.deepCopy(nestedType));
+            } else {
+                resultFieldTypes.add(inputRecordType.getFieldType(fieldName));
             }
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
b/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
index 653b26e..9611b9c 100644
--- a/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
+++ b/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
@@ -19,10 +19,10 @@
 
 package org.apache.asterix.om.typecomputer.impl;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+
 import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
 import org.apache.asterix.om.types.ARecordType;
@@ -54,8 +54,8 @@ public class RecordMergeTypeComputer implements IResultTypeComputer {
         ARecordType recType1 = TypeComputerUtils.extractRecordType(t1);
 
         if (recType0 == null || recType1 == null) {
-            throw new AlgebricksException("record-merge expects possibly NULL records as
arguments, but got (" + t0
-                    + ", " + t1 + ")");
+            throw new AlgebricksException(
+                    "record-merge expects possibly NULL records as arguments, but got ("
+ t0 + ", " + t1 + ")");
         }
 
         List<String> resultFieldNames = new ArrayList<>();
@@ -66,16 +66,12 @@ public class RecordMergeTypeComputer implements IResultTypeComputer {
 
         List<IAType> resultFieldTypes = new ArrayList<>();
         for (String fieldName : resultFieldNames) {
-            try {
-                if (recType0.getFieldType(fieldName).getTypeTag() == ATypeTag.RECORD) {
-                    ARecordType nestedType = (ARecordType) recType0.getFieldType(fieldName);
-                    //Deep Copy prevents altering of input types
-                    resultFieldTypes.add(nestedType.deepCopy(nestedType));
-                } else {
-                    resultFieldTypes.add(recType0.getFieldType(fieldName));
-                }
-            } catch (IOException e) {
-                throw new IllegalStateException(e);
+            if (recType0.getFieldType(fieldName).getTypeTag() == ATypeTag.RECORD) {
+                ARecordType nestedType = (ARecordType) recType0.getFieldType(fieldName);
+                //Deep Copy prevents altering of input types
+                resultFieldTypes.add(nestedType.deepCopy(nestedType));
+            } else {
+                resultFieldTypes.add(recType0.getFieldType(fieldName));
             }
         }
 
@@ -111,7 +107,7 @@ public class RecordMergeTypeComputer implements IResultTypeComputer {
         boolean isOpen = recType0.isOpen() || recType1.isOpen();
 
         IAType resultType = new ARecordType(resultTypeName, resultFieldNames.toArray(new
String[] {}),
-                    resultFieldTypes.toArray(new IAType[] {}), isOpen);
+                resultFieldTypes.toArray(new IAType[] {}), isOpen);
 
         if (nullable) {
             resultType = AUnionType.createNullableType(resultType);
@@ -142,12 +138,12 @@ public class RecordMergeTypeComputer implements IResultTypeComputer
{
                 } else {
                     IAType[] combinedFieldTypes = ArrayUtils.addAll(resultType.getFieldTypes().clone(),
                             fieldType1Copy.getFieldTypes()[i]);
-                    resultType = new ARecordType(resultType.getTypeName(), ArrayUtils.addAll(
-                            resultType.getFieldNames(), fieldType1Copy.getFieldNames()[i]),
combinedFieldTypes,
-                            resultType.isOpen());
+                    resultType = new ARecordType(resultType.getTypeName(),
+                            ArrayUtils.addAll(resultType.getFieldNames(), fieldType1Copy.getFieldNames()[i]),
+                            combinedFieldTypes, resultType.isOpen());
                 }
 
-            } catch (IOException | AsterixException e) {
+            } catch (AsterixException e) {
                 throw new AlgebricksException(e);
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
b/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
index 9f4d155..69a4068 100644
--- a/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
+++ b/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
@@ -19,7 +19,6 @@
 
 package org.apache.asterix.om.typecomputer.impl;
 
-import java.io.IOException;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Deque;
@@ -196,21 +195,15 @@ public class RecordRemoveFieldsTypeComputer implements IResultTypeComputer
{
         return false;
     }
 
-    private void addField(ARecordType inputRecordType,  String fieldName, List<String>
resultFieldNames, List<IAType>
-            resultFieldTypes)
-            throws AlgebricksException {
-        try {
-            resultFieldNames.add(fieldName);
-            if (inputRecordType.getFieldType(fieldName).getTypeTag() == ATypeTag.RECORD)
{
-                ARecordType nestedType = (ARecordType) inputRecordType.getFieldType(fieldName);
-                //Deep Copy prevents altering of input types
-                resultFieldTypes.add(nestedType.deepCopy(nestedType));
-            } else {
-                resultFieldTypes.add(inputRecordType.getFieldType(fieldName));
-            }
-
-        } catch (IOException e) {
-            throw new AlgebricksException(e);
+    private void addField(ARecordType inputRecordType, String fieldName, List<String>
resultFieldNames,
+            List<IAType> resultFieldTypes) throws AlgebricksException {
+        resultFieldNames.add(fieldName);
+        if (inputRecordType.getFieldType(fieldName).getTypeTag() == ATypeTag.RECORD) {
+            ARecordType nestedType = (ARecordType) inputRecordType.getFieldType(fieldName);
+            //Deep Copy prevents altering of input types
+            resultFieldTypes.add(nestedType.deepCopy(nestedType));
+        } else {
+            resultFieldTypes.add(inputRecordType.getFieldType(fieldName));
         }
     }
 
@@ -245,7 +238,7 @@ public class RecordRemoveFieldsTypeComputer implements IResultTypeComputer
{
         String resultTypeName = "result-record(" + inputRecordType.getTypeName() + ")";
 
         return new ARecordType(resultTypeName, resultFieldNames.toArray(new String[n]),
-                    resultFieldTypes.toArray(new IAType[n]), true); // Make the output type
open always
+                resultFieldTypes.toArray(new IAType[n]), true); // Make the output type open
always
 
     }
 
@@ -285,9 +278,8 @@ public class RecordRemoveFieldsTypeComputer implements IResultTypeComputer
{
         A method to deep copy a record the path validation
              i.e., keep only fields that are valid
      */
-    private ARecordType deepCheckAndCopy(Deque<String> fieldPath, ARecordType srcRecType,
List<List<String>>
-            pathList, boolean isOpen)
-            throws AlgebricksException {
+    private ARecordType deepCheckAndCopy(Deque<String> fieldPath, ARecordType srcRecType,
List<List<String>> pathList,
+            boolean isOpen) throws AlgebricksException {
         // Make sure the current path is valid before going further
         if (isRemovePath(fieldPath, pathList)) {
             return null;
@@ -322,7 +314,7 @@ public class RecordRemoveFieldsTypeComputer implements IResultTypeComputer
{
             return null;
         }
         return new ARecordType(srcRecType.getTypeName(), destFieldNames.toArray(new String[n]),
-                    destFieldTypes.toArray(new IAType[n]), isOpen);
+                destFieldTypes.toArray(new IAType[n]), isOpen);
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-om/src/main/java/org/apache/asterix/om/types/AOrderedListType.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/om/types/AOrderedListType.java b/asterix-om/src/main/java/org/apache/asterix/om/types/AOrderedListType.java
index 23e6cf5..e16633e 100644
--- a/asterix-om/src/main/java/org/apache/asterix/om/types/AOrderedListType.java
+++ b/asterix-om/src/main/java/org/apache/asterix/om/types/AOrderedListType.java
@@ -18,11 +18,10 @@
  */
 package org.apache.asterix.om.types;
 
+import org.apache.asterix.om.base.IAObject;
 import org.json.JSONException;
 import org.json.JSONObject;
 
-import org.apache.asterix.om.base.IAObject;
-
 public class AOrderedListType extends AbstractCollectionType {
 
     private static final long serialVersionUID = 1L;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-om/src/main/java/org/apache/asterix/om/types/ARecordType.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/om/types/ARecordType.java b/asterix-om/src/main/java/org/apache/asterix/om/types/ARecordType.java
index 1062b88..c2eae36 100644
--- a/asterix-om/src/main/java/org/apache/asterix/om/types/ARecordType.java
+++ b/asterix-om/src/main/java/org/apache/asterix/om/types/ARecordType.java
@@ -31,8 +31,6 @@ import org.apache.asterix.common.exceptions.AsterixException;
 import org.apache.asterix.om.base.IAObject;
 import org.apache.asterix.om.util.NonTaggedFormatUtil;
 import org.apache.asterix.om.visitors.IOMVisitor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -61,9 +59,6 @@ public class ARecordType extends AbstractComplexType {
      *            the types of the closed fields
      * @param isOpen
      *            whether the record is open
-     * @throws AsterixException
-     *             if there are duplicate field names or if there is an error serializing
the field names
-     * @throws HyracksDataException
      */
     public ARecordType(String typeName, String[] fieldNames, IAType[] fieldTypes, boolean
isOpen) {
         super(typeName);
@@ -128,7 +123,7 @@ public class ARecordType extends AbstractComplexType {
      *            the name of the field whose position is sought
      * @return the position of the field in the closed schema or -1 if the field does not
exist.
      */
-    public int getFieldIndex(String fieldName) throws IOException {
+    public int getFieldIndex(String fieldName) {
         if (fieldNames == null) {
             return -1;
         }
@@ -146,10 +141,9 @@ public class ARecordType extends AbstractComplexType {
      * @param parent
      *            The type of the parent
      * @return the type of the child
-     * @throws IOException
      */
 
-    public IAType getSubFieldType(List<String> subFieldName, IAType parent) throws
IOException {
+    public IAType getSubFieldType(List<String> subFieldName, IAType parent) {
         ARecordType subRecordType = (ARecordType) parent;
         for (int i = 0; i < subFieldName.size() - 1; i++) {
             subRecordType = (ARecordType) subRecordType.getFieldType(subFieldName.get(i));
@@ -189,10 +183,8 @@ public class ARecordType extends AbstractComplexType {
      * @param fieldName
      *            the fieldName whose type is sought
      * @return the field type of the field name if it exists, otherwise null
-     * @throws IOException
-     *             if an error occurs while serializing the field name
      */
-    public IAType getFieldType(String fieldName) throws IOException {
+    public IAType getFieldType(String fieldName) {
         int fieldPos = getFieldIndex(fieldName);
         if (fieldPos < 0 || fieldPos >= fieldTypes.length) {
             return null;
@@ -206,9 +198,8 @@ public class ARecordType extends AbstractComplexType {
      * @param fieldName
      *            the name of the field to check
      * @return true if fieldName is a closed field, otherwise false
-     * @throws IOException
      */
-    public boolean isClosedField(String fieldName) throws IOException {
+    public boolean isClosedField(String fieldName) {
         return getFieldIndex(fieldName) != -1;
     }
 
@@ -221,7 +212,7 @@ public class ARecordType extends AbstractComplexType {
         return false;
     }
 
-    public ARecordType deepCopy(ARecordType type) throws AlgebricksException {
+    public ARecordType deepCopy(ARecordType type) {
         IAType[] newTypes = new IAType[type.fieldNames.length];
         for (int i = 0; i < type.fieldTypes.length; i++) {
             if (type.fieldTypes[i].getTypeTag() == ATypeTag.RECORD) {

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-om/src/main/java/org/apache/asterix/om/types/AUnorderedListType.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/om/types/AUnorderedListType.java
b/asterix-om/src/main/java/org/apache/asterix/om/types/AUnorderedListType.java
index ab7bba5..80b13b5 100644
--- a/asterix-om/src/main/java/org/apache/asterix/om/types/AUnorderedListType.java
+++ b/asterix-om/src/main/java/org/apache/asterix/om/types/AUnorderedListType.java
@@ -18,11 +18,10 @@
  */
 package org.apache.asterix.om.types;
 
+import org.apache.asterix.om.base.IAObject;
 import org.json.JSONException;
 import org.json.JSONObject;
 
-import org.apache.asterix.om.base.IAObject;
-
 public class AUnorderedListType extends AbstractCollectionType {
 
     private static final long serialVersionUID = 1L;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-om/src/main/java/org/apache/asterix/om/types/EnumDeserializer.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/om/types/EnumDeserializer.java b/asterix-om/src/main/java/org/apache/asterix/om/types/EnumDeserializer.java
index cf516af..8ec8989 100644
--- a/asterix-om/src/main/java/org/apache/asterix/om/types/EnumDeserializer.java
+++ b/asterix-om/src/main/java/org/apache/asterix/om/types/EnumDeserializer.java
@@ -23,7 +23,8 @@ import java.util.Map;
 
 public class EnumDeserializer<E extends Enum<E> & IEnumSerializer> {
 
-    public static final EnumDeserializer<ATypeTag> ATYPETAGDESERIALIZER = new EnumDeserializer<ATypeTag>(ATypeTag.class);
+    public static final EnumDeserializer<ATypeTag> ATYPETAGDESERIALIZER = new EnumDeserializer<ATypeTag>(
+            ATypeTag.class);
 
     private Map<Byte, E> enumvalMap = new HashMap<Byte, E>();
 

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-om/src/main/java/org/apache/asterix/om/types/TypeHierarchy.java
----------------------------------------------------------------------
diff --git a/asterix-om/src/main/java/org/apache/asterix/om/types/TypeHierarchy.java b/asterix-om/src/main/java/org/apache/asterix/om/types/TypeHierarchy.java
deleted file mode 100644
index ded3d5c..0000000
--- a/asterix-om/src/main/java/org/apache/asterix/om/types/TypeHierarchy.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.
- */
-package org.apache.asterix.om.types;
-
-import java.util.Hashtable;
-
-/*
- * Author: Guangqiang Li
- * Created on Sep 24, 2009
- */
-public class TypeHierarchy {
-    private static Hashtable<String, String> parentMap = new Hashtable<String, String>();
-    static {
-        parentMap.put("integer", "decimal");
-        parentMap.put("double", "decimal");
-        parentMap.put("decimal", "numeric");
-    }
-
-    public static boolean isSubType(String sub, String par) {
-        String parent = parentMap.get(sub);
-        if (parent != null)
-            if (parent.equals(par))
-                return true;
-            else
-                return isSubType(parent, par);
-        return false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
index 55e7d15..ed8ce03 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
@@ -30,6 +30,7 @@ import org.apache.asterix.om.types.ATypeTag;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IDataOutputProvider;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
@@ -91,7 +92,7 @@ public class ClosedRecordConstructorEvalFactory implements ICopyEvaluatorFactory
                     }
                 }
                 recBuilder.write(out, true);
-            } catch (IOException | AsterixException e) {
+            } catch (HyracksDataException e) {
                 throw new AlgebricksException(e);
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
index 6117452..66631d5 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
@@ -34,6 +34,7 @@ import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
 import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluator;
 import org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.data.std.api.IDataOutputProvider;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
@@ -107,7 +108,7 @@ public class OpenRecordConstructorDescriptor extends AbstractScalarFunctionDynam
                                 }
                             }
                             recBuilder.write(out, true);
-                        } catch (IOException | AsterixException e) {
+                        } catch (HyracksDataException e) {
                             throw new AlgebricksException(e);
                         }
                     }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
index d9323a5..9e7c4ac 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
@@ -184,7 +184,7 @@ public class RecordAddFieldsDescriptor extends AbstractScalarFunctionDynamicDesc
                             }
                             addFields(recordPointable, listPointable);
                             recordBuilder.write(output.getDataOutput(), true);
-                        } catch (IOException | AsterixException e) {
+                        } catch (HyracksDataException e) {
                             throw new AlgebricksException(e);
                         }
                     }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/9dcba3c9/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
----------------------------------------------------------------------
diff --git a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
index 73d5cd9..2e493c5 100644
--- a/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
+++ b/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
@@ -168,8 +168,8 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                         switch (type2) {
                             case YEARMONTHDURATION:
 
-                                yearMonth = AYearMonthDurationSerializerDeserializer.getYearMonth(
-                                        argOut2.getByteArray(), 1);
+                                yearMonth = AYearMonthDurationSerializerDeserializer
+                                        .getYearMonth(argOut2.getByteArray(), 1);
 
                                 int yearStart = GREG_CAL.getYear(chrononToStart);
                                 int monthStart = GREG_CAL.getMonthOfYear(chrononToStart,
yearStart);
@@ -182,13 +182,13 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                         + ((totalMonths < 0 && totalMonths % yearMonth
!= 0) ? -1 : 0);
 
                                 if (binIndex > Integer.MAX_VALUE) {
-                                    throw new AlgebricksException(getIdentifier().getName()
-                                            + ": Overflowing time value to be binned!");
+                                    throw new AlgebricksException(
+                                            getIdentifier().getName() + ": Overflowing time
value to be binned!");
                                 }
 
                                 if (binIndex < Integer.MIN_VALUE) {
-                                    throw new AlgebricksException(getIdentifier().getName()
-                                            + ": Underflowing time value to be binned!");
+                                    throw new AlgebricksException(
+                                            getIdentifier().getName() + ": Underflowing time
value to be binned!");
                                 }
 
                                 break;
@@ -210,43 +210,42 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                 }
                                 return;
                             default:
-                                throw new AlgebricksException(
-                                        getIdentifier().getName()
-                                                + ": expecting YEARMONTHDURATION/DAYTIMEDURATION
for the thrid argument but got "
-                                                + type2);
+                                throw new AlgebricksException(getIdentifier().getName()
+                                        + ": expecting YEARMONTHDURATION/DAYTIMEDURATION
for the thrid argument but got "
+                                        + type2);
                         }
 
                         switch (type0) {
                             case DATE:
-                                binStartChronon = DurationArithmeticOperations.addDuration(chrononToStart,
yearMonth
-                                        * (int) binIndex, dayTime * binIndex, false);
-                                binEndChronon = DurationArithmeticOperations.addDuration(chrononToStart,
yearMonth
-                                        * ((int) binIndex + 1), dayTime * (binIndex + 1),
false);
-
-                                binStartChronon = binStartChronon
-                                        / GregorianCalendarSystem.CHRONON_OF_DAY
-                                        + ((binStartChronon < 0 && binStartChronon
-                                                % GregorianCalendarSystem.CHRONON_OF_DAY
!= 0) ? -1 : 0);
-                                binEndChronon = binEndChronon
-                                        / GregorianCalendarSystem.CHRONON_OF_DAY
-                                        + ((binEndChronon < 0 && binEndChronon
% GregorianCalendarSystem.CHRONON_OF_DAY != 0) ? -1
-                                                : 0);
+                                binStartChronon = DurationArithmeticOperations.addDuration(chrononToStart,
+                                        yearMonth * (int) binIndex, dayTime * binIndex, false);
+                                binEndChronon = DurationArithmeticOperations.addDuration(chrononToStart,
+                                        yearMonth * ((int) binIndex + 1), dayTime * (binIndex
+ 1), false);
+
+                                binStartChronon = binStartChronon / GregorianCalendarSystem.CHRONON_OF_DAY
+                                        + ((binStartChronon < 0
+                                                && binStartChronon % GregorianCalendarSystem.CHRONON_OF_DAY
!= 0) ? -1
+                                                        : 0);
+                                binEndChronon = binEndChronon / GregorianCalendarSystem.CHRONON_OF_DAY
+                                        + ((binEndChronon < 0
+                                                && binEndChronon % GregorianCalendarSystem.CHRONON_OF_DAY
!= 0) ? -1
+                                                        : 0);
                                 break;
                             case TIME:
                                 if (yearMonth != 0) {
                                     throw new AlgebricksException(getIdentifier().getName()
                                             + ": cannot create year-month bin for a time
value");
                                 }
-                                binStartChronon = DurationArithmeticOperations.addDuration(chrononToStart,
yearMonth
-                                        * (int) binIndex, dayTime * binIndex, true);
-                                binEndChronon = DurationArithmeticOperations.addDuration(chrononToStart,
yearMonth
-                                        * ((int) binIndex + 1), dayTime * (binIndex + 1),
true);
+                                binStartChronon = DurationArithmeticOperations.addDuration(chrononToStart,
+                                        yearMonth * (int) binIndex, dayTime * binIndex, true);
+                                binEndChronon = DurationArithmeticOperations.addDuration(chrononToStart,
+                                        yearMonth * ((int) binIndex + 1), dayTime * (binIndex
+ 1), true);
                                 break;
                             case DATETIME:
-                                binStartChronon = DurationArithmeticOperations.addDuration(chrononToStart,
yearMonth
-                                        * (int) binIndex, dayTime * binIndex, false);
-                                binEndChronon = DurationArithmeticOperations.addDuration(chrononToStart,
yearMonth
-                                        * ((int) binIndex + 1), dayTime * (binIndex + 1),
false);
+                                binStartChronon = DurationArithmeticOperations.addDuration(chrononToStart,
+                                        yearMonth * (int) binIndex, dayTime * binIndex, false);
+                                binEndChronon = DurationArithmeticOperations.addDuration(chrononToStart,
+                                        yearMonth * ((int) binIndex + 1), dayTime * (binIndex
+ 1), false);
                                 break;
                             case NULL:
                                 try {
@@ -260,14 +259,13 @@ public class IntervalBinDescriptor extends AbstractScalarFunctionDynamicDescript
                                         + ": the first argument should be DATE/TIME/DATETIME/NULL
but got " + type0);
 
                         }
-                        aInterval.setValue(binStartChronon, binEndChronon, type0.serialize());
                         try {
+                            aInterval.setValue(binStartChronon, binEndChronon, type0.serialize());
                             intervalSerde.serialize(aInterval, out);
                             return;
                         } catch (HyracksDataException ex) {
                             throw new AlgebricksException(ex);
                         }
-
                     }
                 };
             }



Mime
View raw message