Search in sources :

Example 46 with HyracksDataException

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);
    }
}
Also used : TypeMismatchException(org.apache.asterix.runtime.exceptions.TypeMismatchException) IOException(java.io.IOException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 47 with HyracksDataException

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);
    }
}
Also used : TypeMismatchException(org.apache.asterix.runtime.exceptions.TypeMismatchException) IOException(java.io.IOException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 48 with HyracksDataException

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);
    }
}
Also used : HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) AsterixException(org.apache.asterix.common.exceptions.AsterixException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 49 with HyracksDataException

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;
}
Also used : IOperatorDescriptor(org.apache.hyracks.api.dataflow.IOperatorDescriptor) IMissingWriterFactory(org.apache.hyracks.api.dataflow.value.IMissingWriterFactory) NotImplementedException(org.apache.hyracks.algebricks.common.exceptions.NotImplementedException) AlgebricksException(org.apache.hyracks.algebricks.common.exceptions.AlgebricksException) HybridHashJoinOperatorDescriptor(org.apache.hyracks.dataflow.std.join.HybridHashJoinOperatorDescriptor) OptimizedHybridHashJoinOperatorDescriptor(org.apache.hyracks.dataflow.std.join.OptimizedHybridHashJoinOperatorDescriptor) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 50 with HyracksDataException

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;
}
Also used : Literal(org.apache.asterix.lang.common.base.Literal) LiteralExpr(org.apache.asterix.lang.common.expression.LiteralExpr) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Aggregations

HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)566 IOException (java.io.IOException)209 DataOutput (java.io.DataOutput)96 ArrayBackedValueStorage (org.apache.hyracks.data.std.util.ArrayBackedValueStorage)78 ITupleReference (org.apache.hyracks.dataflow.common.data.accessors.ITupleReference)75 IPointable (org.apache.hyracks.data.std.api.IPointable)73 IFrameTupleReference (org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference)70 TypeMismatchException (org.apache.asterix.runtime.exceptions.TypeMismatchException)67 IScalarEvaluator (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator)67 VoidPointable (org.apache.hyracks.data.std.primitive.VoidPointable)64 IScalarEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)61 IHyracksTaskContext (org.apache.hyracks.api.context.IHyracksTaskContext)60 ArrayList (java.util.ArrayList)57 ACIDException (org.apache.asterix.common.exceptions.ACIDException)56 ISerializerDeserializer (org.apache.hyracks.api.dataflow.value.ISerializerDeserializer)56 ATypeTag (org.apache.asterix.om.types.ATypeTag)39 AsterixException (org.apache.asterix.common.exceptions.AsterixException)36 ArrayTupleBuilder (org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder)32 ByteBuffer (java.nio.ByteBuffer)30 MetadataEntityValueExtractor (org.apache.asterix.metadata.valueextractors.MetadataEntityValueExtractor)27