Search in sources :

Example 1 with ASTNotNode

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

the class IteratorBuildingVisitor method visit.

@Override
public Object visit(ASTAndNode and, Object data) {
    QueryPropertyMarker.Instance instance = QueryPropertyMarker.findInstance(and);
    if (instance.isType(ExceededOrThresholdMarkerJexlNode.class)) {
        JexlNode source = instance.getSource();
        // Ivarator to get the job done
        if (source instanceof ASTAndNode) {
            try {
                ivarateList(and, source, data);
            } catch (IOException ioe) {
                throw new DatawaveFatalQueryException(ioe);
            }
        } else {
            QueryException qe = new QueryException(DatawaveErrorCode.UNEXPECTED_SOURCE_NODE, MessageFormat.format("{0}", "Limited ExceededOrThresholdMarkerJexlNode"));
            throw new DatawaveFatalQueryException(qe);
        }
    } else if (data instanceof IndexRangeIteratorBuilder) {
        // index checking has already been done, otherwise we would not have
        // an "ExceededValueThresholdMarker"
        // hence the "IndexAgnostic" method can be used here
        LiteralRange range = JexlASTHelper.findRange().recursively().getRange(and);
        if (range == null) {
            QueryException qe = new QueryException(DatawaveErrorCode.MULTIPLE_RANGES_IN_EXPRESSION);
            throw new DatawaveFatalQueryException(qe);
        }
        ((IndexRangeIteratorBuilder) data).setRange(range);
    } else if (instance.isType(ExceededValueThresholdMarkerJexlNode.class)) {
        // if the parent is our ExceededValueThreshold marker, then use an
        // Ivarator to get the job done unless we don't have to
        JexlNode source = instance.getSource();
        String identifier = null;
        LiteralRange<?> range = null;
        boolean negatedLocal = false;
        if (source instanceof ASTAndNode) {
            range = buildLiteralRange(source, null);
            identifier = range.getFieldName();
        } else {
            if (source instanceof ASTNRNode || source instanceof ASTNotNode)
                negatedLocal = true;
            range = buildLiteralRange(source);
            identifier = JexlASTHelper.getIdentifier(source);
        }
        boolean negatedOverall = negatedLocal;
        if (data instanceof AbstractIteratorBuilder) {
            AbstractIteratorBuilder oib = (AbstractIteratorBuilder) data;
            if (oib.isInANot()) {
                negatedOverall = !negatedOverall;
            }
        }
        // or the field is index only but not in the term frequencies, then we must ivarate
        if (!limitLookup || !allowTermFrequencyLookup || (indexOnlyFields.contains(identifier) && !termFrequencyFields.contains(identifier))) {
            if (source instanceof ASTAndNode) {
                try {
                    List<ASTFunctionNode> functionNodes = JexlASTHelper.getFunctionNodes(source).stream().filter(node -> JexlFunctionArgumentDescriptorFactory.F.getArgumentDescriptor(node).allowIvaratorFiltering()).collect(Collectors.toList());
                    if (functionNodes.isEmpty()) {
                        ivarateRange(and, source, data);
                    } else {
                        ivarateFilter(and, source, data, functionNodes);
                    }
                } catch (IOException ioe) {
                    throw new DatawaveFatalQueryException("Unable to ivarate", ioe);
                }
            } else if (source instanceof ASTERNode || source instanceof ASTNRNode) {
                try {
                    ivarateRegex(and, source, data);
                } catch (IOException ioe) {
                    throw new DatawaveFatalQueryException("Unable to ivarate", ioe);
                }
            } else {
                QueryException qe = new QueryException(DatawaveErrorCode.UNEXPECTED_SOURCE_NODE, MessageFormat.format("{0}", "ExceededValueThresholdMarkerJexlNode"));
                throw new DatawaveFatalQueryException(qe);
            }
        } else {
            NestedIterator<Key> nested = null;
            if (termFrequencyFields.contains(identifier)) {
                nested = buildExceededFromTermFrequency(identifier, and, source, range, data);
            } else {
                /**
                 * This is okay since 1) We are doc specific 2) We are not index only or tf 3) Therefore, we must evaluate against the document for this
                 * expression 4) Return a stubbed range in case we have a disjunction that breaks the current doc.
                 */
                if (!limitOverride && !negatedOverall)
                    nested = createExceededCheck(identifier, range, and);
            }
            if (null != nested && null != data && data instanceof AbstractIteratorBuilder) {
                AbstractIteratorBuilder iterators = (AbstractIteratorBuilder) data;
                if (negatedLocal) {
                    iterators.addExclude(nested);
                } else {
                    iterators.addInclude(nested);
                }
            } else {
                if (isQueryFullySatisfied == true) {
                    log.warn("Determined that isQueryFullySatisfied should be false, but it was not preset to false in the SatisfactionVisitor");
                }
                return nested;
            }
        }
    } else if (null != data && data instanceof AndIteratorBuilder) {
        and.childrenAccept(this, data);
    } else {
        // Create an AndIterator and recursively add the children
        AbstractIteratorBuilder andItr = new AndIteratorBuilder();
        andItr.negateAsNeeded(data);
        and.childrenAccept(this, andItr);
        // If there is no parent
        if (data == null) {
            // Make this AndIterator the root node
            if (!andItr.includes().isEmpty()) {
                root = andItr.build();
            }
        } else {
            // Otherwise, add this AndIterator to its parent
            AbstractIteratorBuilder parent = (AbstractIteratorBuilder) data;
            if (!andItr.includes().isEmpty()) {
                parent.addInclude(andItr.build());
            }
        }
        if (log.isTraceEnabled()) {
            log.trace("ASTAndNode visit: pretty formatting of:\nparent.includes:" + formatIncludesOrExcludes(andItr.includes()) + "\nparent.excludes:" + formatIncludesOrExcludes(andItr.excludes()));
        }
    }
    return null;
}
Also used : Arrays(java.util.Arrays) Text(org.apache.hadoop.io.Text) ASTSizeMethod(org.apache.commons.jexl2.parser.ASTSizeMethod) AbstractIteratorBuilder(datawave.query.iterator.builder.AbstractIteratorBuilder) JavaRegexParseException(datawave.query.parser.JavaRegexAnalyzer.JavaRegexParseException) IvaratorCacheDir(datawave.query.iterator.ivarator.IvaratorCacheDir) ASTNRNode(org.apache.commons.jexl2.parser.ASTNRNode) Map(java.util.Map) ExceededValueThresholdMarkerJexlNode(datawave.query.jexl.nodes.ExceededValueThresholdMarkerJexlNode) AttributeFactory(datawave.query.attributes.AttributeFactory) JexlFunctionArgumentDescriptorFactory(datawave.query.jexl.functions.JexlFunctionArgumentDescriptorFactory) ExceededOrThresholdMarkerJexlNode(datawave.query.jexl.nodes.ExceededOrThresholdMarkerJexlNode) DatawaveFatalQueryException(datawave.query.exceptions.DatawaveFatalQueryException) ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) TimeFilter(datawave.query.predicate.TimeFilter) Set(java.util.Set) IndexRangeIteratorBuilder(datawave.query.iterator.builder.IndexRangeIteratorBuilder) ASTNENode(org.apache.commons.jexl2.parser.ASTNENode) DefaultArithmetic(datawave.query.jexl.DefaultArithmetic) ASTOrNode(org.apache.commons.jexl2.parser.ASTOrNode) Predicate(com.google.common.base.Predicate) AndIteratorBuilder(datawave.query.iterator.builder.AndIteratorBuilder) JexlContext(org.apache.commons.jexl2.JexlContext) DatawaveFieldIndexListIteratorJexl(datawave.core.iterators.DatawaveFieldIndexListIteratorJexl) TermFrequencyAggregator(datawave.query.jexl.functions.TermFrequencyAggregator) FileSortedSet(datawave.query.util.sortedset.FileSortedSet) IteratorBuilder(datawave.query.iterator.builder.IteratorBuilder) ASTEQNode(org.apache.commons.jexl2.parser.ASTEQNode) NestedIterator(datawave.query.iterator.NestedIterator) JexlASTHelper(datawave.query.jexl.JexlASTHelper) IndexIteratorBuilder(datawave.query.iterator.builder.IndexIteratorBuilder) JexlArithmetic(org.apache.commons.jexl2.JexlArithmetic) ASTMethodNode(org.apache.commons.jexl2.parser.ASTMethodNode) IteratorToSortedKeyValueIterator(datawave.query.util.IteratorToSortedKeyValueIterator) JexlNode(org.apache.commons.jexl2.parser.JexlNode) SortedKeyValueIterator(org.apache.accumulo.core.iterators.SortedKeyValueIterator) TreeSet(java.util.TreeSet) SourceFactory(datawave.query.iterator.SourceFactory) ArrayList(java.util.ArrayList) NodeOperand(datawave.query.jexl.LiteralRange.NodeOperand) Lists(com.google.common.collect.Lists) LiteralRange(datawave.query.jexl.LiteralRange) Key(org.apache.accumulo.core.data.Key) IndexFilterIteratorBuilder(datawave.query.iterator.builder.IndexFilterIteratorBuilder) OrIteratorBuilder(datawave.query.iterator.builder.OrIteratorBuilder) Predicates(com.google.common.base.Predicates) EventFieldIterator(datawave.query.iterator.EventFieldIterator) IndexRegexIteratorBuilder(datawave.query.iterator.builder.IndexRegexIteratorBuilder) FileSystemCache(datawave.core.iterators.filesystem.FileSystemCache) FieldIndexAggregator(datawave.query.jexl.functions.FieldIndexAggregator) QueryPropertyMarker(datawave.query.jexl.nodes.QueryPropertyMarker) TermFrequencyIndexBuilder(datawave.query.iterator.builder.TermFrequencyIndexBuilder) IOException(java.io.IOException) IndexListIteratorBuilder(datawave.query.iterator.builder.IndexListIteratorBuilder) DatawaveErrorCode(datawave.webservice.query.exception.DatawaveErrorCode) QueryLock(datawave.core.iterators.querylock.QueryLock) OrIterator(datawave.query.iterator.logic.OrIterator) NegationBuilder(datawave.query.iterator.builder.NegationBuilder) Range(org.apache.accumulo.core.data.Range) JavaRegexAnalyzer(datawave.query.parser.JavaRegexAnalyzer) Filter(datawave.query.predicate.Filter) QueryException(datawave.webservice.query.exception.QueryException) ASTEvaluationOnly(org.apache.commons.jexl2.parser.ASTEvaluationOnly) FST(org.apache.lucene.util.fst.FST) PartialKey(org.apache.accumulo.core.data.PartialKey) QuerySpanCollector(datawave.query.iterator.profile.QuerySpanCollector) IvaratorBuilder(datawave.query.iterator.builder.IvaratorBuilder) ASTIdentifier(org.apache.commons.jexl2.parser.ASTIdentifier) IteratorEnvironment(org.apache.accumulo.core.iterators.IteratorEnvironment) Script(org.apache.commons.jexl2.Script) SortedSet(java.util.SortedSet) DatawaveJexlEngine(datawave.query.jexl.DatawaveJexlEngine) URISyntaxException(java.net.URISyntaxException) SourceManager(datawave.query.iterator.SourceManager) Logger(org.apache.log4j.Logger) ValueTuple(datawave.query.attributes.ValueTuple) EventDataQueryFilter(datawave.query.predicate.EventDataQueryFilter) ASTNotNode(org.apache.commons.jexl2.parser.ASTNotNode) ASTStringLiteral(org.apache.commons.jexl2.parser.ASTStringLiteral) Path(org.apache.hadoop.fs.Path) Value(org.apache.accumulo.core.data.Value) URI(java.net.URI) UniversalSet(datawave.util.UniversalSet) TypeMetadata(datawave.query.util.TypeMetadata) ASTDelayedPredicate(org.apache.commons.jexl2.parser.ASTDelayedPredicate) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) IdentifierOpLiteral(datawave.query.jexl.JexlASTHelper.IdentifierOpLiteral) Entry(java.util.Map.Entry) IvaratorCacheDirConfig(datawave.query.iterator.ivarator.IvaratorCacheDirConfig) EventDataQueryExpressionFilter(datawave.query.predicate.EventDataQueryExpressionFilter) JexlNodes.children(org.apache.commons.jexl2.parser.JexlNodes.children) GenericObjectPool(org.apache.commons.pool.impl.GenericObjectPool) ASTReferenceExpression(org.apache.commons.jexl2.parser.ASTReferenceExpression) ASTNumberLiteral(org.apache.commons.jexl2.parser.ASTNumberLiteral) NoOpType(datawave.data.type.NoOpType) IdentityAggregator(datawave.query.jexl.functions.IdentityAggregator) MessageFormat(java.text.MessageFormat) HashSet(java.util.HashSet) ASTERNode(org.apache.commons.jexl2.parser.ASTERNode) DatawaveJexlContext(datawave.query.jexl.DatawaveJexlContext) ASTAndNode(org.apache.commons.jexl2.parser.ASTAndNode) NoSuchElementException(java.util.NoSuchElementException) ParserTreeConstants(org.apache.commons.jexl2.parser.ParserTreeConstants) MalformedURLException(java.net.MalformedURLException) Maps(com.google.common.collect.Maps) Constants(datawave.query.Constants) ArithmeticJexlEngines(datawave.query.jexl.ArithmeticJexlEngines) ASTFunctionNode(org.apache.commons.jexl2.parser.ASTFunctionNode) CompositeMetadata(datawave.query.composite.CompositeMetadata) EventFieldAggregator(datawave.query.jexl.functions.EventFieldAggregator) Collections(java.util.Collections) ChainableEventDataQueryFilter(datawave.query.predicate.ChainableEventDataQueryFilter) ASTReference(org.apache.commons.jexl2.parser.ASTReference) ASTNotNode(org.apache.commons.jexl2.parser.ASTNotNode) ASTERNode(org.apache.commons.jexl2.parser.ASTERNode) ASTNRNode(org.apache.commons.jexl2.parser.ASTNRNode) QueryPropertyMarker(datawave.query.jexl.nodes.QueryPropertyMarker) IOException(java.io.IOException) AndIteratorBuilder(datawave.query.iterator.builder.AndIteratorBuilder) DatawaveFatalQueryException(datawave.query.exceptions.DatawaveFatalQueryException) QueryException(datawave.webservice.query.exception.QueryException) ASTFunctionNode(org.apache.commons.jexl2.parser.ASTFunctionNode) AbstractIteratorBuilder(datawave.query.iterator.builder.AbstractIteratorBuilder) DatawaveFatalQueryException(datawave.query.exceptions.DatawaveFatalQueryException) ExceededValueThresholdMarkerJexlNode(datawave.query.jexl.nodes.ExceededValueThresholdMarkerJexlNode) ExceededOrThresholdMarkerJexlNode(datawave.query.jexl.nodes.ExceededOrThresholdMarkerJexlNode) JexlNode(org.apache.commons.jexl2.parser.JexlNode) IndexRangeIteratorBuilder(datawave.query.iterator.builder.IndexRangeIteratorBuilder) LiteralRange(datawave.query.jexl.LiteralRange) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey) ASTAndNode(org.apache.commons.jexl2.parser.ASTAndNode)

