K
- The Key typeV
- The Value typepublic interface BTree<K,V>
Modifier and Type | Field and Description |
---|---|
static boolean |
ALLOW_DUPLICATES
The B-tree allows duplicate values
|
static int |
DEFAULT_PAGE_SIZE
Default page size (number of entries per node)
|
static long |
DEFAULT_READ_TIMEOUT
Define a default delay for a read transaction.
|
static int |
DEFAULT_WRITE_BUFFER_SIZE
Default size of the buffer used to write data on disk.
|
static boolean |
FORBID_DUPLICATES
The B-tree forbids duplicate values
|
Modifier and Type | Method and Description |
---|---|
TupleCursor<K,V> |
browse()
Creates a cursor starting at the beginning of the tree
|
TupleCursor<K,V> |
browse(long revision)
Creates a cursor starting at the beginning of the tree, for a given revision
|
TupleCursor<K,V> |
browseFrom(K key)
Creates a cursor starting on the given key
|
TupleCursor<K,V> |
browseFrom(long revision,
K key)
Creates a cursor starting on the given key at the given revision
|
KeyCursor<K> |
browseKeys()
Creates a cursor starting at the beginning of the tree
|
void |
close()
Close the B-tree, cleaning up all the data structure
|
boolean |
contains(K key,
V value)
Checks if the B-tree contains the given key with the given value.
|
boolean |
contains(long revision,
K key,
V value)
Checks if the B-tree contains the given key with the given value for a given revision
|
Tuple<K,V> |
delete(K key)
Delete the entry which key is given as a parameter.
|
Tuple<K,V> |
delete(K key,
V value)
Delete the value from an entry associated with the given key.
|
void |
flush()
Flush the latest revision to disk.
|
V |
get(K key)
Find a value in the tree, given its key.
|
V |
get(long revision,
K key)
Find a value in the tree, given its key, at a specific revision.
|
Comparator<K> |
getKeyComparator() |
ElementSerializer<K> |
getKeySerializer() |
String |
getKeySerializerFQCN() |
String |
getName() |
long |
getNbElems() |
int |
getPageSize() |
long |
getReadTimeOut() |
long |
getRevision() |
org.apache.directory.mavibot.btree.Page<K,V> |
getRootPage()
Get the current rootPage
|
org.apache.directory.mavibot.btree.Page<K,V> |
getRootPage(long revision)
Get the rootPage associated to a given revision.
|
BTreeTypeEnum |
getType() |
Comparator<V> |
getValueComparator() |
ValueCursor<V> |
getValues(K key) |
ElementSerializer<V> |
getValueSerializer() |
String |
getValueSerializerFQCN() |
int |
getWriteBufferSize() |
boolean |
hasKey(K key)
Checks if the given key exists.
|
boolean |
hasKey(long revision,
K key)
Checks if the given key exists for a given revision.
|
V |
insert(K key,
V value)
Insert an entry in the B-tree.
|
boolean |
isAllowDuplicates() |
void |
setAllowDuplicates(boolean allowDuplicates) |
void |
setKeySerializer(ElementSerializer<K> keySerializer) |
void |
setName(String name) |
void |
setPageSize(int pageSize)
Set the maximum number of elements we can store in a page.
|
void |
setReadTimeOut(long readTimeOut) |
void |
setValueSerializer(ElementSerializer<V> valueSerializer) |
void |
setWriteBufferSize(int writeBufferSize) |
static final int DEFAULT_PAGE_SIZE
static final int DEFAULT_WRITE_BUFFER_SIZE
static final long DEFAULT_READ_TIMEOUT
static final boolean ALLOW_DUPLICATES
static final boolean FORBID_DUPLICATES
void close() throws IOException
IOException
void setPageSize(int pageSize)
pageSize
- The requested page sizeint getPageSize()
V insert(K key, V value) throws IOException
We will replace the value if the provided key already exists in the B-tree.
key
- Inserted keyvalue
- Inserted valueIOException
- TODOTuple<K,V> delete(K key) throws IOException
key
- The key for the entry we try to removeIOException
Tuple<K,V> delete(K key, V value) throws IOException
key
- The key for the entry we try to removevalue
- The value to delete (can be null)IOException
V get(K key) throws IOException, KeyNotFoundException
key
- The key we are looking atKeyNotFoundException
- If the key is not found in the B-treeIOException
- TODOorg.apache.directory.mavibot.btree.Page<K,V> getRootPage(long revision) throws IOException, KeyNotFoundException
revision
- The revision we are looking forIOException
- If we had an issue while accessing the underlying fileKeyNotFoundException
- If the revision does not exist for this B-treeorg.apache.directory.mavibot.btree.Page<K,V> getRootPage()
ValueCursor<V> getValues(K key) throws IOException, KeyNotFoundException
IOException
KeyNotFoundException
Page.getValues(Object)
V get(long revision, K key) throws IOException, KeyNotFoundException
revision
- The revision for which we want to find a keykey
- The key we are looking atKeyNotFoundException
- If the key is not found in the B-treeIOException
- If there was an issue while fetching data from the diskboolean hasKey(K key) throws IOException, KeyNotFoundException
key
- The key we are looking atIOException
- If we have an error while trying to access the pageKeyNotFoundException
- If the key is not found in the B-treeboolean hasKey(long revision, K key) throws IOException, KeyNotFoundException
revision
- The revision for which we want to find a keykey
- The key we are looking atIOException
- If we have an error while trying to access the pageKeyNotFoundException
- If the key is not found in the B-treeboolean contains(K key, V value) throws IOException
key
- The key we are looking forvalue
- The value associated with the given keyIOException
boolean contains(long revision, K key, V value) throws IOException, KeyNotFoundException
revision
- The revision we would like to browsekey
- The key we are looking forvalue
- The value associated with the given keyKeyNotFoundException
- If the key is not found in the B-treeIOException
TupleCursor<K,V> browse() throws IOException, KeyNotFoundException
IOException
KeyNotFoundException
TupleCursor<K,V> browse(long revision) throws IOException, KeyNotFoundException
revision
- The revision we would like to browseIOException
- If we had an issue while fetching data from the diskKeyNotFoundException
- If the key is not found in the B-treeTupleCursor<K,V> browseFrom(K key) throws IOException
key
- The key which is the starting point. If the key is not found,
then the cursor will always return null.IOException
TupleCursor<K,V> browseFrom(long revision, K key) throws IOException, KeyNotFoundException
The
- revision we are looking forkey
- The key which is the starting point. If the key is not found,
then the cursor will always return null.IOException
- If wxe had an issue reading the B-tree from diskKeyNotFoundException
- If we can't find a rootPage for this revisionKeyCursor<K> browseKeys() throws IOException, KeyNotFoundException
IOException
KeyNotFoundException
Comparator<K> getKeyComparator()
Comparator<V> getValueComparator()
void setKeySerializer(ElementSerializer<K> keySerializer)
keySerializer
- the Key serializer to setvoid setValueSerializer(ElementSerializer<V> valueSerializer)
valueSerializer
- the Value serializer to setvoid flush() throws IOException
IOException
long getReadTimeOut()
void setReadTimeOut(long readTimeOut)
readTimeOut
- the readTimeOut to setint getWriteBufferSize()
void setWriteBufferSize(int writeBufferSize)
writeBufferSize
- the writeBufferSize to setElementSerializer<K> getKeySerializer()
String getKeySerializerFQCN()
ElementSerializer<V> getValueSerializer()
String getValueSerializerFQCN()
long getRevision()
long getNbElems()
boolean isAllowDuplicates()
void setAllowDuplicates(boolean allowDuplicates)
allowDuplicates
- True if the B-tree will allow duplicate valuesBTreeTypeEnum getType()
Copyright © 2012–2015 Apache Mavibot Project Parent. All rights reserved.