Search in sources :

Example 1 with NegationBuilder

use of datawave.query.iterator.builder.NegationBuilder in project datawave by NationalSecurityAgency.

the class IteratorBuildingVisitor method visit.

@Override
public Object visit(ASTNotNode not, Object data) {
    // We have no parent
    if (root == null && data == null) {
        // We don't support querying only on a negation
        throw new IllegalStateException("Root node cannot be a negation!");
    }
    NegationBuilder stub = new NegationBuilder();
    stub.negateAsNeeded(data);
    // Add all of the children to this negation
    not.childrenAccept(this, stub);
    // Then add the children to the parent's children
    AbstractIteratorBuilder parent = (AbstractIteratorBuilder) data;
    /*
         * because we're in a negation, the includes become excludes to the parent. conversely, the excludes in the child tree become includes to the parent.
         */
    parent.excludes().addAll(stub.includes());
    parent.includes().addAll(stub.excludes());
    if (log.isTraceEnabled()) {
        log.trace("pretty formatting of:\nparent.includes:" + formatIncludesOrExcludes(parent.includes()) + "\nparent.excludes:" + formatIncludesOrExcludes(parent.excludes()));
    }
    return null;
}
Also used : AbstractIteratorBuilder(datawave.query.iterator.builder.AbstractIteratorBuilder) NegationBuilder(datawave.query.iterator.builder.NegationBuilder)

Aggregations

AbstractIteratorBuilder (datawave.query.iterator.builder.AbstractIteratorBuilder)1 NegationBuilder (datawave.query.iterator.builder.NegationBuilder)1