public boolean getAllowsChildren() { return !exprNode.isLeaf(); }
/** * Makes a full clone in new memory space of the current node and children * * @return the clone */ @Override public ExprNode clone() { ExprNode clone = (ExprNode)super.clone(); // Clone the children if ( children != null ) { ((BranchNode)clone).children = new ArrayList<ExprNode>(); for ( ExprNode child : children ) { ((BranchNode)clone).children.add( (ExprNode)child.clone() ); } } return clone; }
/** * Disjunctions (OR) are the union of candidates across all subexpressions * so we add all the counts of the child nodes. Notice that we annotate the * child node with a recursive call. * * @param node the OR branch node * @return the scan count on the OR node * @throws NamingException if there is an error */ private BigInteger getDisjunctionScan( BranchNode node ) throws NamingException { ArrayList children = node.getChildren(); BigInteger total = BigInteger.ZERO; for ( int ii = 0; ii < children.size(); ii++ ) { ExprNode child = ( ExprNode ) children.get( ii ); annotate( child ); total = total.add( ( BigInteger ) child.get( "count" ) ); } // we don't want values bigger than Integer.MAX_VALUE if ( total.compareTo( MAX ) > 0 ) { total = MAX; } return total; }
/** * @see Object#toString() */ public String toString() { StringBuilder buf = new StringBuilder(); buf.append( "classes " ); classes.printRefinementToBuffer( buf ); return buf.toString(); } }
node.accept( visitor );
/** * @see ExprNode#printRefinementToBuffer(StringBuffer) * * @return The buffer in which the refinement has been appended * @throws UnsupportedOperationException if this node isn't a part of a refinement. */ public StringBuilder printRefinementToBuffer( StringBuilder buf ) { buf.append( "not: {" ); boolean isFirst = true; for ( ExprNode node:children ) { if ( isFirst ) { isFirst = false; } else { buf.append( ", " ); } node.printRefinementToBuffer( buf ); } buf.append( '}' ); return buf; }
public boolean getAllowsChildren() { return !exprNode.isLeaf(); }
/** * @see ExprNode#printRefinementToBuffer(StringBuffer) * * @return The buffer in which the refinement has been appended * @throws UnsupportedOperationException if this node isn't a part of a refinement. */ public StringBuilder printRefinementToBuffer( StringBuilder buf ) { buf.append( "or: {" ); boolean isFirst = true; for ( ExprNode node:children ) { if ( isFirst ) { isFirst = false; } else { buf.append( ", " ); } node.printRefinementToBuffer( buf ); } buf.append( '}' ); return buf; }
/** * ANDs or Conjunctions take the count of the smallest child as their count. * This is the best that a conjunction can do and should be used rather than * the worst case. Notice that we annotate the child node with a recursive * call before accessing its count parameter making the chain recursion * depth first. * * @param node a AND (Conjunction) BranchNode * @return the calculated scan count * @throws NamingException if there is an error */ private BigInteger getConjunctionScan( BranchNode node ) throws NamingException { BigInteger count = MAX; ArrayList children = node.getChildren(); for ( int ii = 0; ii < children.size(); ii++ ) { ExprNode child = ( ExprNode ) children.get( ii ); annotate( child ); count = ( ( BigInteger ) child.get( "count" ) ).min( count ); } return count; }
if ( exprNode.isLeaf() )
/** * @see ExprNode#printRefinementToBuffer(StringBuffer) * * @param buf the buffer to append to. * @return The buffer in which the refinement has been appended * @throws UnsupportedOperationException if this node isn't a part of a refinement. */ public StringBuilder printRefinementToBuffer( StringBuilder buf ) { buf.append( "and: {" ); boolean isFirst = true; for ( ExprNode node:children ) { if ( isFirst ) { isFirst = false; } else { buf.append( ", " ); } node.printRefinementToBuffer( buf ); } buf.append( '}' ); return buf; }
value = ( ( BigInteger ) child.get( "count" ) ).intValue(); minValue = Math.min( minValue, value );
if ( exprNode.isLeaf() )
refinement.printRefinementToBuffer( tempBuffer ); buffer.append( tempBuffer );
if ( !child.isLeaf() )