Class 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 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).
      • itemsByIndex

        protected Map<Integer,​Object> itemsByIndex
        Map of object, keyed by the index (0, 1, etc).
    • Constructor Detail

      • LazyLoadQueryResult

        public LazyLoadQueryResult​(org.datanucleus.store.query.Query q)
    • 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 class org.datanucleus.store.query.AbstractQueryResult
      • close

        public void close()
        Specified by:
        close in interface org.datanucleus.store.query.QueryResult
        Overrides:
        close in class org.datanucleus.store.query.AbstractQueryResult
      • closeResults

        protected void closeResults()
        Specified by:
        closeResults in class org.datanucleus.store.query.AbstractQueryResult
      • getSizeUsingMethod

        protected int getSizeUsingMethod()
        Overrides:
        getSizeUsingMethod in class org.datanucleus.store.query.AbstractQueryResult
      • get

        public Object get​(int index)
        Specified by:
        get in interface List
        Specified by:
        get in class org.datanucleus.store.query.AbstractQueryResult
      • 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 interface Collection
        Specified by:
        contains in interface List
        Overrides:
        contains in class org.datanucleus.store.query.AbstractQueryResult
      • containsAll

        public boolean containsAll​(Collection c)
        Specified by:
        containsAll in interface Collection
        Specified by:
        containsAll in interface List
        Overrides:
        containsAll in class org.datanucleus.store.query.AbstractQueryResult
      • listIterator

        public ListIterator listIterator()
        Specified by:
        listIterator in interface List
        Specified by:
        listIterator in class org.datanucleus.store.query.AbstractQueryResult
      • equals

        public boolean equals​(Object o)
        Specified by:
        equals in interface Collection
        Specified by:
        equals in interface List
        Specified by:
        equals in class org.datanucleus.store.query.AbstractQueryResult
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface Collection
        Specified by:
        hashCode in interface List
        Overrides:
        hashCode in class org.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