Package wt.impact

Class WTValuedEntryChunkedIterator

All Implemented Interfaces:
AutoCloseable, Iterator<WTValuedMap.WTValuedEntry>

public class WTValuedEntryChunkedIterator extends AbstractWTEntryChunkedIterator<WTValuedMap.WTValuedEntry>
WTValuedMap entry set iterator that inflates and deflates key and value references in chunks. This iterator keeps memory usage low when iterating over large, deflated maps.

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 and value references are deflated if iteration terminates.

Examples:

 WTValuedMap wtMap;
     :
 // wtMap is created and populated with deflated key and value references
     :
 try (WTValuedEntryChunkedIterator entryIter = new WTValuedEntryChunkedIterator(wtMap, 1000)) {
     while ( entryIter.hasNext() ) {
         WTValuedEntry entry = entryIter.next();  // Key and value references are inflated.
             :
     }
 }
 // All key and value references in the map that were originally deflated will be 
 // automatically deflated when the try-with-resources block exits.
 // All key and value references in the map that were originally inflated will remain so.
     :
 
If a try-with-resources block is not used then close() should be called when the iterator is no longer needed:
 WTValuedMap wtMap;
     :
 // wtMap is created and populated with deflated key and value references
     :
 WTValuedEntryChunkedIterator entryIter = new WTValuedEntryChunkedIterator(wtMap, 1000);
 while ( entryIter.hasNext() ) {
     WTValuedEntry entry = entryIter.next();  // Key and value references are inflated.
         :
 }
 entryIter.close(); // Deflate key and value references.
     :
 


Supported API: true

Extendable: false
  • Constructor Details

    • WTValuedEntryChunkedIterator

      public WTValuedEntryChunkedIterator(WTValuedMap map, int chunkSize)
      Construct a new WTValuedEntryChunkedIterator for all map entries. Inflates key and value references in chunks to keep memory usage low.

      This iterator can only be used in the method server.

      Supported API: true

      Parameters:
      map - WTValuedMap with deflated key and value references.
      chunkSize - Number of entries that are inflated in a chunk.
    • WTValuedEntryChunkedIterator

      public WTValuedEntryChunkedIterator(WTValuedMap map, int chunkSize, Class<? extends Persistable> keyFilter)
      Construct a new WTValuedEntryChunkedIterator for map entries with filtered keys and all key sub-classes. Inflates key and value references in chunks to keep memory usage low.

      This iterator can only be used in the method server.

      Supported API: true

      Parameters:
      map - WTValuedMap with deflated key and value references.
      chunkSize - Number of entries that are inflated in a chunk.
      keyFilter - Key class filter.
    • WTValuedEntryChunkedIterator

      public WTValuedEntryChunkedIterator(WTValuedMap map, int chunkSize, Class<? extends Persistable> keyFilter, boolean includeSubclasses)
      Construct a new WTValuedEntryChunkedIterator for map entries with filtered keys. Inflates key and value references in chunks to keep memory usage low.

      This iterator can only be used in the method server.

      Supported API: true

      Parameters:
      map - WTValuedMap with deflated key and value 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.