org.apache.directory.server.xdbm
Class GenericIndex<K,O,ID>

java.lang.Object
  extended by org.apache.directory.server.xdbm.GenericIndex<K,O,ID>
All Implemented Interfaces:
Index<K,O,ID>

public class GenericIndex<K,O,ID>
extends java.lang.Object
implements Index<K,O,ID>

A generic index implementation that is just used to hold the index configuration parameters (attributeId, cacheSize, wkDirPath). All other methods are not working.

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

Field Summary
protected  java.lang.String attributeId
           
protected  int cacheSize
           
protected  java.io.File wkDirPath
           
 
Fields inherited from interface org.apache.directory.server.xdbm.Index
DEFAULT_INDEX_CACHE_SIZE
 
Constructor Summary
GenericIndex(java.lang.String attributeId, int cacheSize)
          Creates a new instance of GenericIndex.
GenericIndex(java.lang.String attributeId, int cacheSize, java.io.File wkDirPath)
          Creates a new instance of GenericIndex.
 
Method Summary
 void add(K attrVal, ID id)
           
 void close()
           
 int count()
          Gets the total scan count for this index.
 int count(K attrVal)
          Gets the scan count for the occurance of a specific attribute value within the index.
 void drop(ID id)
          Remove all the reference to an entry from the index.
 void drop(K attrVal, ID id)
           
 boolean forward(K attrVal)
           
 boolean forward(K attrVal, ID id)
           
 IndexCursor<K,O,ID> forwardCursor()
           
 IndexCursor<K,O,ID> forwardCursor(K key)
           
 boolean forwardGreaterOrEq(K attrVal)
           
 boolean forwardGreaterOrEq(K attrVal, ID id)
           
 boolean forwardLessOrEq(K attrVal)
           
 boolean forwardLessOrEq(K attrVal, ID id)
           
 ID forwardLookup(K attrVal)
           
 org.apache.directory.shared.ldap.cursor.Cursor<ID> forwardValueCursor(K key)
           
 org.apache.directory.shared.ldap.schema.AttributeType getAttribute()
          Gets the attribute this Index is built upon.
 java.lang.String getAttributeId()
          Gets the attribute identifier set at configuration time for this index which may not be the OID but an alias name for the attributeType associated with this Index
 int getCacheSize()
          Gets the size of the index cache in terms of the number of index entries to be cached.
 K getNormalized(K attrVal)
          Gets the normalized value for an attribute.
 java.io.File getWkDirPath()
          Gets the working directory path to something other than the default.
 int greaterThanCount(K attrVal)
           
 boolean isCountExact()
          Checks whether or not calls to count the number of keys greater than or less than the key are exact.
 int lessThanCount(K attrVal)
           
 boolean reverse(ID id)
           
 boolean reverse(ID id, K attrVal)
           
 IndexCursor<K,O,ID> reverseCursor()
           
 IndexCursor<K,O,ID> reverseCursor(ID id)
           
 boolean reverseGreaterOrEq(ID id)
           
 boolean reverseGreaterOrEq(ID id, K attrVal)
           
 boolean reverseLessOrEq(ID id)
           
 boolean reverseLessOrEq(ID id, K attrVal)
           
 K reverseLookup(ID id)
           
 org.apache.directory.shared.ldap.cursor.Cursor<K> reverseValueCursor(ID id)
           
 void setAttributeId(java.lang.String attributeId)
          Sets the attribute identifier set at configuration time for this index which may not be the OID but an alias name for the attributeType associated with this Index
 void setCacheSize(int cacheSize)
          Sets the size of the index cache in terms of the number of index entries to be cached.
 void setWkDirPath(java.io.File wkDirPath)
          Sets the working directory path to something other than the default.
 void sync()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attributeId

protected java.lang.String attributeId

cacheSize

protected int cacheSize

wkDirPath

protected java.io.File wkDirPath
Constructor Detail

GenericIndex

public GenericIndex(java.lang.String attributeId,
                    int cacheSize)
Creates a new instance of GenericIndex.

Parameters:
attributeId - the attribute ID
cacheSize - the cache size

GenericIndex

public GenericIndex(java.lang.String attributeId,
                    int cacheSize,
                    java.io.File wkDirPath)
Creates a new instance of GenericIndex.

Parameters:
attributeId - the attribute ID
cacheSize - the cache size
wkDirPath - the working directory
Method Detail

add

public void add(K attrVal,
                ID id)
         throws java.lang.Exception
Specified by:
add in interface Index<K,O,ID>
Throws:
java.lang.Exception

close