Example 2 with ASTNotNode

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

the class PushdownNegationVisitor method visit.

@Override
public Object visit(ASTNotNode node, Object data) {
    // if there is already a negation passed down it should negate this node and continue down the tree to check for other negations
    if (data != null && ((NegationState) data).isNegated()) {
        JexlNode nextNode = dropNot(node, (NegationState) data);
        // pass down with a new negation state since nothing that comes up from this point should impact what is already being returned (a processed
        // negation)
        nextNode.jjtAccept(this, new NegationState(false));
        return data;
    } else {
        // arrived to this node without a negation, apply a negation and push down
        NegationState state = (NegationState) super.visit(node, new NegationState(true));
        // if the returned state is false the negation was successfully pushed down, it should be removed
        if (!state.isNegated()) {
            // drop the not because it was pushed down and get the new node
            JexlNode nextNode = dropNot(node, new NegationState(true));
            // the negation at this level was removed so the state is false going forward
            nextNode.jjtAccept(this, new NegationState(false));
        }
        // any down-tree state manipulation is a result of this NOT so do not back propagate that
        return data;
    }
}
Also used : JexlNode(org.apache.commons.jexl2.parser.JexlNode)

Example 3 with ASTNotNode

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

the class PushdownNegationVisitor method applyDeMorgans.

