leveldb-api:(5)DBIterator

DB迭代器:继承closeable接口

public interface DBIterator
        extends Iterator<Map.Entry<byte[], byte[]>>, Closeable
{
    /**
     * Repositions the iterator so the key of the next BlockElement
     * returned greater than or equal to the specified targetKey.
     */
    void seek(byte[] key);

    /**
     * Repositions the iterator so is is at the beginning of the Database.
     */
    void seekToFirst();

    /**
     * Returns the next element in the iteration, without advancing the iteration.
     */
    Map.Entry<byte[], byte[]> peekNext();

    /**
     * @return true if there is a previous entry in the iteration.
     */
    boolean hasPrev();

    /**
     * @return the previous element in the iteration and rewinds the iteration.
     */
    Map.Entry<byte[], byte[]> prev();

    /**
     * @return the previous element in the iteration, without rewinding the iteration.
     */
    Map.Entry<byte[], byte[]> peekPrev();

    /**
     * Repositions the iterator so it is at the end of of the Database.
     */
    void seekToLast();
}

SeekToFirst() - 定位到 leveldb 的第一个 key

SeekToLast() - 定位到 leveldb 的最后一个 key

Seek(target) - 定位到第一个大于等于 target 的 key

Next() - 定位到后一个 key,并且rewind迭代器

PeekNext() - 定位到后一个key,不rewind迭代器

Prev() - 定位到前一个 key,rewind迭代器

PeekPrev() - 定位到前一个 key,不rewind迭代器

hasPrev() - 判断迭代器的前一个entry是否存在

posted @ 2022-07-18 17:17  只能说运气有点好  阅读(76)  评论(0)    收藏  举报