org.apache.directory.server.core.partition.impl.btree
Interface Table

All Known Subinterfaces:
MasterTable
All Known Implementing Classes:
JdbmMasterTable, JdbmTable

public interface Table

A backend friendly wrapper around a JDBM BTree that transparent enables duplicates when the BTree does not support them. TODO Need to rewrite the Javadocs in this interface.

Version:
$Rev: 442053 $
Author:
Apache Directory Project

Method Summary
 void close()
          Closes the underlying Db of this Table.
 int count()
          Gets the count of the number of records in this Table.
 int count(java.lang.Object key)
          Gets the count of the number of records in this Table with a specific key: returns the number of duplicates for a key.
 int count(java.lang.Object key, boolean isGreaterThan)
          Returns the number of records greater than or less than a key value.
 java.lang.Object get(java.lang.Object key)
          Gets the value of a record by key if the key exists.
 TupleComparator getComparator()
          Gets the comparator used by this Table: may be null if this Table was not initialized with one.
 java.lang.String getName()
          Gets the name of this Table.
 TupleRenderer getRenderer()
          Gets the data renderer used by this Table to display or log records keys and values.
 boolean has(java.lang.Object key)
          Checks to see if this table has a key: same as a get call with a check to see if the returned value is null or not.
 boolean has(java.lang.Object key, boolean isGreaterThan)
          Checks to see if this table has a record with a key greater/less than or equal to the key argument.
 boolean has(java.lang.Object key, java.lang.Object value)
          Checks to see if this table has a key with a specific value.
 boolean has(java.lang.Object key, java.lang.Object val, boolean isGreaterThan)
          Checks to see if this table has a record with a key equal to the argument key with a value greater/less than or equal to the value argument provided.
 boolean isDupsEnabled()
          Checks to see if this Table has enabled the use of duplicate keys.
 boolean isSortedDupsEnabled()
          Checks to see if this Table has enabled sorting on the values of duplicate keys.
 javax.naming.NamingEnumeration listTuples()
          Sets a cursor to the first record in the Table and enables single next steps across all records.
 javax.naming.NamingEnumeration listTuples(java.lang.Object key)
          Sets a cursor to the first record in the Table with a key value of key and enables single next steps across all duplicate records with this key.
 javax.naming.NamingEnumeration listTuples(java.lang.Object key, boolean isGreaterThan)
          Sets a cursor to the first record in the Table with a key value greater/less than or equal to key and enables single next steps across all records with key values equal to or less/greater than key.
 javax.naming.NamingEnumeration listTuples(java.lang.Object key, java.lang.Object val, boolean isGreaterThan)
          Sets a cursor to the first record in the Table with a key equal to the key argument whose value is greater/less than or equal to val and enables single next steps across all records with key equal to key.
 javax.naming.NamingEnumeration listValues(java.lang.Object key)
          Sets a enumeration to the first record in the Table with a key value of key and enables single next steps across all duplicate records with this key.
 java.lang.Object put(java.lang.Object key, javax.naming.NamingEnumeration values)
          Efficiently puts a set of values into the Table.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Puts a record into this Table.
 java.lang.Object remove(java.lang.Object key)
          Removes all records with key from this Table.
 java.lang.Object remove(java.lang.Object key, javax.naming.NamingEnumeration values)
          Removes a set of values with the same key from this Table.
 java.lang.Object remove(java.lang.Object key, java.lang.Object value)
          Removes a single specific record with key and value from this Table.
 void setRenderer(TupleRenderer renderer)
          Sets the data renderer to by used by this Table to display or log record keys and values.
 

Method Detail

getComparator

TupleComparator getComparator()
Gets the comparator used by this Table: may be null if this Table was not initialized with one.

Returns:
the final comparator instance or null if this Table was not created with one.

getRenderer

TupleRenderer getRenderer()
Gets the data renderer used by this Table to display or log records keys and values.

Returns:
the renderer used

setRenderer

void setRenderer(TupleRenderer renderer)
Sets the data renderer to by used by this Table to display or log record keys and values.

Parameters:
renderer - the DataRenderer instance to used as the renderer.

getName

java.lang.String getName()
Gets the name of this Table.

Returns:
the name

isDupsEnabled

boolean isDupsEnabled()
Checks to see if this Table has enabled the use of duplicate keys.

Returns:
true if duplicate keys are enabled, false otherwise.

isSortedDupsEnabled