/**
 * Apply De Morgan's law to a node, splicing out the old root and putting a replacement in its place. De Morgans law states that the negation of a
 * disjunction is the conjunction of the negations; and the negation of a conjunction is the disjunction of the negations
 *
 * By generalizing De Morgans duality, an ASTAndNode can be converted to an ASTOrNode by applying a negation to the root, flipping the operator (AND to OR
 * vice versa), and negating each child then splicing the new root into the parent
 *
 * @param root
 *            the node to apply De Morgan's law to either an ASTAndNode or ASTOrNode, must not be null
 * @param negateRoot
 *            apply the negation of the parent here, or assume that will be done eventually elsewhere
 *
 * @return the replacement for root which was replaced, will always be an ASTNotNode
 */
public static JexlNode applyDeMorgans(JexlNode root, boolean negateRoot) {
    if (root == null) {
        throw new IllegalArgumentException("root must not be null");
    }
    if (root.jjtGetNumChildren() == 0) {
        throw new IllegalStateException("root must have at least one child");
    }
    // build the child list, while negating each child
    List<JexlNode> negatedChildren = new ArrayList<>(root.jjtGetNumChildren());
    for (int i = 0; i < root.jjtGetNumChildren(); i++) {
        negatedChildren.add(JexlNodes.negate(root.jjtGetChild(i)));
    }
    // flip the root operator and finish validating the root
    JexlNode newRoot;
    if (root instanceof ASTAndNode) {
        newRoot = JexlNodeFactory.createOrNode(negatedChildren);
    } else if (root instanceof ASTOrNode) {
        newRoot = JexlNodeFactory.createAndNode(negatedChildren);
    } else {
        throw new IllegalArgumentException("root must be either an ASTAndNode or ASTOrNode");
    }
    if (negateRoot) {
        // negate the new node
        newRoot = JexlNodes.negate(newRoot);
    }
    // if there is a parent to swap
    if (root.jjtGetParent() != null) {
        // replace root with the newly negated node, AND -> OR or OR -> AND
        JexlNodes.swap(root.jjtGetParent(), root, newRoot);
    }
    return newRoot;
}
Also used : ASTOrNode(org.apache.commons.jexl2.parser.ASTOrNode) ArrayList(java.util.ArrayList) JexlNode(org.apache.commons.jexl2.parser.JexlNode) ASTAndNode(org.apache.commons.jexl2.parser.ASTAndNode)

