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 class
LazyCollection.Static
-
Method Summary
Modifier and Type Method Description boolean
consolidate()
Optimizes the internal structure of this lazy collection.<P extends Consumer<Lazy<?>>>
PiterateLazyReferences(P procedure)
Iterates over all internally usedLazy
references.default Stream<E>
parallelStream()
Returns a parallelStream
with this collection as its source.default Stream<E>
stream()
Returns a sequentialStream
with this collection as its source.void
tryUnload(boolean unloadAll)
Tries to unload as much as possible elements from the collection.
-
Method Details
-
iterateLazyReferences
Iterates over all internally usedLazy
references.- 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:
true
if the internal structure has changed,false
otherwise
-
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 sequentialStream
with this collection as its source.This stream comes with a custom close handler, which clears all
Lazy
references of this collection, which were not loaded before. So if you want to close allLazy
references which were not loaded before theStream
was created, just callBaseStream.close()
afterwards.- Specified by:
stream
in interfaceCollection<E>
- Returns:
- a sequential
Stream
over the elements in this collection
-
parallelStream
Returns a parallelStream
with this collection as its source.This stream comes with a custom close handler, which clears all
Lazy
references of this collection, which were not loaded before. So if you want to close allLazy
references which were not loaded before theStream
was created, just callBaseStream.close()
afterwards.- Specified by:
parallelStream
in interfaceCollection<E>
- Returns:
- a parallel
Stream
over the elements in this collection
-