| java.lang.Object org.mmbase.bridge.util.HugeNodeListIterator
HugeNodeListIterator | public class HugeNodeListIterator implements NodeIterator(Code) | | Iterates the big result of a query. It avoids using a lot of memory (which you would need if you
get the complete NodeList first), and pollution of the (node) cache. In this current
implementation the Query is 'batched' to avoid reading in all nodes in memory, and the queries
are marked with
CachePolicy.NEVER .
author: Michiel Meeuwissen version: $Id: HugeNodeListIterator.java,v 1.6 2007/02/10 15:47:42 nklasens Exp $ since: MMBase-1.8 |
Method Summary | |
public void | add(Node o) | protected int | compares(Node node1, Node node2) Used by nextNode and previousNode. | protected void | executeNextQuery(Query q) Executes the given query, and prepares to do 'next', so setting 'nextNode' and 'previousNode'. | protected void | executePreviousQuery(Query q) Executes the given query, and prepares to do 'previous', so setting 'nextNode' and
'previousNode', and winds the new nodeIterator to the end. | protected void | executeQuery(Query currentQuery) Executes the given query, taking into account the fact wether it is NodeQuery or not, and
applying the 'batchSize'. | public boolean | hasNext() | public boolean | hasPrevious() | public static void | main(String[] args) Main only for testing. | public Node | next() | public int | nextIndex() | public Node | nextNode() Implementation calculates also the next next Node, and gives back the 'old' next Node, from
now on known as 'previousNode'. | public Node | previous() | public int | previousIndex() | public Node | previousNode() Implementation is analogous to nextNode. | public void | remove() | public void | set(Node o) |
DEFAULT_BATCH_SIZE | final public static int DEFAULT_BATCH_SIZE(Code) | | |
batchSize | protected int batchSize(Code) | | |
nextIndex | protected int nextIndex(Code) | | |
HugeNodeListIterator | public HugeNodeListIterator(Query query, int batchSize)(Code) | | Constructor for this Iterator.
Parameters: query - The query which is used as a base for the querie(s) to be executed. Parameters: batchSize - The (approximate) size of the sub-queries, should be a reasonably largenumber, like 10000 or so. |
HugeNodeListIterator | public HugeNodeListIterator(Query query)(Code) | | Constructor for this Iterator. The 'batchSize' is taken from the query's 'maxnumber'
properties, or, it that is not set, it is defaulted to 10000.
Parameters: query - The query which is used as a base for the querie(s) to be executed. |
compares | protected int compares(Node node1, Node node2)(Code) | | Used by nextNode and previousNode. Does a field-by-field compare of two Node objects, on
the fields used to order the nodes.
This is used to determine whether a node comes after or before another - allowing
the node iterator to skip nodes it already 'had'.
-1 if node1 is smaller than node 2, 0 if both nodes are equals, and +1 is node 1 is greater than node 2. |
executeNextQuery | protected void executeNextQuery(Query q)(Code) | | Executes the given query, and prepares to do 'next', so setting 'nextNode' and 'previousNode'.
|
executePreviousQuery | protected void executePreviousQuery(Query q)(Code) | | Executes the given query, and prepares to do 'previous', so setting 'nextNode' and
'previousNode', and winds the new nodeIterator to the end.
|
executeQuery | protected void executeQuery(Query currentQuery)(Code) | | Executes the given query, taking into account the fact wether it is NodeQuery or not, and
applying the 'batchSize'. The result is available in the 'nodeIterator' member.
|
hasNext | public boolean hasNext()(Code) | | |
hasPrevious | public boolean hasPrevious()(Code) | | |
main | public static void main(String[] args)(Code) | | Main only for testing.
|
nextIndex | public int nextIndex()(Code) | | |
nextNode | public Node nextNode()(Code) | | Implementation calculates also the next next Node, and gives back the 'old' next Node, from
now on known as 'previousNode'.
|
previousIndex | public int previousIndex()(Code) | | |
previousNode | public Node previousNode()(Code) | | Implementation is analogous to nextNode.
|
|
|