public interface DB extends Iterable<Map.Entry<byte[],byte[]>>, Closeable
| Modifier and Type | Method and Description |
|---|---|
void |
compactRange(byte[] begin,
byte[] end)
Compact the underlying storage for the key range [begin, end].
|
WriteBatch |
createWriteBatch() |
void |
delete(byte[] key) |
Snapshot |
delete(byte[] key,
WriteOptions options)
Remove the database entry (if any) for "key".
|
byte[] |
get(byte[] key)
Same as calling
get(byte[], ReadOptions) with default options |
byte[] |
get(byte[] key,
ReadOptions options)
If the database contains an entry for "key" return its corresponding
value.
|
long[] |
getApproximateSizes(Range... ranges)
For each i in [0,n-1], store in "sizes[i]", the approximate
file system space used by keys in "[range[i].start ..
|
String |
getProperty(String name)
DB implementations can export properties about their state
via this method.
|
Snapshot |
getSnapshot()
Return a handle to the current DB state.
|
DBIterator |
iterator()
Same as calling
iterator(ReadOptions) with default options |
DBIterator |
iterator(ReadOptions options)
Return a iterator over the contents of the database.
|
void |
put(byte[] key,
byte[] value) |
Snapshot |
put(byte[] key,
byte[] value,
WriteOptions options)
Set the database entry for "key" to "value".
|
void |
resumeCompactions()
Resumes the background compaction threads.
|
void |
suspendCompactions()
Suspends any background compaction threads.
|
void |
write(WriteBatch updates) |
Snapshot |
write(WriteBatch updates,
WriteOptions options)
Apply the specified updates to the database.
|
forEach, spliteratorbyte[] get(byte[] key)
throws DBException
get(byte[], ReadOptions) with default optionsDBExceptionbyte[] get(byte[] key,
ReadOptions options)
throws DBException
If there is no entry for "key" return null.
key - key to search foroptions - read optionnullDBException - if error occurred in accessing db sateDBIterator iterator()
iterator(ReadOptions) with default optionsDBIterator iterator(ReadOptions options)
iterator(ReadOptions) will automatically position
itsel to first entry if seek method is not called.
It is preferable to call one of the Seek methods on the iterator before using it.
Caller should call DBIterator.close() when it is no longer needed.
The returned iterator should be closed before this db is deleted.
options - iterator read optionsvoid put(byte[] key,
byte[] value)
throws DBException
DBExceptionvoid delete(byte[] key)
throws DBException
DBExceptionvoid write(WriteBatch updates) throws DBException
DBExceptionWriteBatch createWriteBatch()
Snapshot put(byte[] key, byte[] value, WriteOptions options) throws DBException
Note: consider setting options.sync = true.
key - entry keyvalue - entry valyeDBException - on any write failureSnapshot delete(byte[] key, WriteOptions options) throws DBException
WriteOptions.snapshot()==false otherwise returns a snapshot
of the DB after this operation.DBException - on any write failure. It is not an error if "key"
did not exist in the database.Snapshot write(WriteBatch updates, WriteOptions options) throws DBException
Note: consider setting options.sync = true.
WriteOptions.snapshot()==false otherwise returns a snapshot
of the DB after this operation.DBException - on any write failureSnapshot getSnapshot()
Closeable.close() when the
snapshot is no longer needed.long[] getApproximateSizes(Range... ranges)
Note that the returned sizes measure file system space usage, so if the user data compresses by a factor of ten, the returned sizes will be one-tenth the size of the corresponding user data size.
The results may not include the sizes of recently written data.
ranges - each range to test forString getProperty(String name)
Valid property names include:
name - property namenull if property does not existvoid suspendCompactions()
throws InterruptedException
InterruptedExceptionvoid resumeCompactions()
void compactRange(byte[] begin,
byte[] end)
throws DBException
begin == null is treated as before all keys in the database.
end == null is treated as a key after all keys in the database.
Therefore the call to db.compactRange(null, null); will compact
the entire database.
begin - if null then compaction start from the first keyend - if null then compaction ends at the last keyDBExceptionCopyright © 2011–2020. All rights reserved.