@Override protected List<QueryNode> setChildrenOrder(List<QueryNode> children) throws QueryNodeException { try { for (QueryNode child : children) { if (!child.isLeaf()) { List<QueryNode> grandChildren = child.getChildren(); if (grandChildren != null && grandChildren.size() > 0) { this.childrenBuffer.add(child); } } else { this.childrenBuffer.add(child); } } children.clear(); children.addAll(this.childrenBuffer); } finally { this.childrenBuffer.clear(); } return children; }
@Override protected List<QueryNode> setChildrenOrder(List<QueryNode> children) throws QueryNodeException { try { for (QueryNode child : children) { if (!child.isLeaf()) { List<QueryNode> grandChildren = child.getChildren(); if (grandChildren != null && grandChildren.size() > 0) { this.childrenBuffer.add(child); } } else { this.childrenBuffer.add(child); } } children.clear(); children.addAll(this.childrenBuffer); } finally { this.childrenBuffer.clear(); } return children; }
@Override protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException { if (!node.isLeaf()) { List<QueryNode> children = node.getChildren(); boolean removeBoolean = false; if (children == null || children.size() == 0) { removeBoolean = true; } else { removeBoolean = true; for (Iterator<QueryNode> it = children.iterator(); it.hasNext();) { if (!(it.next() instanceof DeletedQueryNode)) { removeBoolean = false; break; } } } if (removeBoolean) { return new DeletedQueryNode(); } } return node; }
@Override protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException { if (!node.isLeaf()) { List<QueryNode> children = node.getChildren(); boolean removeBoolean = false; if (children == null || children.size() == 0) { removeBoolean = true; } else { removeBoolean = true; for (Iterator<QueryNode> it = children.iterator(); it.hasNext();) { if (!(it.next() instanceof DeletedQueryNode)) { removeBoolean = false; break; } } } if (removeBoolean) { return new DeletedQueryNode(); } } return node; }
@Override public QueryNode process(QueryNode queryTree) throws QueryNodeException { queryTree = super.process(queryTree); if (!queryTree.isLeaf()) { List<QueryNode> children = queryTree.getChildren(); if (children == null || children.size() == 0) { return new MatchNoDocsQueryNode(); } } return queryTree; }
@Override public QueryNode process(QueryNode queryTree) throws QueryNodeException { queryTree = super.process(queryTree); if (!queryTree.isLeaf()) { List<QueryNode> children = queryTree.getChildren(); if (children == null || children.size() == 0) { return new MatchNoDocsQueryNode(); } } return queryTree; }
/** * Sets the given datatype on each descendant of the {@link DatatypeQueryNode} */ private void setDatatype(final QueryNode node, final String datatype) { final Query query = (Query) node.getTag(QueryTreeBuilder.QUERY_TREE_BUILDER_TAGID); if (query instanceof NodePrimitiveQuery) { ((NodePrimitiveQuery) query).setDatatype(datatype); } if (node.isLeaf()) { return; } for (final QueryNode child : node.getChildren()) { this.setDatatype(child, datatype); } }
else if (!node.isLeaf()) { for (final QueryNode child : node.getChildren()) { child.setTag(DatatypeQueryNode.DATATYPE_TAGID, this.getDatatype(conf, node));
@Override protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException { // If the current node is a group query node, check the query type and assign it to its children if (node instanceof GroupQueryNode) { GroupQueryNode groupQueryNode = (GroupQueryNode) node; String queryType = null; if (node instanceof NodeGroupQueryNode) { queryType = NODE_QUERYTYPE; } else if (node instanceof SpanGroupQueryNode) { queryType = SPAN_QUERYTYPE; } else { throw new QueryNodeException(new MessageImpl("Invalid GroupQueryNode received", node.toQueryString(new EscapeQuerySyntaxImpl()))); } // transfer the query type to its child groupQueryNode.getChild().setTag(QUERYTYPE_TAG, queryType); } // in any other cases, if the node is not a leaf node, transfer the query type to its children else if (!node.isLeaf()) { if (node.getTag(QUERYTYPE_TAG) != null) { for (final QueryNode child : node.getChildren()) { child.setTag(QUERYTYPE_TAG, node.getTag(QUERYTYPE_TAG)); } } } return node; }