Package wt.impact
Class WTEntryChunkedIterator
- All Implemented Interfaces:
AutoCloseable,Iterator<WTKeyedMap.WTEntry>
WTKeyedMap entry set iterator that inflates and deflates key references in chunks.
This iterator keeps memory usage low when iterating over large, deflated maps.
Supported API: true
Extendable: false
This iterator can only be used in the method server.
It is recommended that this iterator be used as resource in a try-with-resources block to ensure that inflated key references are deflated if iteration terminates.
Examples:
WTKeyedMap wtMap;
:
// wtMap is created and populated with deflated key references
:
try (WTEntryChunkedIterator entryIter = new WTEntryChunkedIterator(wtMap, 1000)) {
while ( entryIter.hasNext() ) {
WTEntry entry = entryIter.next(); // Key references are inflated.
:
}
}
// All key references in the map that were originally deflated will be
// automatically deflated when the try-with-resources block exits.
// All key references in the map that were originally inflated will remain so.
:
If a try-with-resources block is not used then AbstractWTEntryChunkedIterator.close() should be called
when the iterator is no longer needed:
WTKeyedMap wtMap;
:
// wtMap is created and populated with deflated key references
:
WTEntryChunkedIterator entryIter = new WTEntryChunkedIterator(wtMap, 1000);
while ( entryIter.hasNext() ) {
WTEntry entry = entryIter.next(); // Key references are inflated.
:
}
entryIter.close(); // Deflate key references.
:
Supported API: true
Extendable: false
-
Field Summary
Fields inherited from class wt.impact.AbstractWTEntryChunkedIterator
chunkSize, entrySetIter, includeSubclasses, inflatedChunk, inflatedChunkIter, keyFilter, keyRefsToDeflate, refreshSpec -
Constructor Summary
ConstructorsConstructorDescriptionWTEntryChunkedIterator(WTKeyedMap map, int chunkSize) Construct a new WTEntryChunkedIterator for all map entries.WTEntryChunkedIterator(WTKeyedMap map, int chunkSize, Class<? extends Persistable> keyFilter) Construct a new WTEntryChunkedIterator for map entries with filtered keys and all key sub-classes.WTEntryChunkedIterator(WTKeyedMap map, int chunkSize, Class<? extends Persistable> keyFilter, boolean includeSubclasses) Construct a new WTEntryChunkedIterator for map entries with filtered keys. -
Method Summary
Methods inherited from class wt.impact.AbstractWTEntryChunkedIterator
close, finalize, hasNext, inflate, inflateValueReferences, loadChunk, next, processValueReference, remove, setRefreshSpecMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
WTEntryChunkedIterator
Construct a new WTEntryChunkedIterator for all map entries. Inflates key references in chunks to keep memory usage low.This iterator can only be used in the method server.
Supported API: true- Parameters:
map- WTKeyedMap with deflated key references.chunkSize- Number of entries that are inflated in a chunk.
-
WTEntryChunkedIterator
public WTEntryChunkedIterator(WTKeyedMap map, int chunkSize, Class<? extends Persistable> keyFilter) Construct a new WTEntryChunkedIterator for map entries with filtered keys and all key sub-classes. Inflates key references in chunks to keep memory usage low.This iterator can only be used in the method server.
Supported API: true- Parameters:
map- WTKeyedMap with deflated key references.chunkSize- Number of entries that are inflated in a chunk.keyFilter- Key class filter.
-
WTEntryChunkedIterator
public WTEntryChunkedIterator(WTKeyedMap map, int chunkSize, Class<? extends Persistable> keyFilter, boolean includeSubclasses) Construct a new WTEntryChunkedIterator for map entries with filtered keys. Inflates key references in chunks to keep memory usage low.This iterator can only be used in the method server.
Supported API: true- Parameters:
map- WTKeyedMap with deflated key references.chunkSize- Number of entries that are inflated in a chunk.keyFilter- Key class filter.includeSubclasses- True to iterated over the key filter objects and all of its sub-classes, or false to iterated over only the key filter objects.
-