Package one.microstream.collections.lazy
Interface LazyCollection<E>
- Type Parameters:
E- the type of elements in this collection
- All Superinterfaces:
Collection<E>,Iterable<E>
- All Known Implementing Classes:
LazyArrayList
public interface LazyCollection<E> extends Collection<E>
A
Collection, which uses Lazy references internally,
to enable automatic partial loading of the collection's content.-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classLazyCollection.Static -
Method Summary
Modifier and Type Method Description booleanconsolidate()Optimizes the internal structure of this lazy collection.<P extends Consumer<Lazy<?>>>
PiterateLazyReferences(P procedure)Iterates over all internally usedLazyreferences.default Stream<E>parallelStream()Returns a parallelStreamwith this collection as its source.default Stream<E>stream()Returns a sequentialStreamwith this collection as its source.voidtryUnload(boolean unloadAll)Tries to unload as much as possible elements from the collection.
-
Method Details
-
iterateLazyReferences
Iterates over all internally usedLazyreferences.- Type Parameters:
P- the procedure type- Parameters:
procedure- the lazy reference consumer- Returns:
- the given procedure
-
consolidate
boolean consolidate()Optimizes the internal structure of this lazy collection. Closes possible gaps and cleans up unused storage space.- Returns:
trueif the internal structure has changed,falseotherwise
-
tryUnload
void tryUnload(boolean unloadAll)Tries to unload as much as possible elements from the collection. The amount of unloaded data depends on the collection's implementation details. E.g if the collection is configured to keep a minimum of data in memory that minimum will not be unloaded as long as the parameter unloadAll is not specified. If unloadAll is set it will try to to fall below that limit.- Parameters:
unloadAll- if true try to unload everything, try to fall below limit if possible.
-
stream
Returns a sequentialStreamwith this collection as its source.This stream comes with a custom close handler, which clears all
Lazyreferences of this collection, which were not loaded before. So if you want to close allLazyreferences which were not loaded before theStreamwas created, just callBaseStream.close()afterwards.- Specified by:
streamin interfaceCollection<E>- Returns:
- a sequential
Streamover the elements in this collection
-
parallelStream
Returns a parallelStreamwith this collection as its source.This stream comes with a custom close handler, which clears all
Lazyreferences of this collection, which were not loaded before. So if you want to close allLazyreferences which were not loaded before theStreamwas created, just callBaseStream.close()afterwards.- Specified by:
parallelStreamin interfaceCollection<E>- Returns:
- a parallel
Streamover the elements in this collection
-