public class JdbmIndex<K> extends AbstractIndex<K,String>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_DUPLICATE_LIMIT
default duplicate limit before duplicate keys switch to using a btree for values
|
protected JdbmTable<K,String> |
forward
the forward btree where the btree key is the value of the indexed attribute and
the value of the btree is the entry id of the entry containing an attribute with
that value
|
static String |
FORWARD_BTREE
the key used for the forward btree name
|
protected int |
numDupLimit
duplicate limit before duplicate keys switch to using a btree for values
|
protected jdbm.RecordManager |
recMan
the JDBM record manager for the file containing this index
|
protected JdbmTable<String,K> |
reverse
the reverse btree where the btree key is the entry id of the entry containing a
value for the indexed attribute, and the btree value is the value of the indexed
attribute
|
static String |
REVERSE_BTREE
the key used for the reverse btree name
|
protected File |
wkDirPath
a custom working directory path when specified in configuration
|
attributeId, attributeType, cacheSize, commitNumber, initialized, withReverse
DEFAULT_INDEX_CACHE_SIZE
Constructor and Description |
---|
JdbmIndex(String attributeId,
boolean withReverse)
Creates a JdbmIndex instance for a give AttributeId
|
Modifier and Type | Method and Description |
---|---|
void |
add(K attrVal,
String id)
Add an entry into the index, associated with the element ID.
|
void |
close() |
long |
count()
Gets the total scan count for this index.
|
long |
count(K attrVal)
Gets the scan count for the occurrence of a specific attribute value
within the index.
|
void |
drop(K attrVal,
String id)
Remove the pair
|
void |
drop(String entryId)
Remove all the reference to an entry from the index.
|
boolean |
forward(K attrVal) |
boolean |
forward(K attrVal,
String id) |
org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> |
forwardCursor() |
org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> |
forwardCursor(K key) |
String |
forwardLookup(K attrVal) |
org.apache.directory.api.ldap.model.cursor.Cursor<String> |
forwardValueCursor(K key) |
int |
getNumDupLimit()
Gets the threshold at which point duplicate keys use btree indirection to store
their values.
|
URI |
getWkDirPath()
Gets the working directory path to something other than the default.
|
long |
greaterThanCount(K attrVal) |
void |
init(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
org.apache.directory.api.ldap.model.schema.AttributeType attributeType)
Initialize the index for an Attribute, with a specific working directory (may be null).
|
boolean |
isDupsEnabled()
tells whether the Index implementation supports storing duplicate keys
|
long |
lessThanCount(K attrVal) |
boolean |
reverse(String id) |
boolean |
reverse(String id,
K attrVal) |
org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> |
reverseCursor() |
org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> |
reverseCursor(String id) |
K |
reverseLookup(String id) |
org.apache.directory.api.ldap.model.cursor.Cursor<K> |
reverseValueCursor(String id) |
void |
setNumDupLimit(int numDupLimit)
Sets the threshold at which point duplicate keys use btree indirection to store
their values.
|
void |
setWkDirPath(URI wkDirPath)
Sets the working directory path to something other than the default.
|
void |
sync() |
String |
toString() |
getAttribute, getAttributeId, getCacheSize, hasReverse, protect, setAttributeId, setCacheSize
public static final int DEFAULT_DUPLICATE_LIMIT
public static final String FORWARD_BTREE
public static final String REVERSE_BTREE
protected JdbmTable<K,String> forward
protected JdbmTable<String,K> reverse
protected jdbm.RecordManager recMan
protected int numDupLimit
protected File wkDirPath
public JdbmIndex(String attributeId, boolean withReverse)
public void init(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager, org.apache.directory.api.ldap.model.schema.AttributeType attributeType) throws IOException
schemaManager
- The schemaManager to use to get back the AttributeattributeType
- The attributeType this index is created forIOException
- If the initialization failedpublic int getNumDupLimit()
public void setNumDupLimit(int numDupLimit)
numDupLimit
- the threshold for storing a keys values in another btreepublic void setWkDirPath(URI wkDirPath)
wkDirPath
- optional working directory pathpublic URI getWkDirPath()
public long count() throws IOException
IOException
public long count(K attrVal) throws Exception
attrVal
- the value of the attribute to get a scan count forException
- on failure to access index db filespublic long lessThanCount(K attrVal) throws Exception
Exception
Index.lessThanCount(java.lang.Object)
public String forwardLookup(K attrVal) throws Exception
Exception
Index#forwardLookup(java.lang.Object)
public K reverseLookup(String id) throws org.apache.directory.api.ldap.model.exception.LdapException
org.apache.directory.api.ldap.model.exception.LdapException
public void add(K attrVal, String id) throws Exception
attrVal
- The added valueid
- The element ID pointed by the added valueException
- If the addition can't be donepublic void drop(K attrVal, String id) throws Exception
attrVal
- The value we want to remove from the indexid
- The associated IDException
- If the removal can't be donepublic void drop(String entryId) throws Exception
[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.
entryId
- The master table entry ID to removeException
public org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> reverseCursor() throws Exception
Exception
public org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> forwardCursor() throws org.apache.directory.api.ldap.model.exception.LdapException
org.apache.directory.api.ldap.model.exception.LdapException
public org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> reverseCursor(String id) throws Exception
Exception
public org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> forwardCursor(K key) throws Exception
Exception
public org.apache.directory.api.ldap.model.cursor.Cursor<K> reverseValueCursor(String id) throws Exception
Exception
public org.apache.directory.api.ldap.model.cursor.Cursor<String> forwardValueCursor(K key) throws Exception
Exception
public boolean forward(K attrVal, String id) throws org.apache.directory.api.ldap.model.exception.LdapException
org.apache.directory.api.ldap.model.exception.LdapException
public void close() throws IOException
IOException
Index.close()
public void sync() throws IOException
IOException
Index#sync()
public boolean isDupsEnabled()
isDupsEnabled
in interface Index<K,String>
isDupsEnabled
in class AbstractIndex<K,String>
public String toString()
toString
in class Object
Object.toString()
Copyright © 2019. All rights reserved.