K
- The Key typeV
- The Value typepublic interface BTree<K,V>
Modifier and Type | Field and Description |
---|---|
static boolean |
ALLOW_DUPLICATES
The BTree 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 BTree forbids duplicate values
|
Modifier and Type | Method and Description |
---|---|
void |
beginTransaction()
Starts a transaction
|
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
|
void |
close()
Close the BTree, cleaning up all the data structure
|
void |
commit()
Commits a transaction
|
boolean |
contains(K key,
V value)
Checks if the BTree contains the given key with the given value.
|
boolean |
contains(long revision,
K key,
V value)
Checks if the BTree 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> |
getComparator() |
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() |
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.
|
void |
init()
Initialize the BTree.
|
V |
insert(K key,
V value)
Insert an entry in the BTree.
|
boolean |
isAllowDuplicates() |
void |
rollback()
Rollback a transaction
|
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 init() throws IOException
IOException
- If we get some exception while initializing the BTreevoid 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 btree.
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 BTreeIOException
- 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 Btreeorg.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 BTreeIOException
- If there was an issue while fetching data from the diskboolean hasKey(K key) throws IOException
key
- The key we are looking atIOException
- If we have an error while trying to access the pageboolean 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 BTreeboolean 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 BTreeIOException
TupleCursor<K,V> browse() throws IOException
IOException
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 BTreeTupleCursor<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 BTree from diskKeyNotFoundException
- If we can't find a rootPage for this revisionComparator<K> getComparator()
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 setString getName()
void setName(String name)
name
- the name 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 BTree will allow duplicate valuesBTreeTypeEnum getType()
void beginTransaction()
void commit()
void rollback()
Copyright © 2012-2014 Apache Mavibot Project Parent. All Rights Reserved.