Package org.datanucleus.store.query
Class CandidateIdsQueryResult<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- org.datanucleus.store.query.AbstractQueryResult<E>
-
- org.datanucleus.store.query.CandidateIdsQueryResult<E>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.List<E>
,QueryResult<E>
public class CandidateIdsQueryResult<E> extends AbstractQueryResult<E>
QueryResult taking in the list of identities of the objects of candidate type. This is used where we cached the results of a query (the "ids") and just want to materialise them. User can define the query extension "datanucleus.query.resultCache.type" to define the type of internal caching of objects once they are found. User can also define whether the returned objects are validated against the datastore upon retrieval using the query extension "datanucleus.query.resultCache.validateObjects" (default=true).- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CandidateIdsQueryResult.ResultIterator
Iterator for results for this query.
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.List<java.lang.Object>
ids
List of identities of the candidate objects.(package private) java.util.Map<java.lang.Integer,E>
results
(package private) boolean
validateObjects
Whether to validate the objects if getting from the cache.-
Fields inherited from class org.datanucleus.store.query.AbstractQueryResult
api, closed, connectionListeners, loadResultsAtCommit, query, resultSizeMethod, size
-
-
Constructor Summary
Constructors Constructor Description CandidateIdsQueryResult(Query query, java.util.List<java.lang.Object> inputIds)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeResults()
Inform the query result that we are closing the results now.protected void
closingConnection()
Inform the query result that the connection is being closed so perform any operations now, or rest in peace.boolean
equals(java.lang.Object o)
Equality operator for QueryResults.E
get(int index)
Method to retrieve a particular element from the list.protected E
getObjectForIndex(int index)
Convenience method to get the object for a particular index.int
hashCode()
Accessor for the hashcode of this objectjava.util.Iterator<E>
iterator()
Accessor for an iterator for the results.java.util.ListIterator<E>
listIterator()
Accessor for a list iterator for the results.protected java.lang.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, close, contains, containsAll, disconnect, getSizeUsingMethod, indexOf, isEmpty, isOpen, lastIndexOf, remove, set, size, subList, toArray, toArray
-
Methods inherited from class java.util.AbstractCollection
addAll, remove, removeAll, retainAll, toString
-
-
-
-
Field Detail
-
ids
final java.util.List<java.lang.Object> ids
List of identities of the candidate objects.
-
results
java.util.Map<java.lang.Integer,E> results
-
validateObjects
boolean validateObjects
Whether to validate the objects if getting from the cache.
-
-
Constructor Detail
-
CandidateIdsQueryResult
public CandidateIdsQueryResult(Query query, java.util.List<java.lang.Object> inputIds)
-
-
Method Detail
-
closeResults
protected void closeResults()
Description copied from class:AbstractQueryResult
Inform the query result that we are closing the results now.- Specified by:
closeResults
in classAbstractQueryResult<E>
-
closingConnection
protected void closingConnection()
Description copied from class:AbstractQueryResult
Inform the query result that the connection is being closed so perform any operations now, or rest in peace.- Specified by:
closingConnection
in classAbstractQueryResult<E>
-
equals
public boolean equals(java.lang.Object o)
Description copied from class:AbstractQueryResult
Equality operator for QueryResults. Overrides the AbstractList implementation since that uses size() and iterator() and that would cause problems when closed.- Specified by:
equals
in interfacejava.util.Collection<E>
- Specified by:
equals
in interfacejava.util.List<E>
- Specified by:
equals
in classAbstractQueryResult<E>
- Parameters:
o
- The object to compare against- Returns:
- Whether they are equal
-
hashCode
public int hashCode()
Description copied from class:AbstractQueryResult
Accessor for the hashcode of this object- Specified by:
hashCode
in interfacejava.util.Collection<E>
- Specified by:
hashCode
in interfacejava.util.List<E>
- Overrides:
hashCode
in classAbstractQueryResult<E>
- Returns:
- The hash code
-
get
public E get(int index)
Description copied from class:AbstractQueryResult
Method to retrieve a particular element from the list.- Specified by:
get
in interfacejava.util.List<E>
- Specified by:
get
in classAbstractQueryResult<E>
- Parameters:
index
- The index of the element- Returns:
- The element at index
-
iterator
public java.util.Iterator<E> iterator()
Description copied from class:AbstractQueryResult
Accessor for an iterator for the results.
-
listIterator
public java.util.ListIterator<E> listIterator()
Description copied from class:AbstractQueryResult
Accessor for a list iterator for the results.- Specified by:
listIterator
in interfacejava.util.List<E>
- Specified by:
listIterator
in classAbstractQueryResult<E>
- Returns:
- a ListIterator with the query results
-
getObjectForIndex
protected E getObjectForIndex(int index)
Convenience method to get the object for a particular index. Loads the object as required, or takes it from the internal cache (if present). Stores the returned object in the internal cache (if present).- Parameters:
index
- The index- Returns:
- The object
-
writeReplace
protected java.lang.Object writeReplace() throws java.io.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:
java.io.ObjectStreamException
- if an error occurs
-
-