Package org.apache.cayenne.access
Class IncrementalFaultList<E>
java.lang.Object
org.apache.cayenne.access.IncrementalFaultList<E>
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,List<E>,SequencedCollection<E>
A synchronized list that serves as a container of Persistent objects. It is returned
when a paged query is performed by DataContext. On creation, only the first
"page" is fully resolved, for the rest of the objects only their ObjectIds
are read. Pages following the first page are resolved on demand only. On
access to an element, the list would ensure that this element as well as all
its siblings on the same page are fully resolved.
The list can hold DataRows or Persistent objects. Attempts to add any other object types will result in an exception.
Performance note: certain operations like toArray would trigger
full list fetch.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DataContextprotected final Listprotected final intStores a hint allowing to distinguish data rows from unfetched ids when the query fetches data rows.protected intDefines the upper limit on the size of fetches.protected final QueryMetadataprotected final intprotected final ObjEntityprotected int -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends E> c) booleanaddAll(Collection<? extends E> c) voidclear()booleanbooleancontainsAll(Collection<?> c) voidSets initial data (i.e.protected voidDeprecated, for removal: This API element is subject to removal in a future version.since 5.0, does nothingget(int index) Returns the dataContext.intGet the upper bound on the number of records to resolve in one round trip to the database.intReturns the pageSize.intReturns a total number of objects that are not resolved yet.intbooleanisEmpty()iterator()Return an iterator for this list.intReturns a list iterator for this list.listIterator(int index) Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.intpageIndex(int elementIndex) Returns zero-based index of the virtual "page" for a given array element index.remove(int index) booleanbooleanremoveAll(Collection<?> c) voidWill resolve all unread objects.protected voidresolveInterval(int fromIndex, int toIndex) Resolves a sublist of objects starting atfromIndexup to but not includingtoIndex.booleanretainAll(Collection<?> c) voidsetMaxFetchSize(int fetchSize) intsize()subList(int fromIndex, int toIndex) Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Field Details
-
pageSize
protected final int pageSize -
elements
-
dataContext
-
rootEntity
-
unfetchedObjects
protected volatile int unfetchedObjects -
idWidth
protected final int idWidthStores a hint allowing to distinguish data rows from unfetched ids when the query fetches data rows. -
metadata
-
maxFetchSize
protected int maxFetchSizeDefines the upper limit on the size of fetches. This is needed to avoid where clause size limitations.
-
-
Method Details
-
fillIn
@Deprecated(since="5.0", forRemoval=true) protected void fillIn(Query query, List<Object> elementsList) Deprecated, for removal: This API element is subject to removal in a future version.since 5.0, does nothingPerforms initialization of the list of objects. Only the first page is fully resolved. For the rest of the list, only ObjectIds are read.- Since:
- 3.0
-
fillIn
Sets initial data (i.e. list of ObjectIds) for this FaultList- Parameters:
elementsList- initial data to fill this list with- Since:
- 5.0
-
resolveAll
public void resolveAll()Will resolve all unread objects. -
resolveInterval
protected void resolveInterval(int fromIndex, int toIndex) Resolves a sublist of objects starting atfromIndexup to but not includingtoIndex. Internally performs bound checking and trims indexes accordingly. -
pageIndex
public int pageIndex(int elementIndex) Returns zero-based index of the virtual "page" for a given array element index. -
getMaxFetchSize
public int getMaxFetchSize()Get the upper bound on the number of records to resolve in one round trip to the database. This setting governs the size/complexity of the where clause generated to retrieve the next page of records. If the fetch size is less than the page size, then multiple fetches will be made to resolve a page. -
setMaxFetchSize
public void setMaxFetchSize(int fetchSize) -
getDataContext
Returns the dataContext.- Returns:
- DataContext
-
getPageSize
public int getPageSize()Returns the pageSize.- Returns:
- int
-
listIterator
Returns a list iterator for this list. Persistent objects are resolved a page (according to getPageSize()) at a time as necessary - when retrieved with next() or previous().- Specified by:
listIteratorin interfaceList<E>
-
listIterator
Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list. The specified index indicates the first element that would be returned by an initial call to the next method. An initial call to the previous method would return the element with the specified index minus one. Persistent objects are resolved a page at a time (according to getPageSize()) as necessary - when retrieved with next() or previous().- Specified by:
listIteratorin interfaceList<E>
-
iterator
Return an iterator for this list. Persistent objects are resolved a page (according to getPageSize()) at a time as necessary - when retrieved with next(). -
add
-
add
-
addAll
-
addAll
-
clear
public void clear() -
contains
-
containsAll
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>- See Also:
-
get
-
indexOf
-
isEmpty
public boolean isEmpty() -
lastIndexOf
- Specified by:
lastIndexOfin interfaceList<E>
-
remove
-
remove
-
removeAll
-
retainAll
-
set
-
size
public int size() -
subList
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
getUnfetchedObjects
public int getUnfetchedObjects()Returns a total number of objects that are not resolved yet.
-