Search in sources :

Example 1 with ASTNENode

use of org.apache.commons.jexl2.parser.ASTNENode in project datawave by NationalSecurityAgency.

the class ExpandCompositeTerms method createCompositeNode.

/**
 * Attempts to form a jexl node from the composite
 *
 * @param composite
 *            A list of composites from which jexl nodes should be created
 * @return A list of jexl nodes created from the given composite
 */
private JexlNode createCompositeNode(Composite composite) {
    List<Class<? extends JexlNode>> nodeClasses = new ArrayList<>();
    List<String> appendedExpressions = new ArrayList<>();
    boolean includeOldData = false;
    if (config.getCompositeTransitionDates().containsKey(composite.getCompositeName())) {
        Date transitionDate = config.getCompositeTransitionDates().get(composite.getCompositeName());
        if (config.getBeginDate().compareTo(transitionDate) < 0)
            includeOldData = true;
    }
    composite.getNodesAndExpressions(nodeClasses, appendedExpressions, config.getFieldToDiscreteIndexTypes(), includeOldData);
    // if this is true, then it indicates that we are dealing with a query containing an overloaded composite
    // field which only contained the first component term. This means that we are running a query against
    // the base composite term, and thus need to expand our ranges to fully include both the composite and
    // non-composite events in our range.
    boolean expandRangeForBaseTerm = CompositeIngest.isOverloadedCompositeField(config.getCompositeToFieldMap(), composite.getCompositeName()) && composite.getJexlNodeList().size() == 1;
    DiscreteIndexType<?> baseTermDiscreteIndexType = config.getFieldToDiscreteIndexTypes().get(composite.getFieldNameList().get(0));
    List<JexlNode> finalNodes = new ArrayList<>();
    for (int i = 0; i < nodeClasses.size(); i++) {
        Class<? extends JexlNode> nodeClass = nodeClasses.get(i);
        String appendedExpression = appendedExpressions.get(i);
        JexlNode newNode = null;
        if (nodeClass.equals(ASTGTNode.class)) {
            if (expandRangeForBaseTerm)
                newNode = JexlNodeFactory.buildNode((ASTGENode) null, composite.getCompositeName(), CompositeUtils.getInclusiveLowerBound(appendedExpression, baseTermDiscreteIndexType));
            else
                newNode = JexlNodeFactory.buildNode((ASTGTNode) null, composite.getCompositeName(), appendedExpression);
        } else if (nodeClass.equals(ASTGENode.class)) {
            newNode = JexlNodeFactory.buildNode((ASTGENode) null, composite.getCompositeName(), appendedExpression);
        } else if (nodeClass.equals(ASTLTNode.class)) {
            newNode = JexlNodeFactory.buildNode((ASTLTNode) null, composite.getCompositeName(), appendedExpression);
        } else if (nodeClass.equals(ASTLENode.class)) {
            if (expandRangeForBaseTerm)
                newNode = JexlNodeFactory.buildNode((ASTLTNode) null, composite.getCompositeName(), CompositeUtils.getExclusiveUpperBound(appendedExpression, baseTermDiscreteIndexType));
            else
                newNode = JexlNodeFactory.buildNode((ASTLENode) null, composite.getCompositeName(), appendedExpression);
        } else if (nodeClass.equals(ASTERNode.class)) {
            newNode = JexlNodeFactory.buildERNode(composite.getCompositeName(), appendedExpression);
        } else if (nodeClass.equals(ASTNENode.class)) {
            newNode = JexlNodeFactory.buildNode((ASTNENode) null, composite.getCompositeName(), appendedExpression);
        } else if (nodeClass.equals(ASTEQNode.class)) {
            // if this is for an overloaded composite field, which only includes the base term, convert to range
            if (expandRangeForBaseTerm) {
                JexlNode lowerBound = JexlNodeFactory.buildNode((ASTGENode) null, composite.getCompositeName(), appendedExpression);
                JexlNode upperBound = JexlNodeFactory.buildNode((ASTLTNode) null, composite.getCompositeName(), CompositeUtils.getExclusiveUpperBound(appendedExpression, baseTermDiscreteIndexType));
                newNode = createUnwrappedAndNode(Arrays.asList(lowerBound, upperBound));
            } else {
                newNode = JexlNodeFactory.buildEQNode(composite.getCompositeName(), appendedExpression);
            }
        } else {
            log.error("Invalid or unknown node type for composite map.");
        }
        finalNodes.add(newNode);
    }
    JexlNode finalNode;
    if (finalNodes.size() > 1) {
        finalNode = createUnwrappedAndNode(finalNodes);
        if (composite.getJexlNodeList().size() > 1) {
            JexlNode delayedNode = ASTEvaluationOnly.create(createUnwrappedAndNode(composite.getJexlNodeList().stream().map(node -> JexlNodeFactory.wrap(copy(node))).collect(Collectors.toList())));
            finalNode = createUnwrappedAndNode(Arrays.asList(JexlNodeFactory.wrap(finalNode), delayedNode));
        }
    } else {
        finalNode = finalNodes.get(0);
        if (composite.getJexlNodeList().size() > 1 && !(finalNode instanceof ASTEQNode)) {
            JexlNode delayedNode = ASTEvaluationOnly.create(createUnwrappedAndNode(composite.getJexlNodeList().stream().map(node -> JexlNodeFactory.wrap(copy(node))).collect(Collectors.toList())));
            finalNode = createUnwrappedAndNode(Arrays.asList(finalNode, delayedNode));
        }
    }
    if (!CompositeIngest.isOverloadedCompositeField(config.getCompositeToFieldMap(), composite.getCompositeName())) {
        config.getIndexedFields().add(composite.getCompositeName());
        config.getQueryFieldsDatatypes().put(composite.getCompositeName(), new NoOpType());
    }
    // save a mapping of generated composites to their component parts for later processing
    jexlNodeToCompMap.put(finalNode, composite);
    return finalNode;
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) ASTLTNode(org.apache.commons.jexl2.parser.ASTLTNode) Arrays(java.util.Arrays) Date(java.util.Date) JexlNodeFactory(datawave.query.jexl.JexlNodeFactory) Logger(org.apache.log4j.Logger) ASTNRNode(org.apache.commons.jexl2.parser.ASTNRNode) ASTNotNode(org.apache.commons.jexl2.parser.ASTNotNode) ASTGTNode(org.apache.commons.jexl2.parser.ASTGTNode) Map(java.util.Map) LinkedHashMultimap(com.google.common.collect.LinkedHashMultimap) ThreadConfigurableLogger(datawave.webservice.common.logging.ThreadConfigurableLogger) CompositeUtils(datawave.query.composite.CompositeUtils) DatawaveFatalQueryException(datawave.query.exceptions.DatawaveFatalQueryException) CompositeRange(datawave.query.composite.CompositeRange) ASTDelayedPredicate(org.apache.commons.jexl2.parser.ASTDelayedPredicate) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) ASTNENode(org.apache.commons.jexl2.parser.ASTNENode) List(java.util.List) ASTOrNode(org.apache.commons.jexl2.parser.ASTOrNode) ShardQueryConfiguration(datawave.query.config.ShardQueryConfiguration) DiscreteIndexType(datawave.data.type.DiscreteIndexType) Entry(java.util.Map.Entry) JexlNodes.children(org.apache.commons.jexl2.parser.JexlNodes.children) CompositeTerm(datawave.query.composite.CompositeTerm) ASTEQNode(org.apache.commons.jexl2.parser.ASTEQNode) JexlASTHelper(datawave.query.jexl.JexlASTHelper) ASTLENode(org.apache.commons.jexl2.parser.ASTLENode) JexlNode(org.apache.commons.jexl2.parser.JexlNode) HashMap(java.util.HashMap) Multimap(com.google.common.collect.Multimap) ASTReferenceExpression(org.apache.commons.jexl2.parser.ASTReferenceExpression) NoOpType(datawave.data.type.NoOpType) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) ASTERNode(org.apache.commons.jexl2.parser.ASTERNode) Lists(com.google.common.collect.Lists) LiteralRange(datawave.query.jexl.LiteralRange) ASTAndNode(org.apache.commons.jexl2.parser.ASTAndNode) CompositeIngest(datawave.ingest.data.config.ingest.CompositeIngest) BoundedRange(datawave.query.jexl.nodes.BoundedRange) QueryPropertyMarker(datawave.query.jexl.nodes.QueryPropertyMarker) Composite(datawave.query.composite.Composite) DatawaveErrorCode(datawave.webservice.query.exception.DatawaveErrorCode) ASTGENode(org.apache.commons.jexl2.parser.ASTGENode) QueryException(datawave.webservice.query.exception.QueryException) ASTEvaluationOnly(org.apache.commons.jexl2.parser.ASTEvaluationOnly) Preconditions(com.google.common.base.Preconditions) ASTFunctionNode(org.apache.commons.jexl2.parser.ASTFunctionNode) ASTReference(org.apache.commons.jexl2.parser.ASTReference) ASTNENode(org.apache.commons.jexl2.parser.ASTNENode) ASTGENode(org.apache.commons.jexl2.parser.ASTGENode) ArrayList(java.util.ArrayList) NoOpType(datawave.data.type.NoOpType) Date(java.util.Date) ASTLTNode(org.apache.commons.jexl2.parser.ASTLTNode) ASTLENode(org.apache.commons.jexl2.parser.ASTLENode) ASTEQNode(org.apache.commons.jexl2.parser.ASTEQNode) JexlNode(org.apache.commons.jexl2.parser.JexlNode)

