Class ScrollableQueryResult<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
org.datanucleus.store.query.AbstractQueryResult<E>
org.datanucleus.store.rdbms.query.AbstractRDBMSQueryResult<E>
org.datanucleus.store.rdbms.query.ScrollableQueryResult<E>
- All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>, org.datanucleus.store.query.QueryResult<E>
public final class ScrollableQueryResult<E>
extends AbstractRDBMSQueryResult<E>
implements Serializable
Lazy collection results from a Query with the ResultSet scrollable.
Supports the following query extensions (in addition to those supported by superclasses) :-
- datanucleus.query.resultCacheType Type of caching of result objects. Supports strong, weak, soft, none
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classAn Iterator results of a pm.query.execute().iterator() -
Field Summary
FieldsModifier and TypeFieldDescription(package private) intPosition of last result (origin=0, set when known).Map of persistable object id, keyed by the result position (0, 1, 2, ...).Map of ResultSet object values, keyed by the list index ("0", "1", etc).(package private) intPosition of first result (origin=0).Fields inherited from class AbstractRDBMSQueryResult
applyRangeChecks, bulkLoadedMmds, bulkLoadedValueByMemberNumber, closeStatementWithResultSet, fp, rof, rsFields inherited from class org.datanucleus.store.query.AbstractQueryResult
api, closed, connectionListeners, loadResultsAtCommit, query, resultSizeMethod, sizeFields inherited from class AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionScrollableQueryResult(org.datanucleus.store.query.Query query, ResultObjectFactory<E> rof, ResultSet rs, org.datanucleus.FetchPlan fp, Collection candidates) Constructor of the result from a Query. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidvoidclose()Method to close the results, making the results unusable thereafter.protected voidInform the query result that the connection is being closed so perform any operations now, or rest in peace.booleanget(int index) Method to retrieve a particular element from the list.protected EgetObjectForIndex(int index) Accessor for the result object at an index.protected intMethod to get the size using the "resultSizeMethod".inthashCode()voiditerator()Accessor for an iterator for the results.Accessor for an iterator for the results.protected voidloadObjects(int start, int maxNumber) Convenience method to load up rows starting at the specified position.Object[]toArray()<T> T[]toArray(T[] a) private <T> T[]toArrayInternal(T[] a) protected ObjectHandle 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 AbstractRDBMSQueryResult
closeResults, disconnect, registerMemberBulkResultSet, setCloseStatementWithResultSetMethods inherited from class org.datanucleus.store.query.AbstractQueryResult
add, add, addAll, addConnectionListener, assertIsOpen, clear, contains, containsAll, indexOf, isEmpty, isOpen, lastIndexOf, remove, set, size, subListMethods inherited from class AbstractList
listIterator, removeRangeMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface List
addAll, addFirst, addLast, getFirst, getLast, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator
-
Field Details
-
resultsObjsByIndex
-
resultIdsByPosition
-
startIndex
int startIndexPosition of first result (origin=0). -
endIndex
int endIndexPosition of last result (origin=0, set when known).
-
-
Constructor Details
-
ScrollableQueryResult
public ScrollableQueryResult(org.datanucleus.store.query.Query query, ResultObjectFactory<E> rof, ResultSet rs, org.datanucleus.FetchPlan fp, Collection candidates) Constructor of the result from a Query.- Parameters:
query- The Queryrof- The factory to retrieve results fromrs- The ResultSet from the Query Statementfp- FetchPlancandidates- the Candidates collection. Pass this argument only when distinct = false
-
-
Method Details
-
initialise
public void initialise()- Specified by:
initialisein classAbstractRDBMSQueryResult<E>
-
loadObjects
protected void loadObjects(int start, int maxNumber) Convenience method to load up rows starting at the specified position. Optionally takes a maximum number of rows to process.- Parameters:
start- Start rowmaxNumber- Max number to process (-1 means no maximum)
-
getObjectForIndex
Accessor for the result object at an index. If the object has already been processed will return that object, otherwise will retrieve the object using the factory.- Parameters:
index- The list index position- Returns:
- The result object
-
close
public void close()Method to close the results, making the results unusable thereafter.- Specified by:
closein interfaceorg.datanucleus.store.query.QueryResult<E>- Overrides:
closein classAbstractRDBMSQueryResult<E>
-
closingConnection
protected void closingConnection()Inform the query result that the connection is being closed so perform any operations now, or rest in peace.- Specified by:
closingConnectionin classorg.datanucleus.store.query.AbstractQueryResult<E>
-
cacheQueryResults
protected void cacheQueryResults() -
iterator
Accessor for an iterator for the results. -
listIterator
Accessor for an iterator for the results.- Specified by:
listIteratorin interfaceList<E>- Specified by:
listIteratorin classorg.datanucleus.store.query.AbstractQueryResult<E>- Returns:
- The iterator
-
equals
- Specified by:
equalsin interfaceCollection<E>- Specified by:
equalsin interfaceList<E>- Overrides:
equalsin classAbstractRDBMSQueryResult<E>
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceList<E>- Overrides:
hashCodein classAbstractRDBMSQueryResult<E>
-
get
-
getSizeUsingMethod
protected int getSizeUsingMethod()Method to get the size using the "resultSizeMethod". This implementation supports "LAST" method. Override this in subclasses to implement other methods.- Overrides:
getSizeUsingMethodin classorg.datanucleus.store.query.AbstractQueryResult<E>- Returns:
- The size
-
toArray
-
toArray
-
toArrayInternal
private <T> T[] toArrayInternal(T[] a) -
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.- Returns:
- The object to serialise
- Throws:
ObjectStreamException- thrown if an error occurs
-