|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.bridge.util.HugeNodeListIterator
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.
| Field Summary | |
protected int |
batchSize
|
static int |
DEFAULT_BATCH_SIZE
|
protected int |
nextIndex
|
protected Node |
nextNode
|
protected NodeIterator |
nodeIterator
|
protected Query |
originalQuery
|
protected Node |
previousNode
|
| Constructor Summary | |
HugeNodeListIterator(Query query)
Constructor for this Iterator. |
|
HugeNodeListIterator(Query query,
int batchSize)
Constructor for this Iterator. |
|
| Method Summary | |
void |
add(Object 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'. |
boolean |
hasNext()
|
boolean |
hasPrevious()
|
static void |
main(String[] args)
Main only for testing. |
Object |
next()
|
int |
nextIndex()
|
Node |
nextNode()
Returns the next element in the iterator as a Node Implementation calculates also the next next Node, and gives back the 'old' next Node, from now on known as 'previousNode'. |
Object |
previous()
|
int |
previousIndex()
|
Node |
previousNode()
Returns the previous element in the iterator as a Node Implementation is analogous to nextNode. |
void |
remove()
|
void |
set(Object o)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int DEFAULT_BATCH_SIZE
protected NodeIterator nodeIterator
protected Node nextNode
protected Node previousNode
protected Query originalQuery
protected int batchSize
protected int nextIndex
| Constructor Detail |
public HugeNodeListIterator(Query query,
int batchSize)
query - The query which is used as a base for the querie(s) to be executed.batchSize - The (approximate) size of the sub-queries, should be a reasonably large
number, like 10000 or so.public HugeNodeListIterator(Query query)
query - The query which is used as a base for the querie(s) to be executed.| Method Detail |
protected void executeQuery(Query currentQuery)
protected void executeNextQuery(Query q)
protected void executePreviousQuery(Query q)
public boolean hasNext()
hasNext in interface ListIteratorpublic boolean hasPrevious()
hasPrevious in interface ListIteratorpublic Object next()
next in interface ListIteratorpublic Object previous()
previous in interface ListIteratorpublic int previousIndex()
previousIndex in interface ListIteratorpublic int nextIndex()
nextIndex in interface ListIterator
protected int compares(Node node1,
Node node2)
public Node nextNode()
nextNode in interface NodeIteratorpublic Node previousNode()
previousNode in interface NodeIteratorpublic void remove()
remove in interface ListIteratorUnsupportedOperationExceptionpublic void add(Object o)
add in interface ListIteratorUnsupportedOperationExceptionpublic void set(Object o)
set in interface ListIteratorUnsupportedOperationExceptionpublic static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||