Example 2 with ASTNENode

use of org.apache.commons.jexl2.parser.ASTNENode in project datawave by NationalSecurityAgency.

the class IsNotNullIntentVisitor method visit.

@Override
public Object visit(ASTERNode node, Object data) {
    // If the ER node is meant to match any string, it can be replaced with FIELD != null.
    Object value = JexlASTHelper.getLiteralValue(node);
    if (".*?".equals(value)) {
        ASTNENode neNode = new ASTNENode(ParserTreeConstants.JJTNENODE);
        neNode.jjtAddChild(node.jjtGetChild(0), 0);
        neNode.jjtAddChild(new ASTNullLiteral(ParserTreeConstants.JJTNULLLITERAL), 1);
        return super.visit(neNode, data);
    }
    return super.visit(node, data);
}
Also used : ASTNENode(org.apache.commons.jexl2.parser.ASTNENode) ASTNullLiteral(org.apache.commons.jexl2.parser.ASTNullLiteral)

Example 3 with ASTNENode

use of org.apache.commons.jexl2.parser.ASTNENode in project datawave by NationalSecurityAgency.

the class PushdownNegationVisitor method visit.

@Override
public Object visit(ASTNENode node, Object data) {
    if (data instanceof NegationState) {
        NegationState state = (NegationState) data;
        if (state.isNegated()) {
            // replace this node with an EQ node
            JexlNode eqNode = JexlNodeFactory.buildEQNode(JexlASTHelper.getIdentifier(node), JexlASTHelper.getLiteral(node).image);
            JexlNodes.swap(node.jjtGetParent(), node, eqNode);
            state.setNegated(false);
            return state;
        }
    }
    // keep going
    return super.visit(node, data);
}
Also used : JexlNode(org.apache.commons.jexl2.parser.JexlNode)