boolean isSortedDupsEnabled()
Checks to see if this Table has enabled sorting on the values of duplicate keys.

Returns:
true if duplicate key values are sorted, false otherwise.

has

boolean has(java.lang.Object key)
            throws javax.naming.NamingException
Checks to see if this table has a key: same as a get call with a check to see if the returned value is null or not.

Parameters:
key - the Object of the key to check for
Returns:
true if the key exists, false otherwise.
Throws:
javax.naming.NamingException - if there is a failure to read the underlying Db

has

boolean has(java.lang.Object key,
            java.lang.Object value)
            throws javax.naming.NamingException
Checks to see if this table has a key with a specific value.

Parameters:
key - the key Object to check for
value - the value Object to check for
Returns:
true if a record with the key and value exists, false otherwise.
Throws:
javax.naming.NamingException - if there is a failure to read the underlying Db

has

boolean has(java.lang.Object key,
            boolean isGreaterThan)
            throws javax.naming.NamingException
Checks to see if this table has a record with a key greater/less than or equal to the key argument. The key argument need not exist for this call to return true. The underlying database must be a BTree because this method depends on the use of sorted keys.

Parameters:
key - the key Object to compare keys to
isGreaterThan - boolean for greater than or less then comparison
Returns:
true if a record with a key greater/less than the key argument exists, false otherwise
Throws:
javax.naming.NamingException - if there is a failure to read the underlying Db, or if the underlying Db is not a Btree.

has

boolean has(java.lang.Object key,
            java.lang.Object val,
            boolean isGreaterThan)
            throws javax.naming.NamingException
Checks to see if this table has a record with a key equal to the argument key with a value greater/less than or equal to the value argument provided. The key argument MUST exist for this call to return true and the underlying Db must be a Btree that allows for sorted duplicate values. The entire basis to this method depends on the fact that duplicate key values are sorted according to a valid value comparator function. If the table does not support duplicates then an UnsupportedOperationException is thrown.

Parameters:
key - the key Object
val - the value Object to compare values to
isGreaterThan - boolean for greater than or less then comparison
Returns:
true if a record with a key greater/less than the key argument exists, false otherwise
Throws:
javax.naming.NamingException - if there is a failure to read the underlying Db or if the underlying Db is not of the Btree type that allows sorted duplicate values.

get

java.lang.Object get(java.lang.Object key)
                     throws javax.naming.NamingException
Gets the value of a record by key if the key exists. If this Table allows duplicate keys then the first key will be returned. If this Table is also a Btree that first key will be the smallest key in the Table as specificed by this Table's comparator or the default berkeley bytewise lexical comparator.

Parameters:
key - the key of the record
Returns:
the value of the record with key if key exists or null if no such record exists.
Throws:
javax.naming.NamingException - if there is a failure to read the underlying Db

put

java.lang.Object put(java.lang.Object key,
                     java.lang.Object value)
                     throws javax.naming.NamingException
Puts a record into this Table.

Parameters:
key - the key of the record
value - the value of the record.
Returns:
the last value present for key or null if this the key did not exist before.
Throws:
javax.naming.NamingException - if there is a failure to read or write to the underlying Db

put

java.lang.Object put(java.lang.Object key,
                     javax.naming.NamingEnumeration values)
                     throws javax.naming.NamingException
Efficiently puts a set of values into the Table. If the Table does not support duplicate keys then only the first key within the enumeration is added. If there are more elements left after this single addition an UnsupportedOperationException is thrown. Nothing is added if the table does not support duplicates and there is more than one element in the enumeration.

Parameters:
key - the key to use for the values
values - the values supplied as an enumeration
Throws:
javax.naming.NamingException - if something goes wrong

remove

java.lang.Object remove(java.lang.Object key)
                        throws javax.naming.NamingException
Removes all records with key from this Table.

Parameters:
key - the key of the records to remove
Throws:
javax.naming.NamingException - if there is a failure to read or write to the underlying Db

remove

java.lang.Object remove(java.lang.Object key,
                        java.lang.Object value)
                        throws javax.naming.NamingException
Removes a single specific record with key and value from this Table.

Parameters:
key - the key of the record to remove
value - the value of the record to remove
Throws:
javax.naming.NamingException - if there is a failure to read or write to the underlying Db

remove

java.lang.Object remove(java.lang.Object key,
                        javax.naming.NamingEnumeration values)
                        throws javax.naming.NamingException
