Class LazyLoadQueryResult
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- org.datanucleus.store.query.AbstractQueryResult
-
- org.datanucleus.store.mongodb.query.LazyLoadQueryResult
-
- All Implemented Interfaces:
Serializable
,Iterable
,Collection
,List
,org.datanucleus.store.query.QueryResult
public class LazyLoadQueryResult extends org.datanucleus.store.query.AbstractQueryResult
QueryResult for MongoDB queries that tries to lazy load results from the provided DBCursor(s) so to avoid problems with memory.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<org.datanucleus.store.mongodb.query.LazyLoadQueryResult.CandidateClassResult>
candidateResults
Candidate results for this query that have not been (completely) processed yet.protected Iterator<com.mongodb.DBObject>
currentCursorIterator
Iterator for the DBCursor that is being processed (if any).protected org.datanucleus.ExecutionContext
ec
protected Map<Integer,Object>
itemsByIndex
Map of object, keyed by the index (0, 1, etc).-
Fields inherited from class org.datanucleus.store.query.AbstractQueryResult
api, closed, connectionListeners, loadResultsAtCommit, query, resultSizeMethod, size
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description LazyLoadQueryResult(org.datanucleus.store.query.Query q)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCandidateResult(org.datanucleus.metadata.AbstractClassMetaData cmd, com.mongodb.DBCursor cursor, int[] fpMembers)
void
close()
protected void
closeResults()
protected void
closingConnection()
boolean
contains(Object o)
boolean
containsAll(Collection c)
boolean
equals(Object o)
Object
get(int index)
protected Object
getNextObject()
Method to extract the next object from the candidateResults (if there is one).boolean
getOrderProcessed()
boolean
getRangeProcessed()
protected int
getSizeUsingMethod()
int
hashCode()
Iterator
iterator()
ListIterator
listIterator()
void
setOrderProcessed(boolean processed)
Allow the creator to signify that the query order was processed when generating this QueryResultvoid
setRangeProcessed(boolean processed)
Allow the creator to signify that the query range was processed when generating this QueryResultprotected Object
writeReplace()
Handle serialisation by returning a java.util.ArrayList of all of the results for this query after disconnecting the query which has the consequence of enforcing the load of all objects.-
Methods inherited from class org.datanucleus.store.query.AbstractQueryResult
add, add, addAll, addConnectionListener, assertIsOpen, clear, disconnect, indexOf, isEmpty, isOpen, lastIndexOf, remove, set, size, subList, toArray, toArray
-
Methods inherited from class java.util.AbstractList
listIterator, removeRange
-
Methods inherited from class java.util.AbstractCollection
addAll, remove, removeAll, retainAll, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
addAll, remove, removeAll, replaceAll, retainAll, sort, spliterator
-
-
-
-
Field Detail
-
ec
protected org.datanucleus.ExecutionContext ec
-
candidateResults
protected List<org.datanucleus.store.mongodb.query.LazyLoadQueryResult.CandidateClassResult> candidateResults
Candidate results for this query that have not been (completely) processed yet.
-
currentCursorIterator
protected Iterator<com.mongodb.DBObject> currentCursorIterator
Iterator for the DBCursor that is being processed (if any).
-
-
Method Detail
-
addCandidateResult
public void addCandidateResult(org.datanucleus.metadata.AbstractClassMetaData cmd, com.mongodb.DBCursor cursor, int[] fpMembers)
-
setRangeProcessed
public void setRangeProcessed(boolean processed)
Allow the creator to signify that the query range was processed when generating this QueryResult- Parameters:
processed
- Whether the range was processed when the query was executed
-
getRangeProcessed
public boolean getRangeProcessed()
-
setOrderProcessed
public void setOrderProcessed(boolean processed)
Allow the creator to signify that the query order was processed when generating this QueryResult- Parameters:
processed
- Whether the order was processed when the query was executed
-
getOrderProcessed
public boolean getOrderProcessed()
-
closingConnection
protected void closingConnection()
- Specified by:
closingConnection
in classorg.datanucleus.store.query.AbstractQueryResult
-
close
public void close()
- Specified by:
close
in interfaceorg.datanucleus.store.query.QueryResult
- Overrides:
close
in classorg.datanucleus.store.query.AbstractQueryResult
-
closeResults
protected void closeResults()
- Specified by:
closeResults
in classorg.datanucleus.store.query.AbstractQueryResult
-
getSizeUsingMethod
protected int getSizeUsingMethod()
- Overrides:
getSizeUsingMethod
in classorg.datanucleus.store.query.AbstractQueryResult
-
get
public Object get(int index)
-
getNextObject
protected Object getNextObject()
Method to extract the next object from the candidateResults (if there is one). If a result is present, this puts it into "itemsByIndex". Returns null if no more results.- Returns:
- The next result (or null if no more).
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection
- Specified by:
contains
in interfaceList
- Overrides:
contains
in classorg.datanucleus.store.query.AbstractQueryResult
-
containsAll
public boolean containsAll(Collection c)
- Specified by:
containsAll
in interfaceCollection
- Specified by:
containsAll
in interfaceList
- Overrides:
containsAll
in classorg.datanucleus.store.query.AbstractQueryResult
-
iterator
public Iterator iterator()
-
listIterator
public ListIterator listIterator()
- Specified by:
listIterator
in interfaceList
- Specified by:
listIterator
in classorg.datanucleus.store.query.AbstractQueryResult
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceCollection
- Specified by:
equals
in interfaceList
- Specified by:
equals
in classorg.datanucleus.store.query.AbstractQueryResult
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection
- Specified by:
hashCode
in interfaceList
- Overrides:
hashCode
in classorg.datanucleus.store.query.AbstractQueryResult
-
writeReplace
protected Object writeReplace() throws ObjectStreamException
Handle serialisation by returning a java.util.ArrayList of all of the results for this query after disconnecting the query which has the consequence of enforcing the load of all objects.- Returns:
- The object to serialise
- Throws:
ObjectStreamException
- Throw if there is a problem in disconnect
-
-