Repository: asterixdb Updated Branches: refs/heads/master 7ccbdb6f1 -> 75d32e50d
Reduce exception wrapping for casting and printing Change-Id: I1911125b2fa93b743bea8cd16211e3bd464dbf1e Reviewed-on: https://asterix-gerrit.ics.uci.edu/1782 Sonar-Qube: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> BAD: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: abdullah alamoudi <bamou...@gmail.com> Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/75d32e50 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/75d32e50 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/75d32e50 Branch: refs/heads/master Commit: 75d32e50ddbd14e526135445978957a685466376 Parents: 7ccbdb6 Author: Till Westmann <ti...@tcbm.hq.couchbase.com> Authored: Fri May 26 20:07:51 2017 -0700 Committer: Till Westmann <ti...@apache.org> Committed: Fri May 26 23:03:44 2017 -0700 ---------------------------------------------------------------------- .../src/test/resources/runtimets/testsuite.xml | 2 +- .../library/java/JObjectPointableVisitor.java | 24 ++------ .../printers/adm/AObjectPrinterFactory.java | 35 +++++------ .../adm/AOrderedlistPrinterFactory.java | 11 +--- .../printers/adm/ARecordPrinterFactory.java | 11 +--- .../adm/AUnorderedlistPrinterFactory.java | 11 +--- .../printers/csv/AObjectPrinterFactory.java | 19 +++--- .../printers/csv/ARecordPrinterFactory.java | 11 +--- .../json/clean/AObjectPrinterFactory.java | 35 +++++------ .../json/clean/AOrderedlistPrinterFactory.java | 11 +--- .../json/clean/ARecordPrinterFactory.java | 11 +--- .../json/lossless/AObjectPrinterFactory.java | 35 +++++------ .../lossless/AOrderedlistPrinterFactory.java | 11 +--- .../json/lossless/ARecordPrinterFactory.java | 11 +--- .../om/pointables/AFlatValuePointable.java | 4 +- .../om/pointables/AListVisitablePointable.java | 4 +- .../pointables/ARecordVisitablePointable.java | 4 +- .../om/pointables/base/IVisitablePointable.java | 4 +- .../om/pointables/cast/ACastVisitor.java | 32 ++++------ .../asterix/om/pointables/cast/AListCaster.java | 4 +- .../om/pointables/cast/ARecordCaster.java | 45 +++++++-------- .../om/pointables/printer/AListPrinter.java | 5 +- .../om/pointables/printer/ARecordPrinter.java | 6 +- .../printer/AbstractPrintVisitor.java | 45 +++++---------- .../pointables/printer/csv/APrintVisitor.java | 4 +- .../visitor/IVisitablePointableVisitor.java | 8 +-- .../om/types/hierachy/ATypeHierarchy.java | 2 +- .../visitors/DeepEqualityVisitor.java | 61 ++++++++------------ .../visitors/ListDeepEqualityChecker.java | 8 +-- .../visitors/RecordDeepEqualityChecker.java | 5 +- 30 files changed, 186 insertions(+), 293 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml index d5b8e74..be6827f 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite.xml @@ -4878,7 +4878,7 @@ <test-case FilePath="open-closed"> <compilation-unit name="query-issue487"><!-- This test case is never run!!!! --> <output-dir compare="Text">query-issue487</output-dir> - <expected-error>org.apache.asterix.common.exceptions.AsterixException</expected-error> + <expected-error>type mismatch: missing a required closed field name: string</expected-error> </compilation-unit> </test-case> <test-case FilePath="open-closed"> http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectPointableVisitor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectPointableVisitor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectPointableVisitor.java index 1a75115..dc8e461 100644 --- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectPointableVisitor.java +++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectPointableVisitor.java @@ -45,39 +45,31 @@ public class JObjectPointableVisitor implements IVisitablePointableVisitor<IJObj private final Map<IVisitablePointable, IJListAccessor> laccessorToPrinter = new HashMap<IVisitablePointable, IJListAccessor>(); @Override - public IJObject visit(AListVisitablePointable accessor, TypeInfo arg) throws AsterixException { + public IJObject visit(AListVisitablePointable accessor, TypeInfo arg) throws HyracksDataException { IJObject result = null; IJListAccessor jListAccessor = laccessorToPrinter.get(accessor); if (jListAccessor == null) { jListAccessor = new JListAccessor(arg.getObjectPool()); laccessorToPrinter.put(accessor, jListAccessor); } - try { - result = jListAccessor.access(accessor, arg.getObjectPool(), arg.getAtype(), this); - } catch (Exception e) { - throw new AsterixException(e); - } + result = jListAccessor.access(accessor, arg.getObjectPool(), arg.getAtype(), this); return result; } @Override - public IJObject visit(ARecordVisitablePointable accessor, TypeInfo arg) throws AsterixException { + public IJObject visit(ARecordVisitablePointable accessor, TypeInfo arg) throws HyracksDataException { IJObject result = null; IJRecordAccessor jRecordAccessor = raccessorToJObject.get(accessor); if (jRecordAccessor == null) { jRecordAccessor = new JRecordAccessor(accessor.getInputRecordType(), arg.getObjectPool()); raccessorToJObject.put(accessor, jRecordAccessor); } - try { - result = jRecordAccessor.access(accessor, arg.getObjectPool(), (ARecordType) arg.getAtype(), this); - } catch (Exception e) { - throw new AsterixException(e); - } + result = jRecordAccessor.access(accessor, arg.getObjectPool(), (ARecordType) arg.getAtype(), this); return result; } @Override - public IJObject visit(AFlatValuePointable accessor, TypeInfo arg) throws AsterixException { + public IJObject visit(AFlatValuePointable accessor, TypeInfo arg) throws HyracksDataException { ATypeTag typeTag = arg.getTypeTag(); IJObject result = null; IJObjectAccessor jObjectAccessor = flatJObjectAccessors.get(typeTag); @@ -86,11 +78,7 @@ public class JObjectPointableVisitor implements IVisitablePointableVisitor<IJObj flatJObjectAccessors.put(typeTag, jObjectAccessor); } - try { - result = jObjectAccessor.access(accessor, arg.getObjectPool()); - } catch (HyracksDataException e) { - throw new AsterixException(e); - } + result = jObjectAccessor.access(accessor, arg.getObjectPool()); return result; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java index bb33fba..9e81b19 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.adm; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.AListVisitablePointable; import org.apache.asterix.om.pointables.ARecordVisitablePointable; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; @@ -139,25 +138,21 @@ public class AObjectPrinterFactory implements IPrinterFactory { if (!printFlatValue(typeTag, b, s, l, ps)) { streamTag.first = ps; streamTag.second = typeTag; - try { - switch (typeTag) { - case OBJECT: - rPointable.set(b, s, l); - visitor.visit(rPointable, streamTag); - break; - case ARRAY: - olPointable.set(b, s, l); - visitor.visit(olPointable, streamTag); - break; - case MULTISET: - ulPointable.set(b, s, l); - visitor.visit(ulPointable, streamTag); - break; - default: - throw new HyracksDataException("No printer for type " + typeTag); - } - } catch (AsterixException e) { - throw new HyracksDataException(e); + switch (typeTag) { + case OBJECT: + rPointable.set(b, s, l); + visitor.visit(rPointable, streamTag); + break; + case ARRAY: + olPointable.set(b, s, l); + visitor.visit(olPointable, streamTag); + break; + case MULTISET: + ulPointable.set(b, s, l); + visitor.visit(ulPointable, streamTag); + break; + default: + throw new HyracksDataException("No printer for type " + typeTag); } } }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java index c71225f..0eef522 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AOrderedlistPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.adm; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.PointableAllocator; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; import org.apache.asterix.om.pointables.base.IVisitablePointable; @@ -59,13 +58,9 @@ public class AOrderedlistPrinterFactory implements IPrinterFactory { @Override public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException { - try { - listAccessor.set(b, start, l); - arg.first = ps; - listAccessor.accept(printVisitor, arg); - } catch (AsterixException e) { - throw new HyracksDataException(e); - } + listAccessor.set(b, start, l); + arg.first = ps; + listAccessor.accept(printVisitor, arg); } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java index 4e54d3f..0ea2d96 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ARecordPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.adm; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.PointableAllocator; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; import org.apache.asterix.om.pointables.base.IVisitablePointable; @@ -59,13 +58,9 @@ public class ARecordPrinterFactory implements IPrinterFactory { @Override public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException { - try { - recAccessor.set(b, start, l); - arg.first = ps; - recAccessor.accept(printVisitor, arg); - } catch (AsterixException e) { - throw new HyracksDataException(e); - } + recAccessor.set(b, start, l); + arg.first = ps; + recAccessor.accept(printVisitor, arg); } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java index d38faf9..66f571f 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AUnorderedlistPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.adm; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.PointableAllocator; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; import org.apache.asterix.om.pointables.base.IVisitablePointable; @@ -59,13 +58,9 @@ public class AUnorderedlistPrinterFactory implements IPrinterFactory { @Override public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException { - try { - listAccessor.set(b, start, l); - arg.first = ps; - listAccessor.accept(printVisitor, arg); - } catch (AsterixException e) { - throw new HyracksDataException(e); - } + listAccessor.set(b, start, l); + arg.first = ps; + listAccessor.accept(printVisitor, arg); } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java index 4018c58..2fddc83 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.csv; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.ARecordVisitablePointable; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; import org.apache.asterix.om.pointables.printer.IPrintVisitor; @@ -131,17 +130,13 @@ public class AObjectPrinterFactory implements IPrinterFactory { if (!printFlatValue(typeTag, b, s, l, ps)) { streamTag.first = ps; streamTag.second = typeTag; - try { - switch (typeTag) { - case OBJECT: - rPointable.set(b, s, l); - visitor.visit(rPointable, streamTag); - break; - default: - throw new HyracksDataException("No printer for type " + typeTag); - } - } catch (AsterixException e) { - throw new HyracksDataException(e); + switch (typeTag) { + case OBJECT: + rPointable.set(b, s, l); + visitor.visit(rPointable, streamTag); + break; + default: + throw new HyracksDataException("No printer for type " + typeTag); } } }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java index 3c4cf3e..bf55410 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ARecordPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.csv; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.PointableAllocator; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; import org.apache.asterix.om.pointables.base.IVisitablePointable; @@ -59,13 +58,9 @@ public class ARecordPrinterFactory implements IPrinterFactory { @Override public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException { - try { - recAccessor.set(b, start, l); - arg.first = ps; - recAccessor.accept(printVisitor, arg); - } catch (AsterixException e) { - throw new HyracksDataException(e); - } + recAccessor.set(b, start, l); + arg.first = ps; + recAccessor.accept(printVisitor, arg); } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java index fe089f9..624613a 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.json.clean; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.AListVisitablePointable; import org.apache.asterix.om.pointables.ARecordVisitablePointable; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; @@ -136,25 +135,21 @@ public class AObjectPrinterFactory implements IPrinterFactory { if (!printFlatValue(typeTag, b, s, l, ps)) { streamTag.first = ps; streamTag.second = typeTag; - try { - switch (typeTag) { - case OBJECT: - rPointable.set(b, s, l); - visitor.visit(rPointable, streamTag); - break; - case ARRAY: - olPointable.set(b, s, l); - visitor.visit(olPointable, streamTag); - break; - case MULTISET: - ulPointable.set(b, s, l); - visitor.visit(ulPointable, streamTag); - break; - default: - throw new HyracksDataException("No printer for type " + typeTag); - } - } catch (AsterixException e) { - throw new HyracksDataException(e); + switch (typeTag) { + case OBJECT: + rPointable.set(b, s, l); + visitor.visit(rPointable, streamTag); + break; + case ARRAY: + olPointable.set(b, s, l); + visitor.visit(olPointable, streamTag); + break; + case MULTISET: + ulPointable.set(b, s, l); + visitor.visit(ulPointable, streamTag); + break; + default: + throw new HyracksDataException("No printer for type " + typeTag); } } }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java index 5638909..a6e3347 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AOrderedlistPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.json.clean; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.PointableAllocator; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; import org.apache.asterix.om.pointables.base.IVisitablePointable; @@ -59,13 +58,9 @@ public class AOrderedlistPrinterFactory implements IPrinterFactory { @Override public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException { - try { - listAccessor.set(b, start, l); - arg.first = ps; - listAccessor.accept(printVisitor, arg); - } catch (AsterixException e) { - throw new HyracksDataException(e); - } + listAccessor.set(b, start, l); + arg.first = ps; + listAccessor.accept(printVisitor, arg); } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java index bfad4ab..430bf66 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ARecordPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.json.clean; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.PointableAllocator; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; import org.apache.asterix.om.pointables.base.IVisitablePointable; @@ -59,13 +58,9 @@ public class ARecordPrinterFactory implements IPrinterFactory { @Override public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException { - try { - recAccessor.set(b, start, l); - arg.first = ps; - recAccessor.accept(printVisitor, arg); - } catch (AsterixException e) { - throw new HyracksDataException(e); - } + recAccessor.set(b, start, l); + arg.first = ps; + recAccessor.accept(printVisitor, arg); } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java index 653e483..947229c 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.AListVisitablePointable; import org.apache.asterix.om.pointables.ARecordVisitablePointable; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; @@ -136,25 +135,21 @@ public class AObjectPrinterFactory implements IPrinterFactory { if (!printFlatValue(typeTag, b, s, l, ps)) { streamTag.first = ps; streamTag.second = typeTag; - try { - switch (typeTag) { - case OBJECT: - rPointable.set(b, s, l); - visitor.visit(rPointable, streamTag); - break; - case ARRAY: - olPointable.set(b, s, l); - visitor.visit(olPointable, streamTag); - break; - case MULTISET: - ulPointable.set(b, s, l); - visitor.visit(ulPointable, streamTag); - break; - default: - throw new HyracksDataException("No printer for type " + typeTag); - } - } catch (AsterixException e) { - throw new HyracksDataException(e); + switch (typeTag) { + case OBJECT: + rPointable.set(b, s, l); + visitor.visit(rPointable, streamTag); + break; + case ARRAY: + olPointable.set(b, s, l); + visitor.visit(olPointable, streamTag); + break; + case MULTISET: + ulPointable.set(b, s, l); + visitor.visit(ulPointable, streamTag); + break; + default: + throw new HyracksDataException("No printer for type " + typeTag); } } }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java index 5f51110..7c210b6 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AOrderedlistPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.PointableAllocator; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; import org.apache.asterix.om.pointables.base.IVisitablePointable; @@ -59,13 +58,9 @@ public class AOrderedlistPrinterFactory implements IPrinterFactory { @Override public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException { - try { - listAccessor.set(b, start, l); - arg.first = ps; - listAccessor.accept(printVisitor, arg); - } catch (AsterixException e) { - throw new HyracksDataException(e); - } + listAccessor.set(b, start, l); + arg.first = ps; + listAccessor.accept(printVisitor, arg); } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java index 19a03b2..4bab638 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ARecordPrinterFactory.java @@ -20,7 +20,6 @@ package org.apache.asterix.dataflow.data.nontagged.printers.json.lossless; import java.io.PrintStream; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.PointableAllocator; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; import org.apache.asterix.om.pointables.base.IVisitablePointable; @@ -59,13 +58,9 @@ public class ARecordPrinterFactory implements IPrinterFactory { @Override public void print(byte[] b, int start, int l, PrintStream ps) throws HyracksDataException { - try { - recAccessor.set(b, start, l); - arg.first = ps; - recAccessor.accept(printVisitor, arg); - } catch (AsterixException e) { - throw new HyracksDataException(e); - } + recAccessor.set(b, start, l); + arg.first = ps; + recAccessor.accept(printVisitor, arg); } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AFlatValuePointable.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AFlatValuePointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AFlatValuePointable.java index 3f27983..86a8a29 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AFlatValuePointable.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AFlatValuePointable.java @@ -19,11 +19,11 @@ package org.apache.asterix.om.pointables; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.base.IVisitablePointable; import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor; import org.apache.asterix.om.types.IAType; import org.apache.asterix.om.util.container.IObjectFactory; +import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.data.std.api.IValueReference; /** @@ -79,7 +79,7 @@ public class AFlatValuePointable extends AbstractVisitablePointable { } @Override - public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException { + public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws HyracksDataException { return vistor.visit(this, tag); } } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AListVisitablePointable.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AListVisitablePointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AListVisitablePointable.java index ec9bf48..5b85d00 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AListVisitablePointable.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/AListVisitablePointable.java @@ -23,7 +23,6 @@ import java.io.DataOutputStream; import java.util.ArrayList; import java.util.List; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer; import org.apache.asterix.om.pointables.base.IVisitablePointable; import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor; @@ -35,6 +34,7 @@ import org.apache.asterix.om.types.IAType; import org.apache.asterix.om.util.container.IObjectFactory; import org.apache.asterix.om.utils.NonTaggedFormatUtil; import org.apache.asterix.om.utils.ResettableByteArrayOutputStream; +import org.apache.hyracks.api.exceptions.HyracksDataException; /** * This class interprets the binary data representation of a list, one can @@ -157,7 +157,7 @@ public class AListVisitablePointable extends AbstractVisitablePointable { } @Override - public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException { + public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws HyracksDataException { return vistor.visit(this, tag); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java ---------------------------------------------------------------------- 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 066d562..45e56aba 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 @@ -24,7 +24,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer; import org.apache.asterix.om.pointables.base.IVisitablePointable; import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor; @@ -36,6 +35,7 @@ import org.apache.asterix.om.types.IAType; import org.apache.asterix.om.util.container.IObjectFactory; import org.apache.asterix.om.utils.NonTaggedFormatUtil; import org.apache.asterix.om.utils.ResettableByteArrayOutputStream; +import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.util.string.UTF8StringWriter; /** @@ -295,7 +295,7 @@ public class ARecordVisitablePointable extends AbstractVisitablePointable { } @Override - public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException { + public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws HyracksDataException { return vistor.visit(this, tag); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/base/IVisitablePointable.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/base/IVisitablePointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/base/IVisitablePointable.java index a744856..bc5bfe5 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/base/IVisitablePointable.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/base/IVisitablePointable.java @@ -19,8 +19,8 @@ package org.apache.asterix.om.pointables.base; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor; +import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.data.std.api.IPointable; /** @@ -29,5 +29,5 @@ import org.apache.hyracks.data.std.api.IPointable; */ public interface IVisitablePointable extends IPointable { - public <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws AsterixException; + <R, T> R accept(IVisitablePointableVisitor<R, T> vistor, T tag) throws HyracksDataException; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ACastVisitor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ACastVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ACastVisitor.java index e57fa06..5f0b0a9 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ACastVisitor.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ACastVisitor.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.AFlatValuePointable; import org.apache.asterix.om.pointables.AListVisitablePointable; import org.apache.asterix.om.pointables.ARecordVisitablePointable; @@ -37,6 +36,7 @@ import org.apache.asterix.om.types.EnumDeserializer; import org.apache.asterix.om.types.IAType; import org.apache.asterix.om.types.hierachy.ATypeHierarchy; import org.apache.hyracks.algebricks.common.utils.Triple; +import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.data.std.util.ArrayBackedValueStorage; /** @@ -58,46 +58,38 @@ public class ACastVisitor implements IVisitablePointableVisitor<Void, Triple<IVi @Override public Void visit(AListVisitablePointable accessor, Triple<IVisitablePointable, IAType, Boolean> arg) - throws AsterixException { + throws HyracksDataException { AListCaster caster = laccessorToCaster.get(accessor); if (caster == null) { caster = new AListCaster(); laccessorToCaster.put(accessor, caster); } - try { - if (arg.second.getTypeTag().equals(ATypeTag.ANY)) { - arg.second = DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_TYPE; - } - caster.castList(accessor, arg.first, (AbstractCollectionType) arg.second, this); - } catch (Exception e) { - throw new AsterixException(e); + if (arg.second.getTypeTag().equals(ATypeTag.ANY)) { + arg.second = DefaultOpenFieldType.NESTED_OPEN_AUNORDERED_LIST_TYPE; } + caster.castList(accessor, arg.first, (AbstractCollectionType) arg.second, this); return null; } @Override public Void visit(ARecordVisitablePointable accessor, Triple<IVisitablePointable, IAType, Boolean> arg) - throws AsterixException { + throws HyracksDataException { ARecordCaster caster = raccessorToCaster.get(accessor); if (caster == null) { caster = new ARecordCaster(); raccessorToCaster.put(accessor, caster); } - try { - if (arg.second.getTypeTag().equals(ATypeTag.ANY)) { - arg.second = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE; - } - ARecordType resultType = (ARecordType) arg.second; - caster.castRecord(accessor, arg.first, resultType, this); - } catch (Exception e) { - throw new AsterixException(e); + if (arg.second.getTypeTag().equals(ATypeTag.ANY)) { + arg.second = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE; } + ARecordType resultType = (ARecordType) arg.second; + caster.castRecord(accessor, arg.first, resultType, this); return null; } @Override public Void visit(AFlatValuePointable accessor, Triple<IVisitablePointable, IAType, Boolean> arg) - throws AsterixException { + throws HyracksDataException { if (arg.second == null) { // for open type case arg.first.set(accessor); @@ -121,7 +113,7 @@ public class ACastVisitor implements IVisitablePointableVisitor<Void, Triple<IVi accessor.getLength(), reqTypeTag, castBuffer.getDataOutput()); arg.first.set(castBuffer); } catch (IOException e1) { - throw new AsterixException( + throw new HyracksDataException( "Type mismatch: cannot cast the " + inputTypeTag + " type to the " + reqTypeTag + " type."); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/AListCaster.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/AListCaster.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/AListCaster.java index 52d5b9f..9635ac7 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/AListCaster.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/AListCaster.java @@ -26,7 +26,6 @@ import java.util.List; import org.apache.asterix.builders.OrderedListBuilder; import org.apache.asterix.builders.UnorderedListBuilder; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.AListVisitablePointable; import org.apache.asterix.om.pointables.PointableAllocator; import org.apache.asterix.om.pointables.base.DefaultOpenFieldType; @@ -37,6 +36,7 @@ import org.apache.asterix.om.types.EnumDeserializer; import org.apache.asterix.om.types.IAType; import org.apache.asterix.om.utils.ResettableByteArrayOutputStream; import org.apache.hyracks.algebricks.common.utils.Triple; +import org.apache.hyracks.api.exceptions.HyracksDataException; /** * This class is to do the runtime type cast for a list. It is ONLY visible to @@ -57,7 +57,7 @@ class AListCaster { private IAType reqItemType; public void castList(AListVisitablePointable listAccessor, IVisitablePointable resultAccessor, - AbstractCollectionType reqType, ACastVisitor visitor) throws IOException, AsterixException { + AbstractCollectionType reqType, ACastVisitor visitor) throws HyracksDataException { if (reqType.getTypeTag().equals(ATypeTag.MULTISET)) { unOrderedListBuilder.reset(reqType); reqItemType = reqType.getItemType(); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java index c2aa3d8..25a2f2b 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.List; import org.apache.asterix.builders.RecordBuilder; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.common.exceptions.ErrorCode; import org.apache.asterix.om.pointables.ARecordVisitablePointable; import org.apache.asterix.om.pointables.PointableAllocator; @@ -97,7 +96,7 @@ class ARecordCaster { private final UTF8StringWriter utf8Writer = new UTF8StringWriter(); - public ARecordCaster() { + public ARecordCaster() throws HyracksDataException { try { bos.reset(); int start = bos.size(); @@ -109,34 +108,34 @@ class ARecordCaster { end = bos.size(); nullTypeTag.set(bos.getByteArray(), start, end - start); } catch (IOException e) { - throw new IllegalStateException(e); + throw HyracksDataException.create(e); } } public void castRecord(ARecordVisitablePointable recordAccessor, IVisitablePointable resultAccessor, - ARecordType reqType, ACastVisitor visitor) throws IOException { + ARecordType reqType, ACastVisitor visitor) throws HyracksDataException { List<IVisitablePointable> fieldNames = recordAccessor.getFieldNames(); List<IVisitablePointable> fieldTypeTags = recordAccessor.getFieldTypeTags(); List<IVisitablePointable> fieldValues = recordAccessor.getFieldValues(); numInputFields = fieldNames.size(); - try { - if (openFields == null || numInputFields > openFields.length) { - openFields = new boolean[numInputFields]; - fieldNamesSortedIndex = new int[numInputFields]; - } - if (cachedReqType == null || !reqType.equals(cachedReqType)) { + if (openFields == null || numInputFields > openFields.length) { + openFields = new boolean[numInputFields]; + fieldNamesSortedIndex = new int[numInputFields]; + } + if (cachedReqType == null || !reqType.equals(cachedReqType)) { + try { loadRequiredType(reqType); + } catch (IOException e) { + throw HyracksDataException.create(e); } - - // clear the previous states - reset(); - matchClosedPart(fieldNames, fieldTypeTags); - writeOutput(fieldNames, fieldTypeTags, fieldValues, outputDos, visitor); - resultAccessor.set(outputBos.getByteArray(), 0, outputBos.size()); - } catch (AsterixException e) { - throw new HyracksDataException("Unable to cast record to " + reqType.getTypeName(), e); } + + // clear the previous states + reset(); + matchClosedPart(fieldNames, fieldTypeTags); + writeOutput(fieldNames, fieldTypeTags, fieldValues, outputDos, visitor); + resultAccessor.set(outputBos.getByteArray(), 0, outputBos.size()); } private void reset() { @@ -204,7 +203,7 @@ class ARecordCaster { } private void matchClosedPart(List<IVisitablePointable> fieldNames, List<IVisitablePointable> fieldTypeTags) - throws AsterixException, HyracksDataException { + throws HyracksDataException { // sort-merge based match quickSort(fieldNamesSortedIndex, fieldNames, 0, numInputFields - 1); int fnStart = 0; @@ -270,7 +269,7 @@ class ARecordCaster { ps.print(typeTag); //collect the output message and throw the exception - throw new IllegalStateException("type mismatch: including an extra field " + fieldBos.toString()); + throw new HyracksDataException("type mismatch: including an extra field " + fieldBos.toString()); } } @@ -280,8 +279,8 @@ class ARecordCaster { IAType t = cachedReqType.getFieldTypes()[i]; if (!NonTaggedFormatUtil.isOptional(t)) { // no matched field in the input for a required closed field - throw new IllegalStateException("type mismatch: missing a required closed field " - + cachedReqType.getFieldNames()[i] + ":" + t.getTypeName()); + throw new HyracksDataException("type mismatch: missing a required closed field " + + cachedReqType.getFieldNames()[i] + ": " + t.getTypeName()); } } } @@ -289,7 +288,7 @@ class ARecordCaster { private void writeOutput(List<IVisitablePointable> fieldNames, List<IVisitablePointable> fieldTypeTags, List<IVisitablePointable> fieldValues, DataOutput output, ACastVisitor visitor) - throws IOException, AsterixException { + throws HyracksDataException { // reset the states of the record builder recBuilder.reset(cachedReqType); recBuilder.init(); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java index 704d06e..5352f3c 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AListPrinter.java @@ -29,6 +29,7 @@ import org.apache.asterix.om.pointables.base.IVisitablePointable; import org.apache.asterix.om.types.ATypeTag; import org.apache.asterix.om.types.EnumDeserializer; import org.apache.hyracks.algebricks.common.utils.Pair; +import org.apache.hyracks.api.exceptions.HyracksDataException; /** * This class is to print the content of a list. @@ -47,7 +48,7 @@ public class AListPrinter { } public void printList(AListVisitablePointable listAccessor, PrintStream ps, IPrintVisitor visitor) - throws IOException, AsterixException { + throws HyracksDataException { List<IVisitablePointable> itemTags = listAccessor.getItemTags(); List<IVisitablePointable> items = listAccessor.getItems(); itemVisitorArg.first = ps; @@ -70,7 +71,7 @@ public class AListPrinter { } private void printItem(IPrintVisitor visitor, List<IVisitablePointable> itemTags, List<IVisitablePointable> items, - int i) throws AsterixException { + int i) throws HyracksDataException { IVisitablePointable itemTypeTag = itemTags.get(i); IVisitablePointable item = items.get(i); ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java index fe9e378..ef8c6da 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/ARecordPrinter.java @@ -23,12 +23,12 @@ import java.io.IOException; import java.io.PrintStream; import java.util.List; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.ARecordVisitablePointable; import org.apache.asterix.om.pointables.base.IVisitablePointable; import org.apache.asterix.om.types.ATypeTag; import org.apache.asterix.om.types.EnumDeserializer; import org.apache.hyracks.algebricks.common.utils.Pair; +import org.apache.hyracks.api.exceptions.HyracksDataException; /** * This class is to print the content of a record. @@ -51,7 +51,7 @@ public class ARecordPrinter { } public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, IPrintVisitor visitor) - throws IOException, AsterixException { + throws HyracksDataException { final List<IVisitablePointable> fieldNames = recordAccessor.getFieldNames(); final List<IVisitablePointable> fieldValues = recordAccessor.getFieldValues(); @@ -84,7 +84,7 @@ public class ARecordPrinter { } private void printField(PrintStream ps, IPrintVisitor visitor, IVisitablePointable fieldName, - IVisitablePointable fieldValue, ATypeTag fieldTypeTag) throws AsterixException { + IVisitablePointable fieldValue, ATypeTag fieldTypeTag) throws HyracksDataException { itemVisitorArg.second = fieldTypeTag; if (fieldNameSeparator != null) { // print field name http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java index 82fe048..54bf85b 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/AbstractPrintVisitor.java @@ -19,12 +19,10 @@ package org.apache.asterix.om.pointables.printer; -import java.io.IOException; import java.io.PrintStream; import java.util.HashMap; import java.util.Map; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.AFlatValuePointable; import org.apache.asterix.om.pointables.AListVisitablePointable; import org.apache.asterix.om.pointables.ARecordVisitablePointable; @@ -38,55 +36,44 @@ public abstract class AbstractPrintVisitor implements IPrintVisitor { private final Map<IVisitablePointable, AListPrinter> laccessorToPrinter = new HashMap<>(); @Override - public Void visit(AListVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException { + public Void visit(AListVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws HyracksDataException { AListPrinter printer = laccessorToPrinter.get(accessor); if (printer == null) { printer = createListPrinter(accessor); laccessorToPrinter.put(accessor, printer); } - try { - printer.printList(accessor, arg.first, this); - } catch (IOException e) { - throw new AsterixException(e); - } + printer.printList(accessor, arg.first, this); return null; } @Override - public Void visit(ARecordVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException { + public Void visit(ARecordVisitablePointable accessor, Pair<PrintStream, ATypeTag> arg) throws HyracksDataException { ARecordPrinter printer = raccessorToPrinter.get(accessor); if (printer == null) { printer = createRecordPrinter(accessor); raccessorToPrinter.put(accessor, printer); } - try { - printer.printRecord(accessor, arg.first, this); - } catch (IOException e) { - throw new AsterixException(e); - } + printer.printRecord(accessor, arg.first, this); return null; } @Override - public Void visit(AFlatValuePointable accessor, Pair<PrintStream, ATypeTag> arg) throws AsterixException { - try { - byte[] b = accessor.getByteArray(); - int s = accessor.getStartOffset(); - int l = accessor.getLength(); - PrintStream ps = arg.first; - ATypeTag typeTag = arg.second; - if (!printFlatValue(typeTag, b, s, l, ps)) { - throw new AsterixException("No printer for type " + typeTag); - } - return null; - } catch (HyracksDataException e) { - throw new AsterixException(e); + public Void visit(AFlatValuePointable accessor, Pair<PrintStream, ATypeTag> arg) throws HyracksDataException { + byte[] b = accessor.getByteArray(); + int s = accessor.getStartOffset(); + int l = accessor.getLength(); + PrintStream ps = arg.first; + ATypeTag typeTag = arg.second; + if (!printFlatValue(typeTag, b, s, l, ps)) { + throw new HyracksDataException("No printer for type " + typeTag); } + return null; } - protected abstract AListPrinter createListPrinter(AListVisitablePointable accessor) throws AsterixException; + protected abstract AListPrinter createListPrinter(AListVisitablePointable accessor) throws HyracksDataException; - protected abstract ARecordPrinter createRecordPrinter(ARecordVisitablePointable accessor) throws AsterixException; + protected abstract ARecordPrinter createRecordPrinter(ARecordVisitablePointable accessor) + throws HyracksDataException; protected abstract boolean printFlatValue(ATypeTag typeTag, byte[] b, int s, int l, PrintStream ps) throws HyracksDataException; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java index 926d9f0..3dba6ef 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java @@ -38,8 +38,8 @@ import org.apache.hyracks.api.exceptions.HyracksDataException; */ public class APrintVisitor extends AbstractPrintVisitor { @Override - protected AListPrinter createListPrinter(AListVisitablePointable accessor) throws AsterixException { - throw new AsterixException("'List' type unsupported for CSV output"); + protected AListPrinter createListPrinter(AListVisitablePointable accessor) throws HyracksDataException { + throw new HyracksDataException("'List' type unsupported for CSV output"); } @Override http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/visitor/IVisitablePointableVisitor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/visitor/IVisitablePointableVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/visitor/IVisitablePointableVisitor.java index 5d252ee..952533b 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/visitor/IVisitablePointableVisitor.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/visitor/IVisitablePointableVisitor.java @@ -19,10 +19,10 @@ package org.apache.asterix.om.pointables.visitor; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.AFlatValuePointable; import org.apache.asterix.om.pointables.AListVisitablePointable; import org.apache.asterix.om.pointables.ARecordVisitablePointable; +import org.apache.hyracks.api.exceptions.HyracksDataException; /** * This interface is a visitor for all the three different IVisitablePointable @@ -31,9 +31,9 @@ import org.apache.asterix.om.pointables.ARecordVisitablePointable; */ public interface IVisitablePointableVisitor<R, T> { - public R visit(AListVisitablePointable accessor, T arg) throws AsterixException; + R visit(AListVisitablePointable accessor, T arg) throws HyracksDataException; - public R visit(ARecordVisitablePointable accessor, T arg) throws AsterixException; + R visit(ARecordVisitablePointable accessor, T arg) throws HyracksDataException; - public R visit(AFlatValuePointable accessor, T arg) throws AsterixException; + R visit(AFlatValuePointable accessor, T arg) throws HyracksDataException; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java index 2893a0c..8b0c041 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/hierachy/ATypeHierarchy.java @@ -626,7 +626,7 @@ public class ATypeHierarchy { // convert a numeric value in a byte array to the target type value public static void convertNumericTypeByteArray(byte[] sourceByteArray, int s1, int l1, ATypeTag targetTypeTag, - DataOutput out) throws AsterixException, IOException { + DataOutput out) throws IOException { ATypeTag sourceTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(sourceByteArray[s1]); if (sourceTypeTag != targetTypeTag) { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/DeepEqualityVisitor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/DeepEqualityVisitor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/DeepEqualityVisitor.java index 3cf5ec9..584d1e8 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/DeepEqualityVisitor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/DeepEqualityVisitor.java @@ -21,7 +21,6 @@ package org.apache.asterix.runtime.evaluators.visitors; import java.util.HashMap; import java.util.Map; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.om.pointables.AFlatValuePointable; import org.apache.asterix.om.pointables.AListVisitablePointable; import org.apache.asterix.om.pointables.ARecordVisitablePointable; @@ -40,75 +39,63 @@ public class DeepEqualityVisitor implements IVisitablePointableVisitor<Void, Pai @Override public Void visit(AListVisitablePointable pointable, Pair<IVisitablePointable, Boolean> arg) - throws AsterixException { + throws HyracksDataException { ListDeepEqualityChecker listDeepEqualityChecker = lpointableToEquality.get(pointable); if (listDeepEqualityChecker == null) { listDeepEqualityChecker = new ListDeepEqualityChecker(); lpointableToEquality.put(pointable, listDeepEqualityChecker); } - try { - arg.second = listDeepEqualityChecker.accessList(pointable, arg.first, this); - } catch (Exception e) { - throw new AsterixException(e); - } + arg.second = listDeepEqualityChecker.accessList(pointable, arg.first, this); return null; } @Override public Void visit(ARecordVisitablePointable pointable, Pair<IVisitablePointable, Boolean> arg) - throws AsterixException { + throws HyracksDataException { RecordDeepEqualityChecker recDeepEqualityChecker = rpointableToEquality.get(pointable); if (recDeepEqualityChecker == null) { recDeepEqualityChecker = new RecordDeepEqualityChecker(); rpointableToEquality.put(pointable, recDeepEqualityChecker); } - try { - arg.second = recDeepEqualityChecker.accessRecord(pointable, arg.first, this); - } catch (Exception e) { - throw new AsterixException(e); - } + arg.second = recDeepEqualityChecker.accessRecord(pointable, arg.first, this); return null; } @Override - public Void visit(AFlatValuePointable pointable, Pair<IVisitablePointable, Boolean> arg) throws AsterixException { + public Void visit(AFlatValuePointable pointable, Pair<IVisitablePointable, Boolean> arg) + throws HyracksDataException { if (pointable.equals(arg.first)) { arg.second = true; return null; } - try { - ATypeTag tt1 = PointableHelper.getTypeTag(pointable); - ATypeTag tt2 = PointableHelper.getTypeTag(arg.first); + ATypeTag tt1 = PointableHelper.getTypeTag(pointable); + ATypeTag tt2 = PointableHelper.getTypeTag(arg.first); - if (tt1 != tt2) { - if (!ATypeHierarchy.isSameTypeDomain(tt1, tt2, false)) { - arg.second = false; + if (tt1 != tt2) { + if (!ATypeHierarchy.isSameTypeDomain(tt1, tt2, false)) { + arg.second = false; + } else { + // If same domain, check if numberic + Domain domain = ATypeHierarchy.getTypeDomain(tt1); + byte b1[] = pointable.getByteArray(); + byte b2[] = arg.first.getByteArray(); + if (domain == Domain.NUMERIC) { + int s1 = pointable.getStartOffset(); + int s2 = arg.first.getStartOffset(); + arg.second = Math.abs(ATypeHierarchy.getDoubleValue("deep-equal", 0, b1, s1) + - ATypeHierarchy.getDoubleValue("deep-equal", 1, b2, s2)) < 1E-10; } else { - // If same domain, check if numberic - Domain domain = ATypeHierarchy.getTypeDomain(tt1); - byte b1[] = pointable.getByteArray(); - byte b2[] = arg.first.getByteArray(); - if (domain == Domain.NUMERIC) { - int s1 = pointable.getStartOffset(); - int s2 = arg.first.getStartOffset(); - arg.second = Math.abs(ATypeHierarchy.getDoubleValue("deep-equal", 0, b1, s1) - - ATypeHierarchy.getDoubleValue("deep-equal", 1, b2, s2)) < 1E-10; - } else { - arg.second = false; - } + arg.second = false; } - } else { - arg.second = PointableHelper.byteArrayEqual(pointable, arg.first, 1); } - } catch (HyracksDataException e) { - throw new AsterixException(e); + } else { + arg.second = PointableHelper.byteArrayEqual(pointable, arg.first, 1); } - return null; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/ListDeepEqualityChecker.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/ListDeepEqualityChecker.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/ListDeepEqualityChecker.java index df4847e..bcb41f5 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/ListDeepEqualityChecker.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/ListDeepEqualityChecker.java @@ -47,7 +47,7 @@ class ListDeepEqualityChecker { } public boolean accessList(IVisitablePointable listPointableLeft, IVisitablePointable listPointableRight, - DeepEqualityVisitor visitor) throws IOException, AsterixException { + DeepEqualityVisitor visitor) throws HyracksDataException { this.visitor = visitor; AListVisitablePointable listLeft = (AListVisitablePointable)listPointableLeft; @@ -74,7 +74,7 @@ class ListDeepEqualityChecker { private boolean processOrderedList(List<IVisitablePointable> itemsLeft, List<IVisitablePointable> itemTagTypesLeft, List<IVisitablePointable> itemsRight, List<IVisitablePointable> itemTagTypesRight) - throws HyracksDataException, AsterixException { + throws HyracksDataException { for(int i=0; i<itemsLeft.size(); i++) { ATypeTag fieldTypeLeft = PointableHelper.getTypeTag(itemTagTypesLeft.get(i)); if(fieldTypeLeft.isDerivedType() && fieldTypeLeft != PointableHelper.getTypeTag(itemTagTypesRight.get(i))) { @@ -91,7 +91,7 @@ class ListDeepEqualityChecker { private boolean processUnorderedList(List<IVisitablePointable> itemsLeft, List<IVisitablePointable> itemTagTypesLeft, List<IVisitablePointable> itemsRight, List<IVisitablePointable> itemTagTypesRight) - throws HyracksDataException, AsterixException { + throws HyracksDataException { hashMap.clear(); // Build phase: Add items into hash map, starting with first list. @@ -111,7 +111,7 @@ class ListDeepEqualityChecker { private boolean probeHashMap(List<IVisitablePointable> itemsLeft, List<IVisitablePointable> itemTagTypesLeft, List<IVisitablePointable> itemsRight, List<IVisitablePointable> itemTagTypesRight) - throws HyracksDataException, AsterixException { + throws HyracksDataException { // Probe phase: Probe items from second list for(int indexRight=0; indexRight<itemsRight.size(); indexRight++) { IVisitablePointable itemRight = itemsRight.get(indexRight); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/75d32e50/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/RecordDeepEqualityChecker.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/RecordDeepEqualityChecker.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/RecordDeepEqualityChecker.java index 40af09a..699f2f8 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/RecordDeepEqualityChecker.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/visitors/RecordDeepEqualityChecker.java @@ -20,7 +20,6 @@ package org.apache.asterix.runtime.evaluators.visitors; import java.util.List; -import org.apache.asterix.common.exceptions.AsterixException; import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer; import org.apache.asterix.om.pointables.ARecordVisitablePointable; import org.apache.asterix.om.pointables.base.IVisitablePointable; @@ -50,7 +49,7 @@ class RecordDeepEqualityChecker { } public boolean accessRecord(IVisitablePointable recPointableLeft, IVisitablePointable recPointableRight, - DeepEqualityVisitor visitor) throws HyracksDataException, AsterixException { + DeepEqualityVisitor visitor) throws HyracksDataException { if (recPointableLeft.equals(recPointableRight)) { return true; @@ -86,7 +85,7 @@ class RecordDeepEqualityChecker { private boolean compareValues(List<IVisitablePointable> fieldTypesLeft, List<IVisitablePointable> fieldValuesLeft, List<IVisitablePointable> fieldNamesRight, List<IVisitablePointable> fieldTypesRight, - List<IVisitablePointable> fieldValuesRight) throws HyracksDataException, AsterixException { + List<IVisitablePointable> fieldValuesRight) throws HyracksDataException { // Probe phase: Probe items from second record for (int i = 0; i < fieldNamesRight.size(); i++) {