use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class FeedStreamDataFlowController method start.
@Override
public void start(IFrameWriter writer) throws HyracksDataException {
try {
tupleForwarder.initialize(ctx, writer);
while (true) {
tb.reset();
if (!dataParser.parse(tb.getDataOutput())) {
break;
}
tb.addFieldEndOffset();
tupleForwarder.addTuple(tb);
}
} catch (Exception e) {
throw new HyracksDataException(e);
} finally {
tupleForwarder.close();
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class Operation method privateDoOperation.
public static int privateDoOperation(int op, Value val1, Value val2, Value val3, boolean valid1, boolean valid2, boolean valid3, Value result, EvalState es, ClassAdObjectPool objectPool) throws HyracksDataException {
ValueType vt1;
ValueType vt2;
ValueType vt3;
// get the types of the values
vt1 = val1.getType();
vt2 = val2.getType();
vt3 = val3.getType();
// take care of the easy cases
if (op == OpKind_NO_OP || op == OpKind_PARENTHESES_OP) {
result.setValue(val1);
return SigValues.SIG_CHLD1.ordinal();
} else if (op == OpKind_UNARY_PLUS_OP) {
if (vt1 == ValueType.BOOLEAN_VALUE || vt1 == ValueType.STRING_VALUE || val1.isListValue() || vt1 == ValueType.CLASSAD_VALUE || vt1 == ValueType.ABSOLUTE_TIME_VALUE) {
result.setErrorValue();
} else {
// applies for ERROR, UNDEFINED and Numbers
result.setValue(val1);
}
return SigValues.SIG_CHLD1.ordinal();
}
// test for cases when evaluation is strict
if (isStrictOperator(op)) {
// check for error values
if (vt1 == ValueType.ERROR_VALUE) {
result.setErrorValue();
return SigValues.SIG_CHLD1.ordinal();
}
if (valid2 && vt2 == ValueType.ERROR_VALUE) {
result.setErrorValue();
return SigValues.SIG_CHLD2.ordinal();
}
if (valid3 && vt3 == ValueType.ERROR_VALUE) {
result.setErrorValue();
return SigValues.SIG_CHLD3.ordinal();
}
// tree exists, because these values would be undefined" anyway then.
if (valid1 && vt1 == ValueType.UNDEFINED_VALUE) {
result.setUndefinedValue();
return SigValues.SIG_CHLD1.ordinal();
}
if (valid2 && vt2 == ValueType.UNDEFINED_VALUE) {
result.setUndefinedValue();
return SigValues.SIG_CHLD2.ordinal();
}
if (valid3 && vt3 == ValueType.UNDEFINED_VALUE) {
result.setUndefinedValue();
return SigValues.SIG_CHLD3.ordinal();
}
}
// comparison operations (binary, one unary)
if (op >= OpKind_COMPARISON_START && op <= OpKind_COMPARISON_END) {
return (doComparison(op, val1, val2, result, objectPool));
}
// arithmetic operations (binary)
if (op >= OpKind_ARITHMETIC_START && op <= OpKind_ARITHMETIC_END) {
return (doArithmetic(op, val1, val2, result, objectPool));
}
// logical operators (binary, one unary)
if (op >= OpKind_LOGIC_START && op <= OpKind_LOGIC_END) {
return (doLogical(op, val1, val2, result, objectPool));
}
// bitwise operators (binary, one unary)
if (op >= OpKind_BITWISE_START && op <= OpKind_BITWISE_END) {
return (doBitwise(op, val1, val2, result, objectPool));
}
// misc.
if (op == OpKind_TERNARY_OP) {
// ternary (if-operator)
MutableBoolean b = objectPool.boolPool.get();
// if the selector is UNDEFINED, the result is undefined
if (vt1 == ValueType.UNDEFINED_VALUE) {
result.setUndefinedValue();
return SigValues.SIG_CHLD1.ordinal();
}
if (!val1.isBooleanValueEquiv(b)) {
result.setErrorValue();
return SigValues.SIG_CHLD1.ordinal();
} else if (b.booleanValue()) {
result.setValue(val2);
return (SigValues.SIG_CHLD2.ordinal());
} else {
result.setValue(val3);
return (SigValues.SIG_CHLD3.ordinal());
}
} else if (op == OpKind_SUBSCRIPT_OP) {
if (vt1 == ValueType.CLASSAD_VALUE && vt2 == ValueType.STRING_VALUE) {
ClassAd classad = objectPool.classAdPool.get();
AMutableCharArrayString index = objectPool.strPool.get();
val1.isClassAdValue(classad);
val2.isStringValue(index);
if (classad.lookup(index.toString()) == null) {
result.setErrorValue();
return SigValues.SIG_CHLD2.ordinal();
}
if (!classad.evaluateAttr(index.toString(), result)) {
result.setErrorValue();
return SigValues.SIG_CHLD2.ordinal();
}
return (SigValues.SIG_CHLD1.ordinal() | SigValues.SIG_CHLD2.ordinal());
} else if (val1.isListValue() && vt2 == ValueType.INTEGER_VALUE) {
AMutableInt64 index = objectPool.int64Pool.get();
ExprList elist = objectPool.exprListPool.get();
val1.isListValue(elist);
val2.isIntegerValue(index);
// check bounds
if (index.getLongValue() < 0 || index.getLongValue() >= elist.getExprList().size()) {
result.setErrorValue();
return SigValues.SIG_CHLD2.ordinal();
}
// get value
elist.getValue(result, elist.get((int) index.getLongValue()), es);
return (SigValues.SIG_CHLD1.ordinal() | SigValues.SIG_CHLD2.ordinal());
}
// should not reach here
throw new HyracksDataException("Should not get here");
}
return -1;
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class MetadataNode method getExternalFiles.
@Override
public List<ExternalFile> getExternalFiles(JobId jobId, Dataset dataset) throws MetadataException, RemoteException {
try {
ITupleReference searchKey = createTuple(dataset.getDataverseName(), dataset.getDatasetName());
ExternalFileTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getExternalFileTupleTranslator(false);
IValueExtractor<ExternalFile> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
List<ExternalFile> results = new ArrayList<>();
searchIndex(jobId, MetadataPrimaryIndexes.EXTERNAL_FILE_DATASET, searchKey, valueExtractor, results);
return results;
} catch (HyracksDataException e) {
throw new MetadataException(e);
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class MetadataNode method getDataverseDatatypes.
private List<Datatype> getDataverseDatatypes(JobId jobId, String dataverseName) throws MetadataException, RemoteException {
try {
ITupleReference searchKey = createTuple(dataverseName);
DatatypeTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getDataTypeTupleTranslator(jobId, this, false);
IValueExtractor<Datatype> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
List<Datatype> results = new ArrayList<>();
searchIndex(jobId, MetadataPrimaryIndexes.DATATYPE_DATASET, searchKey, valueExtractor, results);
return results;
} catch (HyracksDataException e) {
throw new MetadataException(e);
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class MetadataNode method getDataset.
@Override
public Dataset getDataset(JobId jobId, String dataverseName, String datasetName) throws MetadataException, RemoteException {
try {
ITupleReference searchKey = createTuple(dataverseName, datasetName);
DatasetTupleTranslator tupleReaderWriter = tupleTranslatorProvider.getDatasetTupleTranslator(false);
List<Dataset> results = new ArrayList<>();
IValueExtractor<Dataset> valueExtractor = new MetadataEntityValueExtractor<>(tupleReaderWriter);
searchIndex(jobId, MetadataPrimaryIndexes.DATASET_DATASET, searchKey, valueExtractor, results);
if (results.isEmpty()) {
return null;
}
return results.get(0);
} catch (HyracksDataException e) {
throw new MetadataException(e);
}
}
Aggregations