Example 4 with ASTNotNode

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

the class JexlNodeFactory method shallowCopy.

/**
 * A shallow copy of the given JexlNode, creates a new node of the same type with the same parent and image. Children are not copied
 *
 * @param original
 * @return
 */
public static JexlNode shallowCopy(JexlNode original) {
    if (null == original) {
        throw new IllegalArgumentException();
    }
    JexlNode copy;
    Class<?> clz = original.getClass();
    if (ASTAndNode.class.isAssignableFrom(clz)) {
        copy = new ASTAndNode(ParserTreeConstants.JJTANDNODE);
    } else if (ASTBitwiseAndNode.class.isAssignableFrom(clz)) {
        copy = new ASTBitwiseAndNode(ParserTreeConstants.JJTBITWISEANDNODE);
    } else if (ASTBitwiseComplNode.class.isAssignableFrom(clz)) {
        copy = new ASTBitwiseComplNode(ParserTreeConstants.JJTBITWISECOMPLNODE);
    } else if (ASTBitwiseOrNode.class.isAssignableFrom(clz)) {
        copy = new ASTBitwiseOrNode(ParserTreeConstants.JJTBITWISEORNODE);
    } else if (ASTBitwiseXorNode.class.isAssignableFrom(clz)) {
        copy = new ASTBitwiseXorNode(ParserTreeConstants.JJTBITWISEXORNODE);
    } else if (ASTEmptyFunction.class.isAssignableFrom(clz)) {
        copy = new ASTEmptyFunction(ParserTreeConstants.JJTEMPTYFUNCTION);
    } else if (ASTEQNode.class.isAssignableFrom(clz)) {
        copy = new ASTEQNode(ParserTreeConstants.JJTEQNODE);
    } else if (ASTERNode.class.isAssignableFrom(clz)) {
        copy = new ASTERNode(ParserTreeConstants.JJTERNODE);
    } else if (ASTFalseNode.class.isAssignableFrom(clz)) {
        copy = new ASTFalseNode(ParserTreeConstants.JJTFALSENODE);
    } else if (ASTGENode.class.isAssignableFrom(clz)) {
        copy = new ASTGENode(ParserTreeConstants.JJTGENODE);
    } else if (ASTGTNode.class.isAssignableFrom(clz)) {
        copy = new ASTGTNode(ParserTreeConstants.JJTGTNODE);
    } else if (ASTIdentifier.class.isAssignableFrom(clz)) {
        copy = new ASTIdentifier(ParserTreeConstants.JJTIDENTIFIER);
    } else if (ASTLENode.class.isAssignableFrom(clz)) {
        copy = new ASTLENode(ParserTreeConstants.JJTLENODE);
    } else if (ASTLTNode.class.isAssignableFrom(clz)) {
        copy = new ASTLTNode(ParserTreeConstants.JJTLTNODE);
    } else if (ASTNENode.class.isAssignableFrom(clz)) {
        copy = new ASTNENode(ParserTreeConstants.JJTNENODE);
    } else if (ASTNRNode.class.isAssignableFrom(clz)) {
        copy = new ASTNRNode(ParserTreeConstants.JJTNRNODE);
    } else if (ASTNotNode.class.isAssignableFrom(clz)) {
        copy = new ASTNotNode(ParserTreeConstants.JJTNOTNODE);
    } else if (ASTNullLiteral.class.isAssignableFrom(clz)) {
        copy = new ASTNullLiteral(ParserTreeConstants.JJTNULLLITERAL);
    } else if (ASTNumberLiteral.class.isAssignableFrom(clz)) {
        copy = new ASTNumberLiteral(ParserTreeConstants.JJTNUMBERLITERAL);
        JexlNodes.setLiteral((ASTNumberLiteral) copy, ((ASTNumberLiteral) original).getLiteral());
    } else if (ASTOrNode.class.isAssignableFrom(clz)) {
        copy = new ASTOrNode(ParserTreeConstants.JJTORNODE);
    } else if (ASTStringLiteral.class.isAssignableFrom(clz)) {
        copy = new ASTStringLiteral(ParserTreeConstants.JJTSTRINGLITERAL);
        JexlNodes.setLiteral((ASTStringLiteral) copy, ((ASTStringLiteral) original).getLiteral());
    } else if (ASTTrueNode.class.isAssignableFrom(clz)) {
        copy = new ASTTrueNode(ParserTreeConstants.JJTTRUENODE);
    } else if (ASTReferenceExpression.class.isAssignableFrom(clz)) {
        copy = new ASTReferenceExpression(ParserTreeConstants.JJTREFERENCEEXPRESSION);
    } else if (ASTReference.class.isAssignableFrom(clz)) {
        copy = new ASTReference(ParserTreeConstants.JJTREFERENCE);
    } else if (ASTAdditiveNode.class.isAssignableFrom(clz)) {
        copy = new ASTAdditiveNode(ParserTreeConstants.JJTADDITIVENODE);
    } else if (ASTMethodNode.class.isAssignableFrom(clz)) {
        copy = new ASTMethodNode(ParserTreeConstants.JJTMETHODNODE);
    } else if (ASTFunctionNode.class.isAssignableFrom(clz)) {
        copy = new ASTFunctionNode(ParserTreeConstants.JJTFUNCTIONNODE);
    } else if (ASTMulNode.class.isAssignableFrom(clz)) {
        copy = new ASTMulNode(ParserTreeConstants.JJTMULNODE);
    } else if (ASTAssignment.class.isAssignableFrom(clz)) {
        copy = new ASTAssignment(ParserTreeConstants.JJTASSIGNMENT);
    } else {
        throw new UnsupportedOperationException();
    }
    copy.jjtSetParent(original.jjtGetParent());
    copy.image = original.image;
    return copy;
}
Also used : ASTReferenceExpression(org.apache.commons.jexl2.parser.ASTReferenceExpression) ASTNENode(org.apache.commons.jexl2.parser.ASTNENode) ASTNumberLiteral(org.apache.commons.jexl2.parser.ASTNumberLiteral) ASTMulNode(org.apache.commons.jexl2.parser.ASTMulNode) ASTBitwiseComplNode(org.apache.commons.jexl2.parser.ASTBitwiseComplNode) ASTMethodNode(org.apache.commons.jexl2.parser.ASTMethodNode) ASTBitwiseXorNode(org.apache.commons.jexl2.parser.ASTBitwiseXorNode) ASTOrNode(org.apache.commons.jexl2.parser.ASTOrNode) ASTStringLiteral(org.apache.commons.jexl2.parser.ASTStringLiteral) ASTBitwiseAndNode(org.apache.commons.jexl2.parser.ASTBitwiseAndNode) ASTNotNode(org.apache.commons.jexl2.parser.ASTNotNode) ASTGENode(org.apache.commons.jexl2.parser.ASTGENode) ASTERNode(org.apache.commons.jexl2.parser.ASTERNode) ASTAdditiveNode(org.apache.commons.jexl2.parser.ASTAdditiveNode) ASTNRNode(org.apache.commons.jexl2.parser.ASTNRNode) ASTTrueNode(org.apache.commons.jexl2.parser.ASTTrueNode) ASTIdentifier(org.apache.commons.jexl2.parser.ASTIdentifier) ASTAssignment(org.apache.commons.jexl2.parser.ASTAssignment) ASTGTNode(org.apache.commons.jexl2.parser.ASTGTNode) ASTNullLiteral(org.apache.commons.jexl2.parser.ASTNullLiteral) ASTLTNode(org.apache.commons.jexl2.parser.ASTLTNode) ASTReference(org.apache.commons.jexl2.parser.ASTReference) ASTBitwiseOrNode(org.apache.commons.jexl2.parser.ASTBitwiseOrNode) ASTFunctionNode(org.apache.commons.jexl2.parser.ASTFunctionNode) ASTLENode(org.apache.commons.jexl2.parser.ASTLENode) ASTEQNode(org.apache.commons.jexl2.parser.ASTEQNode) ASTFalseNode(org.apache.commons.jexl2.parser.ASTFalseNode) ExceededValueThresholdMarkerJexlNode(datawave.query.jexl.nodes.ExceededValueThresholdMarkerJexlNode) JexlNode(org.apache.commons.jexl2.parser.JexlNode) ExceededTermThresholdMarkerJexlNode(datawave.query.jexl.nodes.ExceededTermThresholdMarkerJexlNode) ASTEmptyFunction(org.apache.commons.jexl2.parser.ASTEmptyFunction) ASTAndNode(org.apache.commons.jexl2.parser.ASTAndNode)

