Class LeveldbIterator

java.lang.Object
org.apache.hadoop.yarn.server.utils.LeveldbIterator
All Implemented Interfaces:
Closeable, AutoCloseable, Iterator<Map.Entry<byte[],byte[]>>

@Public @Evolving public class LeveldbIterator extends Object implements Iterator<Map.Entry<byte[],byte[]>>, Closeable
A wrapper for a DBIterator to translate the raw RuntimeExceptions that can be thrown into DBExceptions.
  • Constructor Summary

    Constructors
    Constructor
    Description
    LeveldbIterator(org.iq80.leveldb.DB db)
    Create an iterator for the specified database.
    LeveldbIterator(org.iq80.leveldb.DBIterator iter)
    Create an iterator using the specified underlying DBIterator.
    LeveldbIterator(org.iq80.leveldb.DB db, org.iq80.leveldb.ReadOptions options)
    Create an iterator for the specified database.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the iterator.
    boolean
    Returns true if the iteration has more elements.
    boolean
     
    Map.Entry<byte[],byte[]>
    Returns the next element in the iteration.
    Map.Entry<byte[],byte[]>
    Returns the next element in the iteration, without advancing the iteration.
    Map.Entry<byte[],byte[]>
     
    Map.Entry<byte[],byte[]>
     
    void
    Removes from the database the last element returned by the iterator.
    void
    seek(byte[] key)
    Repositions the iterator so the key of the next BlockElement returned greater than or equal to the specified targetKey.
    void
    Repositions the iterator so is is at the beginning of the Database.
    void
    Repositions the iterator so it is at the end of of the Database.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.Iterator

    forEachRemaining
  • Constructor Details

    • LeveldbIterator

      public LeveldbIterator(org.iq80.leveldb.DB db)
      Create an iterator for the specified database.
      Parameters:
      db - database.
    • LeveldbIterator

      public LeveldbIterator(org.iq80.leveldb.DB db, org.iq80.leveldb.ReadOptions options)
      Create an iterator for the specified database.
      Parameters:
      db - db.
      options - ReadOptions.
    • LeveldbIterator

      public LeveldbIterator(org.iq80.leveldb.DBIterator iter)
      Create an iterator using the specified underlying DBIterator.
      Parameters:
      iter - DB Iterator.
  • Method Details

    • seek

      public void seek(byte[] key) throws org.iq80.leveldb.DBException
      Repositions the iterator so the key of the next BlockElement returned greater than or equal to the specified targetKey.
      Parameters:
      key - key of the next BlockElement.
      Throws:
      org.iq80.leveldb.DBException - db Exception.
    • seekToFirst

      public void seekToFirst() throws org.iq80.leveldb.DBException
      Repositions the iterator so is is at the beginning of the Database.
      Throws:
      org.iq80.leveldb.DBException
    • seekToLast

      public void seekToLast() throws org.iq80.leveldb.DBException
      Repositions the iterator so it is at the end of of the Database.
      Throws:
      org.iq80.leveldb.DBException
    • hasNext

      public boolean hasNext() throws org.iq80.leveldb.DBException
      Returns true if the iteration has more elements.
      Specified by:
      hasNext in interface Iterator<Map.Entry<byte[],byte[]>>
      Throws:
      org.iq80.leveldb.DBException
    • next

      public Map.Entry<byte[],byte[]> next() throws org.iq80.leveldb.DBException
      Returns the next element in the iteration.
      Specified by:
      next in interface Iterator<Map.Entry<byte[],byte[]>>
      Returns:
      the next element in the iteration.
      Throws:
      org.iq80.leveldb.DBException - DB Exception.
    • peekNext

      public Map.Entry<byte[],byte[]> peekNext() throws org.iq80.leveldb.DBException
      Returns the next element in the iteration, without advancing the iteration.
      Returns:
      the next element in the iteration.
      Throws:
      org.iq80.leveldb.DBException - db Exception.
    • hasPrev

      public boolean hasPrev() throws org.iq80.leveldb.DBException
      Returns:
      true if there is a previous entry in the iteration.
      Throws:
      org.iq80.leveldb.DBException
    • prev

      public Map.Entry<byte[],byte[]> prev() throws org.iq80.leveldb.DBException
      Returns:
      the previous element in the iteration and rewinds the iteration.
      Throws:
      org.iq80.leveldb.DBException
    • peekPrev

      public Map.Entry<byte[],byte[]> peekPrev() throws org.iq80.leveldb.DBException
      Returns:
      the previous element in the iteration, without rewinding the iteration.
      Throws:
      org.iq80.leveldb.DBException
    • remove

      public void remove() throws org.iq80.leveldb.DBException
      Removes from the database the last element returned by the iterator.
      Specified by:
      remove in interface Iterator<Map.Entry<byte[],byte[]>>
      Throws:
      org.iq80.leveldb.DBException
    • close

      public void close() throws IOException
      Closes the iterator.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException