Skip to content

Commit

Permalink
Prefix search implementation
Browse files Browse the repository at this point in the history
Implement a solution to the issue described by google/leveldb#610
  • Loading branch information
pcmind committed Jul 29, 2019
1 parent 5055505 commit d2f928b
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 96 deletions.
12 changes: 12 additions & 0 deletions leveldb-api/src/main/java/org/iq80/leveldb/DB.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ byte[] get(byte[] key, ReadOptions options)
@Override
DBIterator iterator();

/**
* Return a iterator over contents of the database that with keys with {@code prefix}.
*
* @param options iterator read options
* @param prefix keys prefix
* @return new iterator over a view o the database.
*/
default DBIterator prefixIterator(ReadOptions options, byte[] prefix)
{
throw new UnsupportedOperationException();
}

/**
* Return a iterator over the contents of the database.
* The result of {@link DB#iterator(ReadOptions)} will automatically position
Expand Down
3 changes: 3 additions & 0 deletions leveldb-api/src/main/java/org/iq80/leveldb/DBIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public interface DBIterator
*/
void seekToLast();

/**
* Close resources associated to this iterator. Not closing it may lead to memory leak.
*/
@Override
void close();
}

0 comments on commit d2f928b

Please sign in to comment.