Example 4 with ASTNENode

use of org.apache.commons.jexl2.parser.ASTNENode in project datawave by NationalSecurityAgency.

the class QueryModelVisitor method expandBinaryNodeFromModel.

/**
 * Applies the forward mapping from the QueryModel to a node, expanding the node into an Or if needed.
 *
 * @param node
 * @param data
 * @return
 */
protected JexlNode expandBinaryNodeFromModel(JexlNode node, Object data) {
    String field = JexlASTHelper.getIdentifier(node);
    if (isFieldExcluded(field)) {
        return node;
    }
    // Count the immediate children:
    int childCount = node.jjtGetNumChildren();
    if (childCount != 2) {
        QueryException qe = new QueryException(DatawaveErrorCode.BINARY_NODE_TOO_MANY_CHILDREN, MessageFormat.format("Node: {0}", PrintingVisitor.formattedQueryString(node)));
        throw new DatawaveFatalQueryException(qe);
    }
    // Find identifiers
    List<ASTIdentifier> allidentifiers = JexlASTHelper.getIdentifiers(node);
    // If we don't have any identifiers, we have nothing to expand
    if (allidentifiers.isEmpty()) {
        return node;
    }
    JexlNode leftNode = node.jjtGetChild(0);
    JexlNode rightNode = node.jjtGetChild(1);
    if (log.isTraceEnabled()) {
        log.trace("leftNode:" + PrintingVisitor.formattedQueryString(leftNode));
        log.trace("leftNodeQuery:" + JexlStringBuildingVisitor.buildQuery(leftNode));
        log.trace("rightNode:" + PrintingVisitor.formattedQueryString(rightNode));
        log.trace("rightNodeQuery:" + JexlStringBuildingVisitor.buildQuery(rightNode));
    }
    // this will expand identifiers that have a method connected to them
    boolean leftState = JexlASTHelper.HasMethodVisitor.hasMethod(leftNode);
    if (leftState) {
        // there is a method under leftNode
        leftNode = (JexlNode) leftNode.jjtAccept(this.simpleQueryModelVisitor, null);
    }
    boolean rightState = JexlASTHelper.HasMethodVisitor.hasMethod(rightNode);
    if (rightState) {
        // there is a method under rightNode
        rightNode = (JexlNode) rightNode.jjtAccept(this.simpleQueryModelVisitor, null);
    }
    // expand any identifiers inside of methods/functions in the left and right nodes
    leftNode = (JexlNode) leftNode.jjtAccept(this, null);
    rightNode = (JexlNode) rightNode.jjtAccept(this, null);
    if (log.isTraceEnabled()) {
        log.trace("after expansion, leftNode:" + PrintingVisitor.formattedQueryString(leftNode));
        log.trace("after expansion, leftNodeQuery:" + JexlStringBuildingVisitor.buildQuery(leftNode));
        log.trace("after expansion, rightNode:" + PrintingVisitor.formattedQueryString(rightNode));
        log.trace("after expansion, rightNodeQuery:" + JexlStringBuildingVisitor.buildQuery(rightNode));
    }
    // if state == true on either side, then there is a method on one side and we are done applying the model
    if (leftState || rightState) {
        JexlNode toReturn = JexlNodeFactory.buildUntypedBinaryNode(node, leftNode, rightNode);
        if (log.isTraceEnabled()) {
            log.trace("done early. returning:" + JexlStringBuildingVisitor.buildQuery(toReturn));
        }
        return toReturn;
    }
    JexlNode leftSeed, rightSeed;
    Set<JexlNode> left = Sets.newHashSet(), right = Sets.newHashSet();
    boolean isNullEquality = false;
    if (node instanceof ASTEQNode && (leftNode instanceof ASTNullLiteral || rightNode instanceof ASTNullLiteral)) {
        isNullEquality = true;
    }
    // the query has been previously groomed so that identifiers are on the left and literals are on the right
    // an identifier with a method attached will have already been substituted above (and will return null for the IdentifierOpLiteral)
    // The normal case of `IDENTIFIER op 'literal'`
    JexlASTHelper.IdentifierOpLiteral op = JexlASTHelper.getIdentifierOpLiteral(node);
    if (op != null) {
        // One identifier
        leftSeed = op.getIdentifier();
        rightSeed = op.getLiteral();
        if (rightSeed instanceof ASTNullLiteral && node instanceof ASTEQNode) {
            isNullEquality = true;
        }
    } else {
        // We know from above that childCount == 2. We may have a reference on both sides of the expression
        leftSeed = node.jjtGetChild(0);
        rightSeed = node.jjtGetChild(1);
    }
    if (leftSeed instanceof ASTReference) {
        // String fieldName = JexlASTHelper.getIdentifier((JexlNode)leftSeed);
        List<ASTIdentifier> identifiers = JexlASTHelper.getIdentifiers(leftSeed);
        if (identifiers.size() > 1) {
            log.warn("I did not expect to see more than one Identifier here for " + JexlStringBuildingVisitor.buildQuery(leftSeed) + " from " + JexlStringBuildingVisitor.buildQuery(leftNode));
        }
        for (ASTIdentifier identifier : identifiers) {
            for (String fieldName : getAliasesForField(JexlASTHelper.deconstructIdentifier(identifier))) {
                left.add(JexlNodeFactory.buildIdentifier(fieldName));
            }
        }
    } else if (leftSeed instanceof ASTIdentifier) {
        for (String fieldName : getAliasesForField(JexlASTHelper.deconstructIdentifier((ASTIdentifier) leftSeed))) {
            left.add(JexlNodeFactory.buildIdentifier(fieldName));
        }
    } else {
        // Not an identifier, therefore it's probably a literal
        left.add(leftSeed);
    }
    if (rightSeed instanceof ASTReference) {
        List<ASTIdentifier> identifiers = JexlASTHelper.getIdentifiers(rightSeed);
        if (identifiers.size() > 1) {
            log.warn("I did not expect to see more than one Identifier here for " + JexlStringBuildingVisitor.buildQuery(rightSeed) + " from " + JexlStringBuildingVisitor.buildQuery(rightNode));
        }
        for (ASTIdentifier identifier : identifiers) {
            for (String fieldName : getAliasesForField(JexlASTHelper.deconstructIdentifier(identifier))) {
                right.add(JexlNodeFactory.buildIdentifier(fieldName));
            }
        }
    } else if (rightSeed instanceof ASTIdentifier) {
        for (String fieldName : getAliasesForField(JexlASTHelper.deconstructIdentifier((ASTIdentifier) rightSeed))) {
            right.add(JexlNodeFactory.buildIdentifier(fieldName));
        }
    } else {
        // Not an identifier, therefore it's probably a literal
        right.add(rightSeed);
    }
    boolean requiresAnd = isNullEquality || node instanceof ASTNENode;
    @SuppressWarnings("unchecked") Set<List<JexlNode>> // retrieve the cartesian product
    product = Sets.cartesianProduct(left, right);
    /**
     * use the product transformer to shallow copy the jexl nodes. We've created new nodes that will be embedded within an ast reference. As a result, we
     * need to ensure that if we create a logical structure ( such as an or ) -- each literal references a unique identifier from the right. Otherwise,
     * subsequent visitors will reference incorrection sub trees, and potentially negate the activity of the query model visitor
     */
    Set<List<JexlNode>> newSet = product.stream().map(list -> list.stream().map(RebuildingVisitor::copy).collect(Collectors.toList())).collect(Collectors.toSet());
    if (product.size() > 1) {
        JexlNode expanded;
        if (requiresAnd) {
            expanded = JexlNodeFactory.createNodeTreeFromPairs(ContainerType.AND_NODE, node, newSet);
        } else {
            expanded = JexlNodeFactory.createNodeTreeFromPairs(ContainerType.OR_NODE, node, newSet);
        }
        if (log.isTraceEnabled())
            log.trace("expanded:" + PrintingVisitor.formattedQueryString(expanded));
        return expanded;
    } else if (1 == product.size()) {
        List<JexlNode> pair = product.iterator().next();
        JexlNode expanded = JexlNodeFactory.buildUntypedBinaryNode(node, pair.get(0), pair.get(1));
        if (log.isTraceEnabled())
            log.trace("expanded:" + PrintingVisitor.formattedQueryString(expanded));
        return expanded;
    }
    // If we couldn't map anything, return a copy
    if (log.isTraceEnabled())
        log.trace("just returning the original:" + PrintingVisitor.formattedQueryString(node));
    return node;
}
Also used : ContainerType(datawave.query.jexl.JexlNodeFactory.ContainerType) ASTEQNode(org.apache.commons.jexl2.parser.ASTEQNode) ASTLTNode(org.apache.commons.jexl2.parser.ASTLTNode) JexlASTHelper(datawave.query.jexl.JexlASTHelper) ASTLENode(org.apache.commons.jexl2.parser.ASTLENode) ASTMethodNode(org.apache.commons.jexl2.parser.ASTMethodNode) QueryModel(datawave.query.model.QueryModel) JexlNode(org.apache.commons.jexl2.parser.JexlNode) JexlNodeFactory(datawave.query.jexl.JexlNodeFactory) ASTSizeMethod(org.apache.commons.jexl2.parser.ASTSizeMethod) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ASTERNode(org.apache.commons.jexl2.parser.ASTERNode) Logger(org.apache.log4j.Logger) Lists(com.google.common.collect.Lists) ASTNRNode(org.apache.commons.jexl2.parser.ASTNRNode) LiteralRange(datawave.query.jexl.LiteralRange) ASTGTNode(org.apache.commons.jexl2.parser.ASTGTNode) ASTAndNode(org.apache.commons.jexl2.parser.ASTAndNode) ThreadConfigurableLogger(datawave.webservice.common.logging.ThreadConfigurableLogger) ParserTreeConstants(org.apache.commons.jexl2.parser.ParserTreeConstants) DatawaveFatalQueryException(datawave.query.exceptions.DatawaveFatalQueryException) ASTNullLiteral(org.apache.commons.jexl2.parser.ASTNullLiteral) ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNodes(org.apache.commons.jexl2.parser.JexlNodes) BoundedRange(datawave.query.jexl.nodes.BoundedRange) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) DatawaveErrorCode(datawave.webservice.query.exception.DatawaveErrorCode) Node(org.apache.commons.jexl2.parser.Node) ASTNENode(org.apache.commons.jexl2.parser.ASTNENode) ASTGENode(org.apache.commons.jexl2.parser.ASTGENode) List(java.util.List) QueryException(datawave.webservice.query.exception.QueryException) ASTOrNode(org.apache.commons.jexl2.parser.ASTOrNode) ASTFunctionNode(org.apache.commons.jexl2.parser.ASTFunctionNode) Collections(java.util.Collections) ASTIdentifier(org.apache.commons.jexl2.parser.ASTIdentifier) ASTReference(org.apache.commons.jexl2.parser.ASTReference) ASTNENode(org.apache.commons.jexl2.parser.ASTNENode) ASTIdentifier(org.apache.commons.jexl2.parser.ASTIdentifier) ASTNullLiteral(org.apache.commons.jexl2.parser.ASTNullLiteral) ASTReference(org.apache.commons.jexl2.parser.ASTReference) JexlASTHelper(datawave.query.jexl.JexlASTHelper) DatawaveFatalQueryException(datawave.query.exceptions.DatawaveFatalQueryException) QueryException(datawave.webservice.query.exception.QueryException) ASTEQNode(org.apache.commons.jexl2.parser.ASTEQNode) DatawaveFatalQueryException(datawave.query.exceptions.DatawaveFatalQueryException) JexlNode(org.apache.commons.jexl2.parser.JexlNode) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with ASTNENode

