org.apache.directory.server.core.partition.impl.btree.jdbm
Class JdbmIndex

java.lang.Object
  extended by org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex
All Implemented Interfaces:
Index

public class JdbmIndex
extends java.lang.Object
implements Index

A Jdbm based index implementation.

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

Field Summary
static java.lang.String FORWARD_BTREE
           
static java.lang.String REVERSE_BTREE
           
 
Constructor Summary
JdbmIndex(org.apache.directory.shared.ldap.schema.AttributeType attribute, java.io.File wkDirPath, int cacheSize, int numDupLimit)
          Creates an Index using an existing record manager based on a file.
 
Method Summary
 void add(javax.naming.directory.Attribute attr, java.math.BigInteger id)
           
 void add(javax.naming.directory.Attributes attrs, java.math.BigInteger id)
           
 void add(java.lang.Object attrVal, java.math.BigInteger id)
           
 void close()
           
 int count()
          Gets the total scan count for this index.
 int count(java.lang.Object attrVal)
          Gets the scan count for the occurance of a specific attribute value within the index.
 int count(java.lang.Object attrVal, boolean isGreaterThan)
           
 void drop(javax.naming.directory.Attribute attr, java.math.BigInteger id)
          If the Attribute does not have any values then this reduces to a drop(BigInteger) call.
 void drop(javax.naming.directory.Attributes attrs, java.math.BigInteger id)
          If the Attribute for this index within the Attributes does not have any values then this reduces to a drop(BigInteger) call.
 void drop(java.math.BigInteger entryId)
           
 void drop(java.lang.Object attrVal, java.math.BigInteger id)
           
 java.math.BigInteger forwardLookup(java.lang.Object attrVal)
           
 org.apache.directory.shared.ldap.schema.AttributeType getAttribute()
          Gets the attribute this Index is built upon.
 java.lang.Object getNormalized(java.lang.Object attrVal)
          TODO I don't think the keyCache is required anymore since the normalizer will cache values for us.
 boolean hasValue(java.lang.Object attrVal, java.math.BigInteger id)
           
 boolean hasValue(java.lang.Object attrVal, java.math.BigInteger id, boolean isGreaterThan)
           
 boolean hasValue(java.util.regex.Pattern regex, java.math.BigInteger id)
           
 IndexEnumeration listIndices()
           
 IndexEnumeration listIndices(java.lang.Object attrVal)
           
 IndexEnumeration listIndices(java.lang.Object attrVal, boolean isGreaterThan)
           
 IndexEnumeration listIndices(java.util.regex.Pattern regex)
           
 IndexEnumeration listIndices(java.util.regex.Pattern regex, java.lang.String prefix)
           
 IndexEnumeration listReverseIndices(java.math.BigInteger id)
           
 java.lang.Object reverseLookup(java.math.BigInteger id)
           
 void sync()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORWARD_BTREE

public static final java.lang.String FORWARD_BTREE
See Also:
Constant Field Values

REVERSE_BTREE

public static final java.lang.String REVERSE_BTREE
See Also:
Constant Field Values
Constructor Detail

JdbmIndex

public JdbmIndex(org.apache.directory.shared.ldap.schema.AttributeType attribute,
                 java.io.File wkDirPath,
                 int cacheSize,
                 int numDupLimit)
          throws javax.naming.NamingException
Creates an Index using an existing record manager based on a file. The index table B+Tree are created and saved within this file rather than creating a new file.

Parameters:
attribute - the attribute specification to base this index on
recMan - the record manager
Throws:
javax.naming.NamingException - if we fail to create B+Trees using recMan
Method Detail

getAttribute

public org.apache.directory.shared.ldap.schema.AttributeType getAttribute()
Description copied from interface: Index
Gets the attribute this Index is built upon.

Specified by:
getAttribute in interface Index
Returns:
the id of the Index's attribute
See Also:
Index.getAttribute()

count

public int count()
          throws javax.naming.NamingException
Description copied from interface: Index
Gets the total scan count for this index.

Specified by:
count in interface Index
Returns:
the number of key/value pairs in this index
Throws:
javax.naming.NamingException - if their is a failure accessing the index
See Also:
Index.count()

count

public int count(java.lang.Object attrVal)
          throws javax.naming.NamingException
Description copied from interface: Index
Gets the scan count for the occurance of a specific attribute value within the index.

Specified by:
count in interface Index
Parameters:
attrVal - the value of the attribute to get a scan count for
Returns:
the number of key/value pairs in this index with the value value
Throws:
javax.naming.NamingException - if their is a failure accessing the index
See Also:
Index.count(java.lang.Object)

count

public int count(java.lang.Object attrVal,
                 boolean isGreaterThan)
          throws javax.naming.NamingException
Specified by:
count in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.count(java.lang.Object, boolean)

forwardLookup

