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

java.lang.Object
  extended by org.apache.directory.server.xdbm.AbstractIndex<K,O,ID>
      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 AbstractIndex<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.

Author:
Apache Directory Project

Field Summary
protected  URI wkDirPath
          Index working directory
 
Fields inherited from class org.apache.directory.server.xdbm.AbstractIndex
attributeId, attributeType, cacheSize, initialized
 
Fields inherited from interface org.apache.directory.server.xdbm.Index
DEFAULT_INDEX_CACHE_SIZE
 
Constructor Summary
GenericIndex(String attributeId)
          Creates a new instance of GenericIndex.
GenericIndex(String attributeId, int cacheSize)
          Creates a new instance of GenericIndex.
GenericIndex(String attributeId, int cacheSize, URI wkDirPath)
          Creates a new instance of GenericIndex.
 
Method Summary
 void add(K attrVal, ID id)
          Add an entry into the index, associated with the element ID.
 void close()
           
 int count()
          Gets the total scan count for this index.
 int count(K attrVal)
          Gets the scan count for the occurrence 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)
          Remove the pair from the index for the given value and 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.model.cursor.Cursor<ID> forwardValueCursor(K key)
           
 org.apache.directory.shared.ldap.model.schema.AttributeType getAttribute()
          Gets the attribute this Index is built upon.
 K getNormalized(K attrVal)
          Gets the normalized value for an attribute.
 URI getWkDirPath()
          Gets the working directory path to something other than the default.
 int greaterThanCount(K attrVal)
           
 boolean isDupsEnabled()
          tells whether the Index implementation supports storing duplicate keys
 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.model.cursor.Cursor<K> reverseValueCursor(ID id)
           
 void setWkDirPath(URI wkDirPath)
          Sets the working directory path to something other than the default.
 void sync()
           
 
Methods inherited from class org.apache.directory.server.xdbm.AbstractIndex
getAttributeId, getCacheSize, protect, setAttributeId, setCacheSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wkDirPath

protected URI wkDirPath
Index working directory

Constructor Detail

GenericIndex

public GenericIndex(String attributeId)
Creates a new instance of GenericIndex.

Parameters:
attributeId - the attribute ID

GenericIndex

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

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

GenericIndex

public GenericIndex(String attributeId,
                    int cacheSize,
                    URI 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 Exception
Description copied from interface: Index
Add an entry into the index, associated with the element ID. The added value is the key to retrieve the element having the given ID.

Parameters:
attrVal - The added value
id - The element ID pointed by the added value
Throws:
Exception - If the addition can't be done

close

public void close()
           throws Exception
Throws:
Exception

count

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

Returns:
the number of key/value pairs in this index
Throws:
Exception - on failure to access index db files

count

public int count(K attrVal)
          throws Exception
Description copied from interface: Index
Gets the scan count for the occurrence of a specific attribute value within the 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:
Exception - on failure to access index db files

drop

public void drop(ID id)
          throws 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.

Parameters:
id - The master table entry ID to remove
Throws:
Exception

drop

public void drop(K attrVal,
                 ID id)
          throws Exception
Description copied from interface: Index
Remove the pair from the index for the given value and id.

Parameters:
attrVal - The value we want to remove from the index
id - The associated ID
Throws:
Exception - If the removal can't be done

forwardCursor

public IndexCursor<K,O,ID> forwardCursor()
                                  throws Exception
Throws:
Exception

forwardCursor

public IndexCursor<K,O,ID> forwardCursor(K key)
                                  throws Exception
Throws:
Exception

forwardLookup

public ID forwardLookup(K attrVal)
                 throws Exception
Throws:
Exception

forwardValueCursor

public org.apache.directory.shared.ldap.model.cursor.Cursor<ID> forwardValueCursor(K key)
                                                                            throws Exception
Throws:
Exception

forward

public boolean forward(K attrVal)
                throws Exception
Throws:
Exception

forward

public boolean forward(K attrVal,
                       ID id)
                throws Exception
Throws:
Exception

reverse

public boolean reverse(ID id)
                throws Exception
Throws:
Exception

reverse

public boolean reverse(ID id,
                       K attrVal)
                throws Exception
Throws:
Exception

forwardGreaterOrEq

public boolean forwardGreaterOrEq(K attrVal)
                           throws Exception
Throws:
Exception

forwardGreaterOrEq

public boolean forwardGreaterOrEq(K attrVal,
                                  ID id)
                           throws Exception
Throws:
Exception

reverseGreaterOrEq

public boolean reverseGreaterOrEq(ID id)
                           throws Exception
Throws:
Exception

reverseGreaterOrEq

public boolean reverseGreaterOrEq(ID id,
                                  K attrVal)
                           throws Exception
Throws:
Exception

forwardLessOrEq

public boolean forwardLessOrEq(K attrVal)
                        throws Exception
Throws:
Exception

forwardLessOrEq

public boolean forwardLessOrEq(K attrVal,
                               ID id)
                        throws Exception
Throws:
Exception

reverseLessOrEq

public boolean reverseLessOrEq(ID id)
                        throws Exception
Throws:
Exception

reverseLessOrEq

public boolean reverseLessOrEq(ID id,
                               K attrVal)
                        throws Exception
Throws:
Exception

getAttribute

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

Specified by:
getAttribute in interface Index<K,O,ID>
Overrides:
getAttribute in class AbstractIndex<K,O,ID>
Returns:
the id of the Index's attribute

getNormalized

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

Parameters:
attrVal - the user provided value to normalize
Returns:
the normalized value.
Throws:
Exception - if something goes wrong.

getWkDirPath

public URI 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.

Returns:
optional working directory path

greaterThanCount

public int greaterThanCount(K attrVal)
                     throws Exception
Throws:
Exception

lessThanCount

public int lessThanCount(K attrVal)
                  throws Exception
Throws:
Exception

reverseCursor

public IndexCursor<K,O,ID> reverseCursor()
                                  throws Exception
Throws:
Exception

reverseCursor

public IndexCursor<K,O,ID> reverseCursor(ID id)
                                  throws Exception
Throws:
Exception

reverseLookup

public K reverseLookup(ID id)
                throws Exception
Throws:
Exception

reverseValueCursor

public org.apache.directory.shared.ldap.model.cursor.Cursor<K> reverseValueCursor(ID id)
                                                                           throws Exception
Throws:
Exception

setWkDirPath

public void setWkDirPath(URI 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.

Parameters:
wkDirPath - optional working directory path

sync

public void sync()
          throws Exception
Throws:
Exception

isDupsEnabled

public boolean isDupsEnabled()
tells whether the Index implementation supports storing duplicate keys

Specified by:
isDupsEnabled in interface Index<K,O,ID>
Overrides:
isDupsEnabled in class AbstractIndex<K,O,ID>
Returns:
true if duplicate keys are allowed false otherwise


Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.