public void close()
           throws java.lang.Exception
Specified by:
close in interface Index<K,O,ID>
Throws:
java.lang.Exception

count

public int count()
          throws java.lang.Exception
Description copied from interface: Index
Gets the total scan count for this index.

Specified by:
count in interface Index<K,O,ID>
Returns:
the number of key/value pairs in this index
Throws:
java.lang.Exception - on failure to access index db files

count

public int count(K attrVal)
          throws java.lang.Exception
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<K,O,ID>
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:
java.lang.Exception - on failure to access index db files

drop

public void drop(ID id)
          throws java.lang.Exception
Description copied from interface: Index
Remove all the reference to an entry from the index. As an entry might be referenced more than once in the forward index, depending on which index we are dealing with, we need to iterate over all the values contained into the reverse index for this entryId. For instance, considering the ObjectClass index for an entry having three ObjectClasses (top, person, inetOrgPerson), then the reverse index will contain : [entryId, [top, person, inetOrgPerson]] and the forward index will contain many entries like : [top, [..., entryId, ...]] [person, [..., entryId, ...]] [inetOrgPerson, [..., entryId, ...]] So dropping the entryId means that we must first get all the values from the reverse index (and we will get [top, person, inetOrgPerson]) then to iterate through all those values to remove entryId from the associated list of entryIds.

Specified by:
drop in interface Index<K,O,ID>
Parameters:
id - The master table entry ID to remove
Throws:
java.lang.Exception

drop

public void drop(K attrVal,
                 ID id)
          throws java.lang.Exception
Specified by:
drop in interface Index<K,O,ID>
Throws:
java.lang.Exception

forwardCursor

public IndexCursor<K,O,ID> forwardCursor()
                                  throws java.lang.Exception
Specified by:
forwardCursor in interface Index<K,O,ID>
Throws:
java.lang.Exception

forwardCursor

public IndexCursor<K,O,ID> forwardCursor(K key)
                                  throws java.lang.Exception
Specified by:
forwardCursor in interface Index<K,O,ID>
Throws:
java.lang.Exception

forwardLookup

public ID forwardLookup(K attrVal)
                 throws java.lang.Exception
Specified by:
forwardLookup in interface Index<K,O,ID>
Throws:
java.lang.Exception

forwardValueCursor

public org.apache.directory.shared.ldap.cursor.Cursor<ID> forwardValueCursor(K key)
                                                                      throws java.lang.Exception
Specified by:
forwardValueCursor in interface Index<K,O,ID>
Throws:
java.lang.Exception

forward

public boolean forward(K attrVal)
                throws java.lang.Exception
Specified by:
forward in interface Index<K,O,ID>
Throws:
java.lang.Exception

forward

public boolean forward(K attrVal,
                       ID id)
                throws java.lang.Exception
Specified by:
forward in interface Index<K,O,ID>
Throws:
java.lang.Exception

reverse

public boolean reverse(ID id)
                throws java.lang.Exception
Specified by:
reverse in interface Index<K,O,ID>
Throws:
java.lang.Exception

reverse

public boolean reverse(ID id,
                       K attrVal)
                throws java.lang.Exception
Specified by:
reverse in interface Index<K,O,ID>
Throws:
java.lang.Exception

forwardGreaterOrEq

public boolean forwardGreaterOrEq(K attrVal)
                           throws java.lang.Exception
Specified by:
forwardGreaterOrEq in interface Index<K,O,ID>
Throws:
java.lang.Exception

forwardGreaterOrEq

public boolean forwardGreaterOrEq(K attrVal,
                                  ID id)
                           throws java.lang.Exception
Specified by:
forwardGreaterOrEq in interface Index<K,O,ID>
Throws:
java.lang.Exception

reverseGreaterOrEq

public boolean reverseGreaterOrEq(ID id)
                           throws java.lang.Exception
Specified by:
reverseGreaterOrEq in interface Index<K,O,ID>
Throws:
java.lang.Exception

reverseGreaterOrEq

public boolean reverseGreaterOrEq(ID id,
                                  K attrVal)
                           throws java.lang.Exception
Specified by:
reverseGreaterOrEq in interface Index<K,O,ID>
Throws:
java.lang.Exception

forwardLessOrEq

public boolean forwardLessOrEq(K attrVal)
                        throws java.lang.Exception
Specified by:
forwardLessOrEq in interface Index<K,O,ID>
Throws:
java.lang.Exception

forwardLessOrEq

public boolean forwardLessOrEq(K attrVal,
                               ID id)
                        throws java.lang.Exception
