use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class AbstractTripleStringEval method evaluate.
@SuppressWarnings("unchecked")
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
// Gets the first argument.
eval0.evaluate(tuple, argPtrFirst);
byte[] bytes0 = argPtrFirst.getByteArray();
int start0 = argPtrFirst.getStartOffset();
int len0 = argPtrFirst.getLength();
// Gets the second argument.
eval1.evaluate(tuple, argPtrSecond);
byte[] bytes1 = argPtrSecond.getByteArray();
int start1 = argPtrSecond.getStartOffset();
int len1 = argPtrSecond.getLength();
// Gets the third argument.
eval2.evaluate(tuple, argPtrThird);
byte[] bytes2 = argPtrThird.getByteArray();
int start2 = argPtrThird.getStartOffset();
int len2 = argPtrThird.getLength();
// Type check.
if (bytes0[start0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new TypeMismatchException(funcID, 0, bytes0[start0], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
}
if (bytes1[start1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new TypeMismatchException(funcID, 1, bytes1[start1], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
}
if (bytes2[start2] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new TypeMismatchException(funcID, 2, bytes2[start2], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
}
// Sets argument UTF8Pointables.
strPtr1st.set(bytes0, start0 + 1, len0 - 1);
strPtr2nd.set(bytes1, start1 + 1, len1 - 1);
strPtr3rd.set(bytes2, start2 + 1, len2 - 1);
// Resets the output storage.
resultStorage.reset();
// The actual processing.
try {
process(strPtr1st, strPtr2nd, strPtr3rd, result);
} catch (IOException e) {
throw new HyracksDataException(e);
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class AbstractUnaryStringStringEval method evaluate.
@SuppressWarnings("unchecked")
@Override
public void evaluate(IFrameTupleReference tuple, IPointable resultPointable) throws HyracksDataException {
resultStorage.reset();
argEval.evaluate(tuple, argPtr);
byte[] argBytes = argPtr.getByteArray();
int offset = argPtr.getStartOffset();
byte inputTypeTag = argBytes[offset];
if (inputTypeTag != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new TypeMismatchException(funcID, 0, argBytes[offset], ATypeTag.SERIALIZED_STRING_TYPE_TAG);
}
stringPtr.set(argBytes, offset + 1, argPtr.getLength() - 1);
resultArray.reset();
try {
process(stringPtr, resultPointable);
writeResult(resultPointable);
} catch (IOException e) {
throw new HyracksDataException(e);
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class CastTypeEvaluator method evaluate.
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws HyracksDataException {
try {
argEvaluator.evaluate(tuple, argPointable);
inputPointable.set(argPointable);
inputPointable.accept(castVisitor, arg);
result.set(resultPointable);
} catch (Exception ioe) {
throw new HyracksDataException(ioe);
}
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class JoinMultiComparator method generateHashJoinRuntime.
private IOperatorDescriptor generateHashJoinRuntime(JobGenContext context, IOperatorSchema[] inputSchemas, int[] keysLeft, int[] keysRight, IBinaryHashFunctionFactory[] hashFunFactories, IBinaryComparatorFactory[] comparatorFactories, IPredicateEvaluatorFactory predEvaluatorFactory, RecordDescriptor recDescriptor, IOperatorDescriptorRegistry spec) throws AlgebricksException {
IOperatorDescriptor opDesc;
try {
switch(kind) {
case INNER:
opDesc = new HybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), maxInputBuildSizeInFrames, aveRecordsPerFrame, getFudgeFactor(), keysLeft, keysRight, hashFunFactories, comparatorFactories, recDescriptor, predEvaluatorFactory, false, null);
break;
case LEFT_OUTER:
IMissingWriterFactory[] nonMatchWriterFactories = new IMissingWriterFactory[inputSchemas[1].getSize()];
for (int j = 0; j < nonMatchWriterFactories.length; j++) {
nonMatchWriterFactories[j] = context.getMissingWriterFactory();
}
opDesc = new HybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), maxInputBuildSizeInFrames, aveRecordsPerFrame, getFudgeFactor(), keysLeft, keysRight, hashFunFactories, comparatorFactories, recDescriptor, predEvaluatorFactory, true, nonMatchWriterFactories);
break;
default:
throw new NotImplementedException();
}
} catch (HyracksDataException e) {
throw new AlgebricksException(e);
}
return opDesc;
}
use of org.apache.hyracks.api.exceptions.HyracksDataException in project asterixdb by apache.
the class LangRecordParseUtil method exprToStringLiteral.
public static Literal exprToStringLiteral(Expression expr) throws HyracksDataException {
if (expr.getKind() != Expression.Kind.LITERAL_EXPRESSION) {
throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR, "Expected expression can only be of type %1$s", Expression.Kind.LITERAL_EXPRESSION);
}
LiteralExpr keyLiteralExpr = (LiteralExpr) expr;
Literal keyLiteral = keyLiteralExpr.getValue();
if (keyLiteral.getLiteralType() != Literal.Type.STRING) {
throw new HyracksDataException(ErrorCode.ASTERIX, ErrorCode.PARSE_ERROR, "Expected Literal can only be of type %1$s", Literal.Type.STRING);
}
return keyLiteral;
}
Aggregations