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(PartitionTxn partitionTxn,
K attrVal,
String id)
Add an entry into the index, associated with the element E.
|
void |
close(PartitionTxn partitionTxn)
Close and index
|
long |
count(PartitionTxn partitionTxn)
Gets the total scan count for this index.
|
long |
count(PartitionTxn partitionTxn,
K attrVal)
Gets the scan count for the occurrence of a specific attribute value
within the index.
|
void |
drop(PartitionTxn partitionTxn,
K attrVal,
String id)
Remove the pair <K,ID> from the index for the given value and id.
|
void |
drop(PartitionTxn partitionTxn,
String entryId)
Remove all the reference to an entry from the index.
|
boolean |
forward(PartitionTxn partitionTxn,
K attrVal)
Try to move forward in the index
|
boolean |
forward(PartitionTxn partitionTxn,
K attrVal,
String id)
Try to move forward in the index
|
org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> |
forwardCursor(PartitionTxn partitionTxn)
Builds a Cursor on the Forward index
|
org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> |
forwardCursor(PartitionTxn partitionTxn,
K key)
Builds a Cursor on the Forward index, starting at a specific key
|
String |
forwardLookup(PartitionTxn partitionTxn,
K attrVal)
Search for a value using the Forward table
|
org.apache.directory.api.ldap.model.cursor.Cursor<String> |
forwardValueCursor(PartitionTxn partitionTxn,
K key)
Builds a Cursor on the Forward index, starting at a specific 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(PartitionTxn partitionTxn,
K attrVal)
Find the number of element in a tree above a given key
|
void |
init(jdbm.RecordManager recMan,
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(PartitionTxn partitionTxn,
K attrVal)
Find the number of element in a tree below a given key
|
boolean |
reverse(PartitionTxn partitionTxn,
String id)
Try to move backward in the index
|
boolean |
reverse(PartitionTxn partitionTxn,
String id,
K attrVal)
Try to move backward in the index
|
K |
reverseLookup(PartitionTxn partitionTxn,
String id)
Search for a value using the Reverse table
|
org.apache.directory.api.ldap.model.cursor.Cursor<K> |
reverseValueCursor(PartitionTxn partitionTxn,
String id)
Builds a Cursor on the Reverse index, starting at a specific entry 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.
|
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
public void init(jdbm.RecordManager recMan, org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager, org.apache.directory.api.ldap.model.schema.AttributeType attributeType) throws org.apache.directory.api.ldap.model.exception.LdapException, IOException
recMan
- The RecordManagerschemaManager
- The schemaManager to use to get back the AttributeattributeType
- The attributeType this index is created fororg.apache.directory.api.ldap.model.exception.LdapException
- If the initialization failedIOException
- 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(PartitionTxn partitionTxn) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useorg.apache.directory.api.ldap.model.exception.LdapException
- on failure to access index db filespublic long count(PartitionTxn partitionTxn, K attrVal) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useattrVal
- the value of the attribute to get a scan count fororg.apache.directory.api.ldap.model.exception.LdapException
- on failure to access index db filespublic long greaterThanCount(PartitionTxn partitionTxn, K attrVal) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useattrVal
- The keyorg.apache.directory.api.ldap.model.exception.LdapException
- If the operation failedpublic long lessThanCount(PartitionTxn partitionTxn, K attrVal) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useattrVal
- The keyorg.apache.directory.api.ldap.model.exception.LdapException
- If the operation failedpublic String forwardLookup(PartitionTxn partitionTxn, K attrVal) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useattrVal
- The key to retrieveorg.apache.directory.api.ldap.model.exception.LdapException
- If the operation failedpublic K reverseLookup(PartitionTxn partitionTxn, String id) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useid
- The key to retrieveorg.apache.directory.api.ldap.model.exception.LdapException
- If the operation failedpublic void add(PartitionTxn partitionTxn, K attrVal, String id) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useattrVal
- The added valueid
- The entry ID pointed by the added valueorg.apache.directory.api.ldap.model.exception.LdapException
- If the addition can't be donepublic void drop(PartitionTxn partitionTxn, K attrVal, String id) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useattrVal
- The value we want to remove from the indexid
- The associated IDorg.apache.directory.api.ldap.model.exception.LdapException
- If the removal can't be donepublic void drop(PartitionTxn partitionTxn, String entryId) throws org.apache.directory.api.ldap.model.exception.LdapException
[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.
partitionTxn
- The transaction to useentryId
- The master table entryId to removeorg.apache.directory.api.ldap.model.exception.LdapException
- if we can't drop the element from the indexpublic org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> forwardCursor(PartitionTxn partitionTxn) throws org.apache.directory.api.ldap.model.exception.LdapException
Index
partitionTxn
- The transaction to useorg.apache.directory.api.ldap.model.exception.LdapException
- If the cursor can't be createdpublic org.apache.directory.api.ldap.model.cursor.Cursor<IndexEntry<K,String>> forwardCursor(PartitionTxn partitionTxn, K key) throws org.apache.directory.api.ldap.model.exception.LdapException
Index
partitionTxn
- The transaction to usekey
- The key to start fromorg.apache.directory.api.ldap.model.exception.LdapException
- If the cursor can't be createdpublic org.apache.directory.api.ldap.model.cursor.Cursor<K> reverseValueCursor(PartitionTxn partitionTxn, String id) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useid
- The entry ID to start fromorg.apache.directory.api.ldap.model.exception.LdapException
- If the cursor can't be createdpublic org.apache.directory.api.ldap.model.cursor.Cursor<String> forwardValueCursor(PartitionTxn partitionTxn, K key) throws org.apache.directory.api.ldap.model.exception.LdapException
Index
partitionTxn
- The transaction to usekey
- The key to start fromorg.apache.directory.api.ldap.model.exception.LdapException
- If the cursor can't be createdpublic boolean forward(PartitionTxn partitionTxn, K attrVal) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useattrVal
- The key we want to start withorg.apache.directory.api.ldap.model.exception.LdapException
- If we had an issue moving forwardpublic boolean forward(PartitionTxn partitionTxn, K attrVal, String id) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useattrVal
- The key we want to start withid
- The entry ID to start fromorg.apache.directory.api.ldap.model.exception.LdapException
- If we had an issue moving forwardpublic boolean reverse(PartitionTxn partitionTxn, String id) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useid
- The entry we want to start withorg.apache.directory.api.ldap.model.exception.LdapException
- If we had an issue moving backwardpublic boolean reverse(PartitionTxn partitionTxn, String id, K attrVal) throws org.apache.directory.api.ldap.model.exception.LdapException
partitionTxn
- The transaction to useid
- The entry ID to start fromattrVal
- The key we want to start withorg.apache.directory.api.ldap.model.exception.LdapException
- If we had an issue moving backwardpublic void close(PartitionTxn partitionTxn) throws org.apache.directory.api.ldap.model.exception.LdapException, IOException
partitionTxn
- The transaction to useorg.apache.directory.api.ldap.model.exception.LdapException
- If we weren't able to close the indexIOException
- If we had an issue with the index filepublic boolean isDupsEnabled()
isDupsEnabled
in interface Index<K,String>
isDupsEnabled
in class AbstractIndex<K,String>
public String toString()
toString
in class Object
Object.toString()
Copyright © 2003–2020 The Apache Software Foundation. All rights reserved.