IPrinters and IAWriters throw HyracksDataException
instead of AlgebricksException (which should be used at compile-time)
Change-Id: I642ff22a4cc30f1fbf0b61f7b5908a7a0c66da6c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/611
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenHelper.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenHelper.java
index 6ee5145..2c2708b 100644
--- a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenHelper.java
+++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenHelper.java
@@ -41,6 +41,7 @@
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public final class JobGenHelper {
@@ -70,12 +71,16 @@
JobGenContext context, int[] printColumns) throws AlgebricksException {
IPrinterFactory[] pf = new IPrinterFactory[printColumns.length];
IPrinterFactoryProvider pff = context.getPrinterFactoryProvider();
- for (int i = 0; i < pf.length; i++) {
- LogicalVariable v = opSchema.getVariable(printColumns[i]);
- Object t = env.getVarType(v);
- pf[i] = pff.getPrinterFactory(t);
+ try {
+ for (int i = 0; i < pf.length; i++) {
+ LogicalVariable v = opSchema.getVariable(printColumns[i]);
+ Object t = env.getVarType(v);
+ pf[i] = pff.getPrinterFactory(t);
+ }
+ return pf;
+ } catch (HyracksDataException e) {
+ throw new AlgebricksException(e);
}
- return pf;
}
public static int[] variablesToFieldIndexes(Collection<LogicalVariable> varLogical, IOperatorSchema opSchema) {
@@ -90,7 +95,7 @@
public static IBinaryHashFunctionFactory[] variablesToBinaryHashFunctionFactories(
Collection<LogicalVariable> varLogical, IVariableTypeEnvironment env, JobGenContext context)
- throws AlgebricksException {
+ throws AlgebricksException {
IBinaryHashFunctionFactory[] funFactories = new IBinaryHashFunctionFactory[varLogical.size()];
int i = 0;
IBinaryHashFunctionFactoryProvider bhffProvider = context.getBinaryHashFunctionFactoryProvider();
@@ -103,7 +108,7 @@
public static IBinaryHashFunctionFamily[] variablesToBinaryHashFunctionFamilies(
Collection<LogicalVariable> varLogical, IVariableTypeEnvironment env, JobGenContext context)
- throws AlgebricksException {
+ throws AlgebricksException {
IBinaryHashFunctionFamily[] funFamilies = new IBinaryHashFunctionFamily[varLogical.size()];
int i = 0;
IBinaryHashFunctionFamilyProvider bhffProvider = context.getBinaryHashFunctionFamilyProvider();
@@ -116,7 +121,7 @@
public static IBinaryComparatorFactory[] variablesToAscBinaryComparatorFactories(
Collection<LogicalVariable> varLogical, IVariableTypeEnvironment env, JobGenContext context)
- throws AlgebricksException {
+ throws AlgebricksException {
IBinaryComparatorFactory[] compFactories = new IBinaryComparatorFactory[varLogical.size()];
IBinaryComparatorFactoryProvider bcfProvider = context.getBinaryComparatorFactoryProvider();
int i = 0;
@@ -140,7 +145,7 @@
public static INormalizedKeyComputerFactory variablesToAscNormalizedKeyComputerFactory(
Collection<LogicalVariable> varLogical, IVariableTypeEnvironment env, JobGenContext context)
- throws AlgebricksException {
+ throws AlgebricksException {
INormalizedKeyComputerFactoryProvider nkcfProvider = context.getNormalizedKeyComputerFactoryProvider();
if (nkcfProvider == null)
return null;
diff --git a/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IAWriter.java b/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IAWriter.java
index cd83d1f..72626ca 100644
--- a/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IAWriter.java
+++ b/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IAWriter.java
@@ -18,12 +18,12 @@
*/
package org.apache.hyracks.algebricks.data;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.comm.IFrameTupleAccessor;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public interface IAWriter {
- public void init() throws AlgebricksException;
+ void init() throws HyracksDataException;
- public void printTuple(IFrameTupleAccessor tAccess, int tIdx) throws AlgebricksException;
+ void printTuple(IFrameTupleAccessor tAccess, int tIdx) throws HyracksDataException;
}
diff --git a/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinter.java b/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinter.java
index 348f7ae..99161eb 100644
--- a/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinter.java
+++ b/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinter.java
@@ -20,10 +20,10 @@
import java.io.PrintStream;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public interface IPrinter {
- public void init() throws AlgebricksException;
+ void init() throws HyracksDataException;
- public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException;
+ void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException;
}
diff --git a/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinterFactoryProvider.java b/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinterFactoryProvider.java
index 624423e..d428bb0 100644
--- a/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinterFactoryProvider.java
+++ b/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/IPrinterFactoryProvider.java
@@ -18,8 +18,8 @@
*/
package org.apache.hyracks.algebricks.data;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public interface IPrinterFactoryProvider {
- public IPrinterFactory getPrinterFactory(Object type) throws AlgebricksException;
+ IPrinterFactory getPrinterFactory(Object type) throws HyracksDataException;
}
diff --git a/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/IntegerPrinterFactory.java b/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/IntegerPrinterFactory.java
index bdab09d..9c49516 100644
--- a/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/IntegerPrinterFactory.java
+++ b/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/IntegerPrinterFactory.java
@@ -25,6 +25,7 @@
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.primitive.IntegerPointable;
public class IntegerPrinterFactory implements IPrinterFactory {
@@ -40,17 +41,17 @@
return new IPrinter() {
@Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+ public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
int d = IntegerPointable.getInteger(b, s);
try {
WriteValueTools.writeInt(d, ps);
} catch (IOException e) {
- throw new AlgebricksException(e);
+ throw new HyracksDataException(e);
}
}
@Override
- public void init() throws AlgebricksException {
+ public void init() {
}
};
}
diff --git a/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/UTF8StringPrinterFactory.java b/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/UTF8StringPrinterFactory.java
index 1aa3370..78f10d1 100644
--- a/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/UTF8StringPrinterFactory.java
+++ b/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/UTF8StringPrinterFactory.java
@@ -21,9 +21,9 @@
import java.io.IOException;
import java.io.PrintStream;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.util.string.UTF8StringUtil;
public class UTF8StringPrinterFactory implements IPrinterFactory {
@@ -40,16 +40,16 @@
return new IPrinter() {
@Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+ public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
try {
UTF8StringUtil.printUTF8StringWithQuotes(b, s, l, ps);
} catch (IOException e) {
- throw new AlgebricksException(e);
+ throw new HyracksDataException(e);
}
}
@Override
- public void init() throws AlgebricksException {
+ public void init() throws HyracksDataException {
}
};
}
diff --git a/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletPrinterFactoryProvider.java b/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletPrinterFactoryProvider.java
index 8049594..135a9a7 100644
--- a/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletPrinterFactoryProvider.java
+++ b/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletPrinterFactoryProvider.java
@@ -26,11 +26,9 @@
import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.algebricks.data.IPrinterFactoryProvider;
import org.apache.hyracks.algebricks.data.impl.IntegerPrinterFactory;
-import org.apache.hyracks.algebricks.data.utils.WriteValueTools;
import org.apache.hyracks.algebricks.examples.piglet.types.Type;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.primitive.FloatPointable;
-import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
-import org.apache.hyracks.dataflow.common.data.marshalling.FloatSerializerDeserializer;
import org.apache.hyracks.util.string.UTF8StringUtil;
public class PigletPrinterFactoryProvider implements IPrinterFactoryProvider {
@@ -41,7 +39,7 @@
}
@Override
- public IPrinterFactory getPrinterFactory(Object type) throws AlgebricksException {
+ public IPrinterFactory getPrinterFactory(Object type) {
Type t = (Type) type;
switch (t.getTag()) {
case INTEGER:
@@ -69,15 +67,15 @@
public IPrinter createPrinter() {
return new IPrinter() {
@Override
- public void init() throws AlgebricksException {
+ public void init() {
}
@Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+ public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
try {
UTF8StringUtil.printUTF8StringWithQuotes(b, s, l, ps);
} catch (IOException e) {
- throw new AlgebricksException(e);
+ throw new HyracksDataException(e);
}
}
};
@@ -97,11 +95,11 @@
public IPrinter createPrinter() {
return new IPrinter() {
@Override
- public void init() throws AlgebricksException {
+ public void init() throws HyracksDataException {
}
@Override
- public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
+ public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
ps.print(FloatPointable.getFloat(b, s));
}
};
diff --git a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/SinkWriterRuntime.java b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/SinkWriterRuntime.java
index 2512c5e..ebf3d3a 100644
--- a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/SinkWriterRuntime.java
+++ b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/SinkWriterRuntime.java
@@ -21,7 +21,6 @@
import java.io.PrintStream;
import java.nio.ByteBuffer;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.data.IAWriter;
import org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputSinkPushRuntime;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -55,11 +54,7 @@
if (first) {
first = false;
tAccess = new FrameTupleAccessor(inputRecordDesc);
- try {
- writer.init();
- } catch (AlgebricksException e) {
- throw new HyracksDataException(e);
- }
+ writer.init();
}
}
@@ -68,11 +63,7 @@
tAccess.reset(buffer);
int nTuple = tAccess.getTupleCount();
for (int t = 0; t < nTuple; t++) {
- try {
- writer.printTuple(tAccess, t);
- } catch (AlgebricksException ae) {
- throw new HyracksDataException(ae);
- }
+ writer.printTuple(tAccess, t);
}
}
diff --git a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StringStreamingRuntimeFactory.java b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StringStreamingRuntimeFactory.java
index a9f5a21..36d3349 100644
--- a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StringStreamingRuntimeFactory.java
+++ b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StringStreamingRuntimeFactory.java
@@ -155,11 +155,7 @@
for (int t = 0; t < nTuple; t++) {
tRef.reset(tAccess, t);
for (int i = 0; i < printers.length; i++) {
- try {
- printers[i].print(buffer.array(), tRef.getFieldStart(i), tRef.getFieldLength(i), ps);
- } catch (AlgebricksException e) {
- throw new HyracksDataException(e);
- }
+ printers[i].print(buffer.array(), tRef.getFieldStart(i), tRef.getFieldLength(i), ps);
ps.print(fieldDelimiter);
if (i == printers.length - 1) {
ps.print('\n');
diff --git a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/serializer/ResultSerializerFactoryProvider.java b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/serializer/ResultSerializerFactoryProvider.java
index aa1fa6d..0e49d22 100644
--- a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/serializer/ResultSerializerFactoryProvider.java
+++ b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/serializer/ResultSerializerFactoryProvider.java
@@ -21,7 +21,6 @@
import java.io.PrintStream;
import java.nio.BufferOverflowException;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.data.IAWriter;
import org.apache.hyracks.algebricks.data.IAWriterFactory;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
@@ -56,11 +55,7 @@
@Override
public void init() throws HyracksDataException {
- try {
- writer.init();
- } catch (AlgebricksException e) {
- throw new HyracksDataException(e);
- }
+ writer.init();
}
@Override
@@ -69,8 +64,6 @@
writer.printTuple(tAccess, tIdx);
} catch (BufferOverflowException e) {
return false;
- } catch (AlgebricksException e) {
- throw new HyracksDataException(e);
}
return true;
}
diff --git a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/writers/PrinterBasedWriterFactory.java b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/writers/PrinterBasedWriterFactory.java
index bad2d3e..015ce73 100644
--- a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/writers/PrinterBasedWriterFactory.java
+++ b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/writers/PrinterBasedWriterFactory.java
@@ -20,13 +20,13 @@
import java.io.PrintStream;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.data.IAWriter;
import org.apache.hyracks.algebricks.data.IAWriterFactory;
import org.apache.hyracks.algebricks.data.IPrinter;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.api.comm.IFrameTupleAccessor;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class PrinterBasedWriterFactory implements IAWriterFactory {
@@ -48,14 +48,14 @@
return new IAWriter() {
@Override
- public void init() throws AlgebricksException {
+ public void init() throws HyracksDataException {
for (int i = 0; i < printers.length; i++) {
printers[i].init();
}
}
@Override
- public void printTuple(IFrameTupleAccessor tAccess, int tIdx) throws AlgebricksException {
+ public void printTuple(IFrameTupleAccessor tAccess, int tIdx) throws HyracksDataException {
for (int i = 0; i < fields.length; i++) {
int fldStart = tAccess.getTupleStartOffset(tIdx) + tAccess.getFieldSlotsLength()
+ tAccess.getFieldStartOffset(tIdx, fields[i]);
diff --git a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/writers/SerializedDataWriterFactory.java b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/writers/SerializedDataWriterFactory.java
index b01237e..585506f 100644
--- a/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/writers/SerializedDataWriterFactory.java
+++ b/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/writers/SerializedDataWriterFactory.java
@@ -23,12 +23,12 @@
import java.io.ObjectOutputStream;
import java.io.PrintStream;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.data.IAWriter;
import org.apache.hyracks.algebricks.data.IAWriterFactory;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.api.comm.IFrameTupleAccessor;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
public class SerializedDataWriterFactory implements IAWriterFactory {
@@ -40,7 +40,7 @@
return new IAWriter() {
@Override
- public void init() throws AlgebricksException {
+ public void init() throws HyracksDataException {
// dump the SerializerDeserializers to disk
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -49,12 +49,12 @@
baos.writeTo(ps);
oos.close();
} catch (IOException e) {
- throw new AlgebricksException(e);
+ throw new HyracksDataException(e);
}
}
@Override
- public void printTuple(IFrameTupleAccessor tAccess, int tIdx) throws AlgebricksException {
+ public void printTuple(IFrameTupleAccessor tAccess, int tIdx) throws HyracksDataException {
for (int i = 0; i < fields.length; i++) {
int fldStart = tAccess.getTupleStartOffset(tIdx) + tAccess.getFieldSlotsLength()
+ tAccess.getFieldStartOffset(tIdx, fields[i]);