remove AsterixRuntimeException

Change-Id: Ica9d828bffceabe3b614f68886bc860e34f593b4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/856
Tested-by: Michael Blow <michael.blow@couchbase.com>
Reviewed-by: Michael Blow <michael.blow@couchbase.com>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/LoadRecordFieldsRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/LoadRecordFieldsRule.java
index 598c775..9039097 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/LoadRecordFieldsRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/LoadRecordFieldsRule.java
@@ -28,7 +28,6 @@
 import org.apache.commons.lang3.mutable.MutableObject;
 
 import org.apache.asterix.algebra.base.AsterixOperatorAnnotations;
-import org.apache.asterix.common.exceptions.AsterixRuntimeException;
 import org.apache.asterix.om.base.AString;
 import org.apache.asterix.om.constants.AsterixConstantValue;
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -215,7 +214,7 @@
                         }
                     }
                 }
-                throw new AsterixRuntimeException("Field access " + getFirstExpr(a2)
+                throw new AlgebricksException("Field access " + getFirstExpr(a2)
                         + " does not correspond to any input of operator " + topOp);
             }
         }
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushFieldAccessRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushFieldAccessRule.java
index 58921b4..165d749 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushFieldAccessRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushFieldAccessRule.java
@@ -25,7 +25,6 @@
 
 import org.apache.asterix.algebra.base.AsterixOperatorAnnotations;
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
-import org.apache.asterix.common.exceptions.AsterixRuntimeException;
 import org.apache.asterix.metadata.declared.AqlDataSource;
 import org.apache.asterix.metadata.declared.AqlDataSource.AqlDataSourceType;
 import org.apache.asterix.metadata.declared.AqlMetadataProvider;
@@ -284,7 +283,7 @@
                     }
                 }
             }
-            throw new AsterixRuntimeException("Field access " + access.getExpressions().get(0).getValue()
+            throw new AlgebricksException("Field access " + access.getExpressions().get(0).getValue()
                     + " does not correspond to any input of operator " + op2);
         } else {
             // Check if the accessed field is not one of the partitioning key
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/AsterixRuntimeException.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/AsterixRuntimeException.java
deleted file mode 100644
index f025097..0000000
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/exceptions/AsterixRuntimeException.java
+++ /dev/null
@@ -1,37 +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.common.exceptions;
-
-public class AsterixRuntimeException extends RuntimeException {
-
-    private static final long serialVersionUID = 1L;
-
-    public AsterixRuntimeException() {
-        super();
-    }
-
-    public AsterixRuntimeException(String msg) {
-        super(msg);
-    }
-
-    public AsterixRuntimeException(Throwable cause) {
-        super(cause);
-    }
-
-}
diff --git a/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/similarity/IListIterator.java b/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/similarity/IListIterator.java
index 31f97a1..6c3d22e 100644
--- a/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/similarity/IListIterator.java
+++ b/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/similarity/IListIterator.java
@@ -30,9 +30,9 @@
 
     public boolean hasNext();
 
-    public void next();
+    public void next() throws HyracksDataException;
 
-    public void reset();
+    public void reset() throws HyracksDataException;
 
     public int size();
 }
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndex.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndex.java
index b2dbb8c..0a3d622 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndex.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndex.java
@@ -25,12 +25,12 @@
 import java.util.List;
 
 import org.apache.asterix.common.config.MetadataConstants;
-import org.apache.asterix.common.exceptions.AsterixRuntimeException;
 import org.apache.asterix.common.transactions.DatasetId;
 import org.apache.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
 import org.apache.asterix.formats.nontagged.AqlBinaryHashFunctionFactoryProvider;
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.formats.nontagged.AqlTypeTraitProvider;
+import org.apache.asterix.metadata.MetadataException;
 import org.apache.asterix.metadata.api.IMetadataIndex;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.IAType;
