Class DocIterator

java.lang.Object
org.zvec.binding.DocIterator
All Implemented Interfaces:
AutoCloseable

public class DocIterator extends Object implements AutoCloseable
A snapshot document iterator over a collection (zvec ≥ v0.7.0), created via Collection.createIterator(IteratorOptions).

The iterator takes an isolated snapshot at creation time. Always close() the iterator before releasing the last handle of its collection; while an iterator is open, schema changes and destroy on the collection return an error.

Typical usage:


 try (DocIterator it = collection.createIterator(null)) {
     Doc doc;
     while ((doc = it.next()) != null) {
         try {
             // ... read doc ...
         } finally {
             doc.close();
         }
     }
 }
 
  • Method Details

    • next

      public Doc next()
      Advance the iterator and return the next document, or null when the end of the snapshot is reached (EOF). The returned Doc is owned by the caller; release it with Doc.close() when done.
    • close

      public void close()
      Close the iterator and release all its resources. Idempotent.
      Specified by:
      close in interface AutoCloseable