use of org.apache.commons.jexl2.parser.ASTNENode in project datawave by NationalSecurityAgency.

the class RegexFunctionVisitor method visit.

@Override
public Object visit(ASTFunctionNode node, Object data) {
    JexlNode returnNode = copy(node);
    FunctionJexlNodeVisitor functionMetadata = new FunctionJexlNodeVisitor();
    node.jjtAccept(functionMetadata, null);
    if (functionMetadata.name().equals("includeRegex") || functionMetadata.name().equals("excludeRegex")) {
        List<JexlNode> arguments = functionMetadata.args();
        JexlNode node0 = arguments.get(0);
        if (node0 instanceof ASTIdentifier) {
            JexlNode regexNode = buildRegexNode((ASTIdentifier) node0, functionMetadata.name(), arguments.get(1).image);
            if (regexNode != null) {
                returnNode = regexNode;
            }
        } else {
            JexlNode newParent;
            if (functionMetadata.name().equals("excludeRegex")) {
                newParent = new ASTAndNode(ParserTreeConstants.JJTANDNODE);
            } else {
                // it is likely an 'or' node...
                newParent = JexlNodeFactory.shallowCopy(node0);
            }
            for (int i = 0; i < node0.jjtGetNumChildren(); i++) {
                JexlNode child = node0.jjtGetChild(i);
                if (child instanceof ASTIdentifier) {
                    this.adopt(newParent, buildRegexNode((ASTIdentifier) child, functionMetadata.name(), arguments.get(1).image));
                } else {
                    // probably a Reference
                    for (int j = 0; j < child.jjtGetNumChildren(); j++) {
                        JexlNode maybeIdentifier = child.jjtGetChild(j);
                        if (maybeIdentifier instanceof ASTIdentifier) {
                            this.adopt(newParent, buildRegexNode((ASTIdentifier) maybeIdentifier, functionMetadata.name(), arguments.get(1).image));
                        }
                    }
                }
            }
            if (newParent.jjtGetNumChildren() == node0.jjtGetNumChildren() && newParent.jjtGetNumChildren() != 0) {
                returnNode = newParent;
            }
        }
    } else if (functionMetadata.name().equals("isNull")) {
        List<JexlNode> arguments = functionMetadata.args();
        JexlNode node0 = arguments.get(0);
        if (node0 instanceof ASTIdentifier) {
            returnNode = JexlNodeFactory.buildNode(new ASTEQNode(ParserTreeConstants.JJTEQNODE), node0.image, new ASTNullLiteral(ParserTreeConstants.JJTNULLLITERAL));
        }
    } else if (functionMetadata.name().equals("isNotNull")) {
        List<JexlNode> arguments = functionMetadata.args();
        JexlNode node0 = arguments.get(0);
        if (node0 instanceof ASTIdentifier) {
            returnNode = JexlNodeFactory.buildNode(new ASTNENode(ParserTreeConstants.JJTNENODE), node0.image, new ASTNullLiteral(ParserTreeConstants.JJTNULLLITERAL));
        }
    }
    return returnNode;
}
Also used : ASTNENode(org.apache.commons.jexl2.parser.ASTNENode) ASTEQNode(org.apache.commons.jexl2.parser.ASTEQNode) JexlNode(org.apache.commons.jexl2.parser.JexlNode) ASTIdentifier(org.apache.commons.jexl2.parser.ASTIdentifier) List(java.util.List) FunctionJexlNodeVisitor(datawave.query.jexl.functions.FunctionJexlNodeVisitor) ASTNullLiteral(org.apache.commons.jexl2.parser.ASTNullLiteral) ASTAndNode(org.apache.commons.jexl2.parser.ASTAndNode)