@@ -82,13 +82,13 @@
 
     public MetadataIndex(MetadataIndexImmutableProperties indexImmutableProperties, int numFields, IAType[] keyTypes,
             List<List<String>> keyNames, int numSecondaryIndexKeys, ARecordType payloadType, boolean isPrimaryIndex,
-            int[] primaryKeyIndexes) throws AsterixRuntimeException {
+            int[] primaryKeyIndexes) throws MetadataException {
         // Sanity checks.
         if (keyTypes.length != keyNames.size()) {
-            throw new AsterixRuntimeException("Unequal number of key types and names given.");
+            throw new MetadataException("Unequal number of key types and names given.");
         }
         if (keyTypes.length > numFields) {
-            throw new AsterixRuntimeException("Number of keys given is greater than total number of fields.");
+            throw new MetadataException("Number of keys given is greater than total number of fields.");
         }
         // Set simple fields.
         this.datasetName = indexImmutableProperties.getDatasetName();
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AbstractAsterixListIterator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AbstractAsterixListIterator.java
index 548f7c3..b293fc9 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AbstractAsterixListIterator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AbstractAsterixListIterator.java
@@ -19,7 +19,6 @@
 package org.apache.asterix.runtime.evaluators.common;
 
 import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.common.exceptions.AsterixRuntimeException;
 import org.apache.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
 import org.apache.asterix.fuzzyjoin.similarity.IListIterator;
 import org.apache.asterix.om.types.ATypeTag;
@@ -72,7 +71,7 @@
     }
 
     @Override
-    public void next() {
+    public void next() throws HyracksDataException {
         try {
             pos = nextPos;
             ++count;
@@ -82,12 +81,12 @@
             }
             itemLen = nextPos - pos;
         } catch (AsterixException e) {
-            throw new AsterixRuntimeException(e);
+            throw new HyracksDataException(e);
         }
     }
 
     @Override
-    public void reset() {
+    public void reset() throws HyracksDataException {
         count = 0;
         try {
             pos = getItemOffset(data, startOff, count);
@@ -97,11 +96,11 @@
             }
             itemLen = nextPos - pos;
         } catch (AsterixException e) {
-            throw new AsterixRuntimeException(e);
+            throw new HyracksDataException(e);
         }
     }
 
-    public void reset(byte[] data, int startOff) {
+    public void reset(byte[] data, int startOff) throws HyracksDataException {
         this.data = data;
         this.startOff = startOff;
         this.numberOfItems = getNumberOfItems(data, startOff);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceContainsEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceContainsEvaluator.java
index 4ad06d8..23a01d8 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceContainsEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceContainsEvaluator.java
@@ -46,9 +46,9 @@
                         rightStartOffset + typeIndicatorSize, edThresh);
             }
             case ORDEREDLIST: {
-                firstOrdListIter.reset(leftBytes, leftStartOffset);
-                secondOrdListIter.reset(rightBytes, rightStartOffset);
                 try {
+                    firstOrdListIter.reset(leftBytes, leftStartOffset);
+                    secondOrdListIter.reset(rightBytes, rightStartOffset);
                     return ed.getSimilarityContains(firstOrdListIter, secondOrdListIter, edThresh);
                 } catch (HyracksDataException e) {
                     throw new AlgebricksException(e);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
index e59c04f..92946c6 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
@@ -141,8 +141,12 @@
     }
 
     protected boolean prepareLists(IPointable left, IPointable right, ATypeTag argType) throws AlgebricksException {
-        firstListIter.reset(left.getByteArray(), left.getStartOffset());
-        secondListIter.reset(right.getByteArray(), right.getStartOffset());
+        try {
+            firstListIter.reset(left.getByteArray(), left.getStartOffset());
+            secondListIter.reset(right.getByteArray(), right.getStartOffset());
+        } catch (HyracksDataException e) {
+            throw new AlgebricksException(e);
+        }
         // Check for special case where one of the lists is empty, since list
         // types won't match.
         if (firstListIter.size() == 0 || secondListIter.size() == 0) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
index 3e187a9..c151dbd 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
@@ -26,7 +26,6 @@
 import java.util.Map;
 
 import org.apache.asterix.common.config.GlobalConfig;
-import org.apache.asterix.common.exceptions.AsterixRuntimeException;
 import org.apache.asterix.dataflow.data.nontagged.AqlNullWriterFactory;
 import org.apache.asterix.formats.base.IDataFormat;
 import org.apache.asterix.formats.nontagged.AqlADMPrinterFactoryProvider;
@@ -365,7 +364,7 @@
         IFunctionManager mgr = FunctionManagerHolder.getFunctionManager();
         IFunctionDescriptor fd = mgr.lookupFunction(fnId);
         if (fd == null) {
-            throw new AsterixRuntimeException("Unresolved function " + fnId);
+            throw new AlgebricksException("Unresolved function " + fnId);
         }
         final FunctionIdentifier fid = fd.getIdentifier();
         if (functionTypeInferers.containsKey(fid)) {