Search in sources :

Example 1 with AMutableNumberFactor

use of org.apache.asterix.external.classad.AMutableNumberFactor in project asterixdb by apache.

the class ClassAdParser method evaluateFunction.

public ExprTree evaluateFunction(String functionName, ExprList argList) throws HyracksDataException {
    Value val = objectPool.valuePool.get();
    AMutableNumberFactor factor = objectPool.numFactorPool.get();
    ExprTreeHolder tree = objectPool.mutableExprPool.get();
    ((Literal) argList.get(0)).getComponents(val, factor);
    AMutableCharArrayString string_value = objectPool.strPool.get();
    if (val.isStringValue(string_value)) {
        if (functionName.equalsIgnoreCase("absTime")) {
            tree.setInnerTree(Literal.createAbsTime(string_value, objectPool));
        } else if (functionName.equalsIgnoreCase("relTime")) {
            tree.setInnerTree(Literal.createRelTime(string_value, objectPool));
        } else {
            tree.setInnerTree(FunctionCall.createFunctionCall(functionName, argList, objectPool));
        }
    } else {
        tree.setInnerTree(FunctionCall.createFunctionCall(functionName, argList, objectPool));
    }
    return tree;
}
Also used : ExprTreeHolder(org.apache.asterix.external.classad.ExprTreeHolder) Literal(org.apache.asterix.external.classad.Literal) TokenValue(org.apache.asterix.external.classad.TokenValue) Value(org.apache.asterix.external.classad.Value) AMutableNumberFactor(org.apache.asterix.external.classad.AMutableNumberFactor) AMutableCharArrayString(org.apache.asterix.external.classad.AMutableCharArrayString)

Example 2 with AMutableNumberFactor

use of org.apache.asterix.external.classad.AMutableNumberFactor in project asterixdb by apache.

the class ClassAdParser method shouldEvaluateAtParseTime.

public boolean shouldEvaluateAtParseTime(String functionName, ExprList argList) throws HyracksDataException {
    boolean should_eval = false;
    if (functionName.equalsIgnoreCase("absTime") || functionName.equalsIgnoreCase("relTime")) {
        if (argList.size() == 1 && argList.get(0).getKind() == NodeKind.LITERAL_NODE) {
            Value val = objectPool.valuePool.get();
            AMutableNumberFactor factor = objectPool.numFactorPool.get();
            ((Literal) argList.get(0)).getComponents(val, factor);
            if (val.isStringValue()) {
                should_eval = true;
            }
        }
    }
    return should_eval;
}
Also used : Literal(org.apache.asterix.external.classad.Literal) TokenValue(org.apache.asterix.external.classad.TokenValue) Value(org.apache.asterix.external.classad.Value) AMutableNumberFactor(org.apache.asterix.external.classad.AMutableNumberFactor)

Aggregations

AMutableNumberFactor (org.apache.asterix.external.classad.AMutableNumberFactor)2 Literal (org.apache.asterix.external.classad.Literal)2 TokenValue (org.apache.asterix.external.classad.TokenValue)2 Value (org.apache.asterix.external.classad.Value)2 AMutableCharArrayString (org.apache.asterix.external.classad.AMutableCharArrayString)1 ExprTreeHolder (org.apache.asterix.external.classad.ExprTreeHolder)1