Removes a set of values with the same key from this Table. If this table does not allow duplicates the method will attempt to remove the first value in the enumeration if one exists. If there is more than one value within the enumeration after the first drop an UnsupportedOperationException is thrown. Nothing is removed if there is more than one element on the enumeration and the table does not support duplicates.

Parameters:
key - the key of the records to remove
Returns:
the first value removed
Throws:
javax.naming.NamingException - if there is a failure to read or write to the underlying Db

listValues

javax.naming.NamingEnumeration listValues(java.lang.Object key)
                                          throws javax.naming.NamingException
Sets a enumeration to the first record in the Table with a key value of key and enables single next steps across all duplicate records with this key. This enumeration will only iterate over duplicates of the key. Unlike listTuples(Object) which returns Tuples from the enumerations advances methods this call returns an enumeration with just the values of the key.

Parameters:
key - the key to iterate over
Throws:
javax.naming.NamingException - if the underlying browser could not be set

listTuples

javax.naming.NamingEnumeration listTuples()
                                          throws javax.naming.NamingException
Sets a cursor to the first record in the Table and enables single next steps across all records.

Throws:
javax.naming.NamingException - if the underlying cursor could not be set.

listTuples

javax.naming.NamingEnumeration listTuples(java.lang.Object key)
                                          throws javax.naming.NamingException
Sets a cursor to the first record in the Table with a key value of key and enables single next steps across all duplicate records with this key. This cursor will only iterate over duplicates of the key.

Parameters:
key - the key to iterate over
Throws:
javax.naming.NamingException - if the underlying cursor could not be set

listTuples

javax.naming.NamingEnumeration listTuples(java.lang.Object key,
                                          boolean isGreaterThan)
                                          throws javax.naming.NamingException
Sets a cursor to the first record in the Table with a key value greater/less than or equal to key and enables single next steps across all records with key values equal to or less/greater than key.

Parameters:
key - the key to use to position this cursor to record with a key greater/less than or equal to it
isGreaterThan - if true the cursor iterates up over ascending keys greater than or equal to the key argument, but if false this cursor iterates down over descending keys less than or equal to key argument
Throws:
javax.naming.NamingException - if the underlying cursor could not be set

listTuples

javax.naming.NamingEnumeration listTuples(java.lang.Object key,
                                          java.lang.Object val,
                                          boolean isGreaterThan)
                                          throws javax.naming.NamingException
Sets a cursor to the first record in the Table with a key equal to the key argument whose value is greater/less than or equal to val and enables single next steps across all records with key equal to key. Hence this cursor will only iterate over duplicate keys where values are less than or greater than or equal to val. If the table does not support duplicates then an UnsupportedOperationException is thrown.

Parameters:
key - the key to use to position this cursor to record with a key equal to it.
val - the value to use to position this cursor to record with a value greater/less than or equal to it.
isGreaterThan - if true the cursor iterates up over ascending values greater than or equal to the val argument, but if false this cursor iterates down over descending values less than or equal to val argument starting from the largest value going down
Throws:
javax.naming.NamingException - if the underlying cursor could not be set or this method is called over a cursor on a table that does not have sorted duplicates enabled.

count

int count()
          throws javax.naming.NamingException
Gets the count of the number of records in this Table.

Returns:
the number of records
Throws:
javax.naming.NamingException - if there is a failure to read the underlying Db

count

int count(java.lang.Object key)
          throws javax.naming.NamingException
Gets the count of the number of records in this Table with a specific key: returns the number of duplicates for a key.

Parameters:
key - the Object key to count.
Returns:
the number of duplicate records for a key.
Throws:
javax.naming.NamingException - if there is a failure to read the underlying Db

count

int count(java.lang.Object key,
          boolean isGreaterThan)
          throws javax.naming.NamingException
Returns the number of records greater than or less than a key value. The key need not exist for this call to return a non-zero value.

Parameters:
key - the Object key to count.
isGreaterThan - boolean set to true to count for greater than and equal to record keys, or false for less than or equal to keys.
Returns:
the number of keys greater or less than key.
Throws:
javax.naming.NamingException - if there is a failure to read the underlying Db

close

void close()
           throws javax.naming.NamingException
Closes the underlying Db of this Table.

Throws:
javax.naming.NamingException - on any failures


Copyright © 2003-2010 Apache Software Foundation. All Rights Reserved.