|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mmbase.bridge.util.HugeNodeListIterator
public class 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(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'. |
boolean |
hasNext()
|
boolean |
hasPrevious()
|
static void |
main(String[] args)
Main only for testing. |
Node |
next()
|
int |
nextIndex()
|
Node |
nextNode()
Returns the next element in the iterator as a Node |
Node |
previous()
|
int |
previousIndex()
|
Node |
previousNode()
Returns the previous element in the iterator as a Node |
void |
remove()
|
void |
set(Node 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 Iterator<Node>hasNext in interface ListIterator<Node>public boolean hasPrevious()
hasPrevious in interface ListIterator<Node>public Node next()
next in interface Iterator<Node>next in interface ListIterator<Node>public Node previous()
previous in interface ListIterator<Node>public int previousIndex()
previousIndex in interface ListIterator<Node>public int nextIndex()
nextIndex in interface ListIterator<Node>
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 Iterator<Node>remove in interface ListIterator<Node>UnsupportedOperationExceptionpublic void add(Node o)
add in interface ListIterator<Node>UnsupportedOperationExceptionpublic void set(Node o)
set in interface ListIterator<Node>UnsupportedOperationExceptionpublic static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||