Aggregations

JexlNode (org.apache.commons.jexl2.parser.JexlNode)10 ASTNENode (org.apache.commons.jexl2.parser.ASTNENode)9 ASTEQNode (org.apache.commons.jexl2.parser.ASTEQNode)8 ASTERNode (org.apache.commons.jexl2.parser.ASTERNode)6 ASTGENode (org.apache.commons.jexl2.parser.ASTGENode)6 ASTGTNode (org.apache.commons.jexl2.parser.ASTGTNode)6 ASTLENode (org.apache.commons.jexl2.parser.ASTLENode)6 ASTLTNode (org.apache.commons.jexl2.parser.ASTLTNode)6 ASTNRNode (org.apache.commons.jexl2.parser.ASTNRNode)5 ASTNullLiteral (org.apache.commons.jexl2.parser.ASTNullLiteral)5 ExceededTermThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededTermThresholdMarkerJexlNode)4 ExceededValueThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededValueThresholdMarkerJexlNode)4 ASTAndNode (org.apache.commons.jexl2.parser.ASTAndNode)4 ASTIdentifier (org.apache.commons.jexl2.parser.ASTIdentifier)4 DatawaveFatalQueryException (datawave.query.exceptions.DatawaveFatalQueryException)3 List (java.util.List)3 ASTFunctionNode (org.apache.commons.jexl2.parser.ASTFunctionNode)3 ASTOrNode (org.apache.commons.jexl2.parser.ASTOrNode)3 ASTReference (org.apache.commons.jexl2.parser.ASTReference)3 Lists (com.google.common.collect.Lists)2