public java.math.BigInteger forwardLookup(java.lang.Object attrVal)
                                   throws javax.naming.NamingException
Specified by:
forwardLookup in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.forwardLookup(java.lang.Object)

reverseLookup

public java.lang.Object reverseLookup(java.math.BigInteger id)
                               throws javax.naming.NamingException
Specified by:
reverseLookup in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.reverseLookup(java.math.BigInteger)

add

public void add(java.lang.Object attrVal,
                java.math.BigInteger id)
         throws javax.naming.NamingException
Specified by:
add in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.add(java.lang.Object, java.math.BigInteger)

add

public void add(javax.naming.directory.Attribute attr,
                java.math.BigInteger id)
         throws javax.naming.NamingException
Specified by:
add in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.add( javax.naming.directory.Attribute, java.math.BigInteger)

add

public void add(javax.naming.directory.Attributes attrs,
                java.math.BigInteger id)
         throws javax.naming.NamingException
Specified by:
add in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.add( javax.naming.directory.Attributes, java.math.BigInteger)

drop

public void drop(java.lang.Object attrVal,
                 java.math.BigInteger id)
          throws javax.naming.NamingException
Specified by:
drop in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.drop(java.lang.Object, java.math.BigInteger)

drop

public void drop(java.math.BigInteger entryId)
          throws javax.naming.NamingException
Specified by:
drop in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.drop(java.math.BigInteger)

drop

public void drop(javax.naming.directory.Attribute attr,
                 java.math.BigInteger id)
          throws javax.naming.NamingException
Description copied from interface: Index
If the Attribute does not have any values then this reduces to a drop(BigInteger) call.

Specified by:
drop in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.drop( javax.naming.directory.Attribute, java.math.BigInteger)

drop

public void drop(javax.naming.directory.Attributes attrs,
                 java.math.BigInteger id)
          throws javax.naming.NamingException
Description copied from interface: Index
If the Attribute for this index within the Attributes does not have any values then this reduces to a drop(BigInteger) call.

Specified by:
drop in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.drop( javax.naming.directory.Attributes, java.math.BigInteger)

listReverseIndices

public IndexEnumeration listReverseIndices(java.math.BigInteger id)
                                    throws javax.naming.NamingException
Specified by:
listReverseIndices in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.listReverseIndices(BigInteger)

listIndices

public IndexEnumeration listIndices()
                             throws javax.naming.NamingException
Specified by:
listIndices in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.listIndices()

listIndices

public IndexEnumeration listIndices(java.lang.Object attrVal)
                             throws javax.naming.NamingException
Specified by:
listIndices in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.listIndices(java.lang.Object)

listIndices

public IndexEnumeration listIndices(java.lang.Object attrVal,
                                    boolean isGreaterThan)
                             throws javax.naming.NamingException
Specified by:
listIndices in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.listIndices(java.lang.Object, boolean)

listIndices

public IndexEnumeration listIndices(java.util.regex.Pattern regex)
                             throws javax.naming.NamingException
Specified by:
listIndices in interface Index
Throws:
javax.naming.NamingException
See Also:
Index#listIndices(org.apache.regexp.RE)

listIndices

public IndexEnumeration listIndices(java.util.regex.Pattern regex,
                                    java.lang.String prefix)
                             throws javax.naming.NamingException
Specified by:
listIndices in interface Index
Throws:
javax.naming.NamingException
See Also:
Index#listIndices(org.apache.regexp.RE, java.lang.String)

hasValue

public boolean hasValue(java.lang.Object attrVal,
                        java.math.BigInteger id)
                 throws javax.naming.NamingException
Specified by:
hasValue in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.hasValue(java.lang.Object, java.math.BigInteger)

hasValue

public boolean hasValue(java.lang.Object attrVal,
                        java.math.BigInteger id,
                        boolean isGreaterThan)
                 throws javax.naming.NamingException
Specified by:
hasValue in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.hasValue(java.lang.Object, java.math.BigInteger, boolean)

hasValue

public boolean hasValue(java.util.regex.Pattern regex,
                        java.math.BigInteger id)
                 throws javax.naming.NamingException
Specified by:
hasValue in interface Index
Throws:
javax.naming.NamingException
See Also:
Index#hasValue(org.apache.regexp.RE, java.math.BigInteger)

close

public void close()
           throws javax.naming.NamingException
Specified by:
close in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.close()

sync

public void sync()
          throws javax.naming.NamingException
Specified by:
sync in interface Index
Throws:
javax.naming.NamingException
See Also:
Index.sync()

getNormalized

public java.lang.Object getNormalized(java.lang.Object attrVal)
                               throws javax.naming.NamingException
TODO I don't think the keyCache is required anymore since the normalizer will cache values for us.

Specified by:
getNormalized in interface Index
Parameters:
attrVal - the user provided value to normalize
Returns:
the normalized value.
Throws:
javax.naming.NamingException - if something goes wrong.


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