public class JdbmTable<K,V> extends AbstractTable<K,V>
| Modifier and Type | Field and Description |
|---|---|
private jdbm.btree.BTree<K,V> |
bt
the wrappedCursor JDBM btree used in this Table
|
private java.util.Map<java.lang.Long,jdbm.btree.BTree<K,V>> |
duplicateBtrees
a cache of duplicate BTrees
|
private jdbm.helper.Serializer |
keySerializer
A Key serializer
|
private static org.slf4j.Logger |
LOG
A logger for this class
|
(package private) Marshaller<ArrayTree<V>> |
marshaller
A marshaller used to serialize/deserialize values stored in the Table
|
private int |
numDupLimit
the limit at which we start using btree redirection for duplicates
|
private jdbm.RecordManager |
recMan
the JDBM record manager for the file this table is managed in
|
private static java.lang.String |
SZSUFFIX
the key to store and retreive the count information
|
private jdbm.helper.Serializer |
valueSerializer
A value serializer
|
allowsDuplicates, commitNumber, count, keyComparator, name, schemaManager, valueComparator| Constructor and Description |
|---|
JdbmTable(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
java.lang.String name,
int numDupLimit,
jdbm.RecordManager manager,
java.util.Comparator<K> keyComparator,
java.util.Comparator<V> valueComparator,
jdbm.helper.Serializer keySerializer,
jdbm.helper.Serializer valueSerializer)
Creates a Jdbm BTree based tuple Table abstraction that enables
duplicates.
|
JdbmTable(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
java.lang.String name,
jdbm.RecordManager manager,
java.util.Comparator<K> keyComparator,
jdbm.helper.Serializer keySerializer,
jdbm.helper.Serializer valueSerializer)
Creates a Jdbm BTree based tuple Table abstraction without duplicates
enabled using a simple key comparator.
|
| Modifier and Type | Method and Description |
|---|---|
private boolean |
btreeHas(jdbm.btree.BTree tree,
V key,
boolean isGreaterThan) |
void |
close()
Closes the underlying Db of this Table.
|
private void |
commit(jdbm.RecordManager recordManager)
Commit the modification on disk
|
private ArrayTree<V> |
convertToArrayTree(jdbm.btree.BTree bTree) |
private jdbm.btree.BTree<V,K> |
convertToBTree(ArrayTree<V> arrayTree) |
long |
count(K key)
Gets the count of the number of records in this Table with a specific
key: returns the number of duplicates for a key.
|
org.apache.directory.api.ldap.model.cursor.Cursor<org.apache.directory.api.ldap.model.cursor.Tuple<K,V>> |
cursor()
Creates a Cursor that traverses Tuples in a Table.
|
org.apache.directory.api.ldap.model.cursor.Cursor<org.apache.directory.api.ldap.model.cursor.Tuple<K,V>> |
cursor(K key)
Creates a Cursor that traverses Table Tuples for the same key.
|
V |
get(K key)
Gets the value of a record by key if the key exists.
|
(package private) jdbm.btree.BTree |
getBTree()
Returns the main BTree used by this table.
|
(package private) jdbm.btree.BTree |
getBTree(BTreeRedirect redirect) |
(package private) DupsContainer<V> |
getDupsContainer(byte[] serialized) |
jdbm.helper.Serializer |
getKeySerializer() |
Marshaller<ArrayTree<V>> |
getMarshaller() |
jdbm.helper.Serializer |
getValueSerializer() |
long |
greaterThanCount(K key)
Gets the number of records greater than or equal to a key value.
|
boolean |
has(K key)
Checks to see if this table has one or more tuples with a specific key:
this is exactly the same as a get call with a check to see if the
returned value is null or not.
|
boolean |
has(K key,
V value)
Checks to see if this table has a key with a specific value.
|
boolean |
hasGreaterOrEqual(K key)
Checks to see if this table has a record with a key greater than or
equal to the key argument.
|
boolean |
hasGreaterOrEqual(K key,
V val)
Checks to see if this table has a Tuple with a key equal to the key
argument, yet with a value greater than or equal to the value argument
provided.
|
boolean |
hasLessOrEqual(K key)
Checks to see if this table has a record with a key less than or
equal to the key argument.
|
boolean |
hasLessOrEqual(K key,
V val)
Checks to see if this table has a Tuple with a key equal to the key
argument, yet with a value less than or equal to the value argument
provided.
|
boolean |
isDupsEnabled()
Checks to see if this Table has allows for duplicate keys (a.k.a.
|
(package private) boolean |
isKeyUsingBTree(K key)
Added to check that we actually switch from one data structure to the
B+Tree structure on disk for duplicates that go beyond the threshold.
|
long |
lessThanCount(K key)
Gets the number of records less than or equal to a key value.
|
void |
put(K key,
V value)
Puts a record into this Table.
|
void |
remove(K key)
Removes all records with a specified key from this Table.
|
void |
remove(K key,
V value)
Removes a single key value pair with a specified key and value from
this Table.
|
void |
sync()
Synchronizes the buffers with disk.
|
org.apache.directory.api.ldap.model.cursor.Cursor<V> |
valueCursor(K key)
Creates a Cursor that traverses Table values for the same key.
|
count, getKeyComparator, getName, getValueComparator, toStringprivate static final org.slf4j.Logger LOG
private static final java.lang.String SZSUFFIX
private final jdbm.RecordManager recMan
private int numDupLimit
private final java.util.Map<java.lang.Long,jdbm.btree.BTree<K,V>> duplicateBtrees
private final jdbm.helper.Serializer keySerializer
private final jdbm.helper.Serializer valueSerializer
Marshaller<ArrayTree<V>> marshaller
public JdbmTable(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
java.lang.String name,
int numDupLimit,
jdbm.RecordManager manager,
java.util.Comparator<K> keyComparator,
java.util.Comparator<V> valueComparator,
jdbm.helper.Serializer keySerializer,
jdbm.helper.Serializer valueSerializer)
throws java.io.IOException
schemaManager - The server schemaManagername - the name of the tablenumDupLimit - the size limit of duplicates before switching to BTrees for values instead of AvlTreesmanager - the record manager to be used for this tablekeyComparator - a key comparatorvalueComparator - a value comparatorkeySerializer - a serializer to use for the keys instead of using
default Java serialization which could be very expensivevalueSerializer - a serializer to use for the values instead of
using default Java serialization which could be very expensivejava.io.IOException - if the table's file cannot be createdpublic JdbmTable(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
java.lang.String name,
jdbm.RecordManager manager,
java.util.Comparator<K> keyComparator,
jdbm.helper.Serializer keySerializer,
jdbm.helper.Serializer valueSerializer)
throws java.io.IOException
schemaManager - The server schemaManagername - the name of the tablemanager - the record manager to be used for this tablekeyComparator - a tuple comparatorkeySerializer - a serializer to use for the keys instead of using
default Java serialization which could be very expensivevalueSerializer - a serializer to use for the values instead of
using default Java serialization which could be very expensivejava.io.IOException - if the table's file cannot be createdpublic jdbm.helper.Serializer getKeySerializer()
public jdbm.helper.Serializer getValueSerializer()
public boolean isDupsEnabled()
TableTable.isDupsEnabled()public long greaterThanCount(K key) throws java.io.IOException
Tablekey - the key to use in comparisonsjava.io.IOExceptionTable#greaterThanCount(Object)public long lessThanCount(K key) throws java.io.IOException
Tablekey - the key to use in comparisonsjava.io.IOExceptionTable#lessThanCount(Object)public long count(K key) throws org.apache.directory.api.ldap.model.exception.LdapException
Tablekey - the Object key to count.org.apache.directory.api.ldap.model.exception.LdapExceptionTable.count(java.lang.Object)public V get(K key) throws org.apache.directory.api.ldap.model.exception.LdapException
Tablekey - the key of the recordorg.apache.directory.api.ldap.model.exception.LdapExceptionpublic boolean hasGreaterOrEqual(K key, V val) throws org.apache.directory.api.ldap.model.exception.LdapException
Tablekey - the keyval - the value to compare values toorg.apache.directory.api.ldap.model.exception.LdapExceptionTable#hasGreaterOrEqual(Object,Object)public boolean hasLessOrEqual(K key, V val) throws org.apache.directory.api.ldap.model.exception.LdapException
Tablekey - the keyval - the value to compare values toorg.apache.directory.api.ldap.model.exception.LdapExceptionTable#hasLessOrEqual(Object,Object)public boolean hasGreaterOrEqual(K key) throws java.io.IOException
Tablekey - the key to compare keys tojava.io.IOExceptionTable.hasGreaterOrEqual(Object)public boolean hasLessOrEqual(K key) throws java.io.IOException
Tablekey - the key to compare keys tojava.io.IOExceptionTable#hasLessOrEqual(Object)public boolean has(K key, V value) throws org.apache.directory.api.ldap.model.exception.LdapException
Tablekey - the key to check forvalue - the value to check fororg.apache.directory.api.ldap.model.exception.LdapExceptionTable.has(java.lang.Object,
java.lang.Object)public boolean has(K key) throws java.io.IOException
Tablekey - the Object of the key to check forjava.io.IOExceptionTable#has(java.lang.Object)public void put(K key, V value) throws java.lang.Exception
Tablekey - the key of the recordvalue - the value of the record.java.lang.Exception - if there is a failure to read or write to the
underlying Dbjava.lang.IllegalArgumentException - if a null key or value is usedTable.put(java.lang.Object,
java.lang.Object)public void remove(K key, V value) throws java.io.IOException
Tablekey - the key of the record to removevalue - the value of the record to removejava.io.IOExceptionTable.remove(java.lang.Object,
java.lang.Object)public void remove(K key)
Tablekey - the key of the records to removeTable#remove(Object)public org.apache.directory.api.ldap.model.cursor.Cursor<org.apache.directory.api.ldap.model.cursor.Tuple<K,V>> cursor() throws org.apache.directory.api.ldap.model.exception.LdapException
Tableorg.apache.directory.api.ldap.model.exception.LdapExceptionpublic org.apache.directory.api.ldap.model.cursor.Cursor<org.apache.directory.api.ldap.model.cursor.Tuple<K,V>> cursor(K key) throws java.lang.Exception
Tablekey - the duplicate key to return the Tuples ofjava.lang.Exception - if there are failures accessing underlying storespublic org.apache.directory.api.ldap.model.cursor.Cursor<V> valueCursor(K key) throws java.lang.Exception
Tablekey - the duplicate key to return the values ofjava.lang.Exception - if there are failures accessing underlying storespublic void close()
throws java.io.IOException
Tablejava.io.IOExceptionTable#close()public void sync()
throws java.io.IOException
java.io.IOException - if errors are encountered on the flushpublic Marshaller<ArrayTree<V>> getMarshaller()
boolean isKeyUsingBTree(K key) throws java.lang.Exception
java.lang.ExceptionDupsContainer<V> getDupsContainer(byte[] serialized) throws org.apache.directory.api.ldap.model.exception.LdapException
org.apache.directory.api.ldap.model.exception.LdapExceptionjdbm.btree.BTree getBTree()
jdbm.btree.BTree getBTree(BTreeRedirect redirect) throws java.io.IOException
java.io.IOExceptionprivate boolean btreeHas(jdbm.btree.BTree tree,
V key,
boolean isGreaterThan)
throws java.io.IOException
java.io.IOExceptionprivate ArrayTree<V> convertToArrayTree(jdbm.btree.BTree bTree) throws java.io.IOException
java.io.IOExceptionprivate jdbm.btree.BTree<V,K> convertToBTree(ArrayTree<V> arrayTree) throws java.lang.Exception
java.lang.Exceptionprivate void commit(jdbm.RecordManager recordManager)
throws java.io.IOException
recordManager - The recordManager used for the commitjava.io.IOException