Specified by:
forwardLessOrEq in interface Index<K,O,ID>
Throws:
java.lang.Exception

reverseLessOrEq

public boolean reverseLessOrEq(ID id)
                        throws java.lang.Exception
Specified by:
reverseLessOrEq in interface Index<K,O,ID>
Throws:
java.lang.Exception

reverseLessOrEq

public boolean reverseLessOrEq(ID id,
                               K attrVal)
                        throws java.lang.Exception
Specified by:
reverseLessOrEq in interface Index<K,O,ID>
Throws:
java.lang.Exception

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<K,O,ID>
Returns:
the id of the Index's attribute

getAttributeId

public java.lang.String getAttributeId()
Description copied from interface: Index
Gets the attribute identifier set at configuration time for this index which may not be the OID but an alias name for the attributeType associated with this Index

Specified by:
getAttributeId in interface Index<K,O,ID>
Returns:
configured attribute oid or alias name

getCacheSize

public int getCacheSize()
Description copied from interface: Index
Gets the size of the index cache in terms of the number of index entries to be cached.

Specified by:
getCacheSize in interface Index<K,O,ID>
Returns:
the size of the index cache

getNormalized

public K getNormalized(K attrVal)
                throws java.lang.Exception
Description copied from interface: Index
Gets the normalized value for an attribute.

Specified by:
getNormalized in interface Index<K,O,ID>
Parameters:
attrVal - the user provided value to normalize
Returns:
the normalized value.
Throws:
java.lang.Exception - if something goes wrong.

getWkDirPath

public java.io.File getWkDirPath()
Description copied from interface: Index
Gets the working directory path to something other than the default. Sometimes more performance is gained by locating indices on separate disk spindles.

Specified by:
getWkDirPath in interface Index<K,O,ID>
Returns:
optional working directory path

greaterThanCount

public int greaterThanCount(K attrVal)
                     throws java.lang.Exception
Specified by:
greaterThanCount in interface Index<K,O,ID>
Throws:
java.lang.Exception

isCountExact

public boolean isCountExact()
Description copied from interface: Index
Checks whether or not calls to count the number of keys greater than or less than the key are exact. Checking to see the number of values greater than or less than some key may be excessively costly. Since this is not a critical function but one that assists in optimizing searches some implementations can just return a worst case (maximum) guess.

Specified by:
isCountExact in interface Index<K,O,ID>
Returns:
true if the count is an exact value or a worst case guess

lessThanCount

public int lessThanCount(K attrVal)
                  throws java.lang.Exception
Specified by:
lessThanCount in interface Index<K,O,ID>
Throws:
java.lang.Exception

reverseCursor

public IndexCursor<K,O,ID> reverseCursor()
                                  throws java.lang.Exception
Specified by:
reverseCursor in interface Index<K,O,ID>
Throws:
java.lang.Exception

reverseCursor

public IndexCursor<K,O,ID> reverseCursor(ID id)
                                  throws java.lang.Exception
Specified by:
reverseCursor in interface Index<K,O,ID>
Throws:
java.lang.Exception

reverseLookup

public K reverseLookup(ID id)
                throws java.lang.Exception
Specified by:
reverseLookup in interface Index<K,O,ID>
Throws:
java.lang.Exception

reverseValueCursor

public org.apache.directory.shared.ldap.cursor.Cursor<K> reverseValueCursor(ID id)
                                                                     throws java.lang.Exception
Specified by:
reverseValueCursor in interface Index<K,O,ID>
Throws:
java.lang.Exception

setAttributeId

public void setAttributeId(java.lang.String attributeId)
Description copied from interface: Index
Sets the attribute identifier set at configuration time for this index which may not be the OID but an alias name for the attributeType associated with this Index

Specified by:
setAttributeId in interface Index<K,O,ID>
Parameters:
attributeId - configured attribute oid or alias name

setCacheSize

public void setCacheSize(int cacheSize)
Description copied from interface: Index
Sets the size of the index cache in terms of the number of index entries to be cached.

Specified by:
setCacheSize in interface Index<K,O,ID>
Parameters:
cacheSize - the size of the index cache

setWkDirPath

public void setWkDirPath(java.io.File wkDirPath)
Description copied from interface: Index
Sets the working directory path to something other than the default. Sometimes more performance is gained by locating indices on separate disk spindles.

Specified by:
setWkDirPath in interface Index<K,O,ID>
Parameters:
wkDirPath - optional working directory path

sync

public void sync()
          throws java.lang.Exception
Specified by:
sync in interface Index<K,O,ID>
Throws:
java.lang.Exception


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