Example 5 with ASTNotNode

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

the class PushdownNegationVisitor method dropNot.

private JexlNode dropNot(ASTNotNode toDrop, NegationState state) {
    JexlNode newNode = toDrop.jjtGetChild(0);
    // no need to swap nodes if toDrop is the root
    if (toDrop.jjtGetParent() != null) {
        // connect the child to the parent cutting this node out
        JexlNodes.swap(toDrop.jjtGetParent(), toDrop, newNode);
    }
    // negate the data so the parent Not knows it was successfully pushed down
    state.setNegated(false);
    return newNode;
}
Also used : JexlNode(org.apache.commons.jexl2.parser.JexlNode)

Aggregations

JexlNode (org.apache.commons.jexl2.parser.JexlNode)5 ASTAndNode (org.apache.commons.jexl2.parser.ASTAndNode)3 ASTOrNode (org.apache.commons.jexl2.parser.ASTOrNode)3 ExceededValueThresholdMarkerJexlNode (datawave.query.jexl.nodes.ExceededValueThresholdMarkerJexlNode)2 ArrayList (java.util.ArrayList)2 ASTEQNode (org.apache.commons.jexl2.parser.ASTEQNode)2 ASTERNode (org.apache.commons.jexl2.parser.ASTERNode)2 ASTFunctionNode (org.apache.commons.jexl2.parser.ASTFunctionNode)2 ASTIdentifier (org.apache.commons.jexl2.parser.ASTIdentifier)2 ASTMethodNode (org.apache.commons.jexl2.parser.ASTMethodNode)2 ASTNENode (org.apache.commons.jexl2.parser.ASTNENode)2 ASTNRNode (org.apache.commons.jexl2.parser.ASTNRNode)2 ASTNotNode (org.apache.commons.jexl2.parser.ASTNotNode)2 ASTNumberLiteral (org.apache.commons.jexl2.parser.ASTNumberLiteral)2 ASTReference (org.apache.commons.jexl2.parser.ASTReference)2 ASTReferenceExpression (org.apache.commons.jexl2.parser.ASTReferenceExpression)2 ASTStringLiteral (org.apache.commons.jexl2.parser.ASTStringLiteral)2 Predicate (com.google.common.base.Predicate)1 Predicates (com.google.common.base.Predicates)1 Lists (com.google.common.collect.Lists)1