org.opends.server.backends.jeb
Class Index

java.lang.Object
  extended by org.opends.server.backends.jeb.DatabaseContainer
      extended by org.opends.server.backends.jeb.Index

public class Index
extends DatabaseContainer

Represents an index implemented by a JE database in which each key maps to a set of entry IDs. The key is a byte array, and is constructed from some normalized form of an attribute value (or fragment of a value) appearing in the entry.


Field Summary
 Indexer indexer
          The indexer object to construct index keys from LDAP attribute values.
 
Fields inherited from class org.opends.server.backends.jeb.DatabaseContainer
dbConfig, entryContainer, name
 
Constructor Summary
Index(java.lang.String name, Indexer indexer, State state, int indexEntryLimit, int cursorEntryLimit, boolean maintainCount, com.sleepycat.je.Environment env, EntryContainer entryContainer)
          Create a new index object.
 
Method Summary
 boolean addEntry(IndexBuffer buffer, EntryID entryID, Entry entry)
          Update the index buffer for a deleted entry.
 boolean addEntry(com.sleepycat.je.Transaction txn, EntryID entryID, Entry entry)
          Update the index for a new entry.
 ConditionResult containsID(com.sleepycat.je.Transaction txn, com.sleepycat.je.DatabaseEntry key, EntryID entryID)
          Check if an entry ID is in the set of IDs indexed by a given key.
 void delete(IndexBuffer buffer, byte[] keyBytes)
          Buffered delete of a key from the JE database.
 void delete(com.sleepycat.je.Transaction txn, java.util.Set<byte[]> keySet, EntryID entryID)
          Delete specified entry ID from all keys in the provided key set.
 int getEntryLimitExceededCount()
          Get the number of keys that have exceeded the entry limit since this object was created.
 int getIndexEntryLimit()
          Return entry limit.
 boolean getMaintainCount()
          Whether this index maintains a count of IDs for keys once the entry limit has exceeded.
 void incEntryLimitExceededCount()
          Increment the count of the number of keys that have exceeded the entry limit since this object was created.
 void insert(com.sleepycat.je.Transaction txn, com.sleepycat.je.DatabaseEntry key, ImportIDSet importIdSet, com.sleepycat.je.DatabaseEntry data)
          Add the specified import ID set to the provided key.
 boolean insert(com.sleepycat.je.Transaction txn, ImportIDSet importIDSet, java.util.Set<byte[]> keySet, com.sleepycat.je.DatabaseEntry keyData, com.sleepycat.je.DatabaseEntry data)
          Add the specified import ID set to the provided keys in the keyset.
 boolean insertID(IndexBuffer buffer, byte[] keyBytes, EntryID entryID)
          Add an add entry ID operation into a index buffer.
 boolean insertID(com.sleepycat.je.Transaction txn, com.sleepycat.je.DatabaseEntry key, EntryID entryID)
          Insert an entry ID into the set of IDs indexed by a given key.
 boolean isTrusted()
          Return true iff this index is trusted.
 void modifyEntry(IndexBuffer buffer, EntryID entryID, Entry oldEntry, Entry newEntry, java.util.List<Modification> mods)
          Update the index to reflect a sequence of modifications in a Modify operation.
 void modifyEntry(com.sleepycat.je.Transaction txn, EntryID entryID, Entry oldEntry, Entry newEntry, java.util.List<Modification> mods)
          Update the index to reflect a sequence of modifications in a Modify operation.
 EntryIDSet readKey(com.sleepycat.je.DatabaseEntry key, com.sleepycat.je.Transaction txn, com.sleepycat.je.LockMode lockMode)
          Reads the set of entry IDs for a given key.
 EntryIDSet readRange(byte[] lower, byte[] upper, boolean lowerIncluded, boolean upperIncluded)
          Reads a range of keys and collects all their entry IDs into a single set.
 void removeEntry(IndexBuffer buffer, EntryID entryID, Entry entry)
          Update the index buffer for a deleted entry.
 void removeEntry(com.sleepycat.je.Transaction txn, EntryID entryID, Entry entry)
          Update the index for a deleted entry.
 boolean removeID(IndexBuffer buffer, byte[] keyBytes, EntryID entryID)
          Add an remove entry ID operation into a index buffer.
 void removeID(com.sleepycat.je.Transaction txn, com.sleepycat.je.DatabaseEntry key, EntryID entryID)
          Remove an entry ID from the set of IDs indexed by a given key.
 boolean setIndexEntryLimit(int indexEntryLimit)
          Set the index entry limit.
 void setIndexer(Indexer indexer)
          Set the indexer.
 void setRebuildStatus(boolean rebuildRunning)
          Set the rebuild status of this index.
 void setTrusted(com.sleepycat.je.Transaction txn, boolean trusted)
          Set the index trust state.
 void writeKey(com.sleepycat.je.Transaction txn, com.sleepycat.je.DatabaseEntry key, EntryIDSet entryIDList)
          Writes the set of entry IDs for a given key.
 
Methods inherited from class org.opends.server.backends.jeb.DatabaseContainer
delete, getName, getRecordCount, insert, open, openCursor, preload, put, read, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

indexer

public Indexer indexer
The indexer object to construct index keys from LDAP attribute values.

Constructor Detail

Index

public Index(java.lang.String name,
             Indexer indexer,
             State state,
             int indexEntryLimit,
             int cursorEntryLimit,
             boolean maintainCount,
             com.sleepycat.je.Environment env,
             EntryContainer entryContainer)
      throws com.sleepycat.je.DatabaseException
Create a new index object.

Parameters:
name - The name of the index database within the entryContainer.
indexer - The indexer object to construct index keys from LDAP attribute values.
state - The state database to persist index state info.
indexEntryLimit - The configured limit on the number of entry IDs that may be indexed by one key.
cursorEntryLimit - The configured limit on the number of entry IDs
maintainCount - Whether to maintain a count of IDs for a key once the entry limit has exceeded.
env - The JE Environemnt
entryContainer - The database entryContainer holding this index.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.
Method Detail

insertID

public boolean insertID(IndexBuffer buffer,
                        byte[] keyBytes,
                        EntryID entryID)
Add an add entry ID operation into a index buffer.

Parameters:
buffer - The index buffer to insert the ID into.
keyBytes - The index key bytes.
entryID - The entry ID.
Returns:
True if the entry ID is inserted or ignored because the entry limit count is exceeded. False if it already exists in the entry ID set for the given key.

insertID

public boolean insertID(com.sleepycat.je.Transaction txn,
                        com.sleepycat.je.DatabaseEntry key,
                        EntryID entryID)
                 throws com.sleepycat.je.DatabaseException
Insert an entry ID into the set of IDs indexed by a given key.

Parameters:
txn - A database transaction, or null if none is required.
key - The index key.
entryID - The entry ID.
Returns:
True if the entry ID is inserted or ignored because the entry limit count is exceeded. False if it already exists in the entry ID set for the given key.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.

insert

public void insert(com.sleepycat.je.Transaction txn,
                   com.sleepycat.je.DatabaseEntry key,
                   ImportIDSet importIdSet,
                   com.sleepycat.je.DatabaseEntry data)
            throws com.sleepycat.je.DatabaseException
Add the specified import ID set to the provided key. Used during substring buffer flushing.

Parameters:
txn - A transaction.
key - The key to add the set to.
importIdSet - The set of import IDs.
data - Database entry to reuse for read
Throws:
com.sleepycat.je.DatabaseException - If an database error occurs.

insert

public boolean insert(com.sleepycat.je.Transaction txn,
                      ImportIDSet importIDSet,
                      java.util.Set<byte[]> keySet,
                      com.sleepycat.je.DatabaseEntry keyData,
                      com.sleepycat.je.DatabaseEntry data)
               throws com.sleepycat.je.DatabaseException
Add the specified import ID set to the provided keys in the keyset.

Parameters:
txn - A transaction.
importIDSet - A import ID set to use.
keySet - The set containing the keys.
keyData - A key database entry to use.
data - A database entry to use for data.
Returns:
True if the insert was successful.
Throws:
com.sleepycat.je.DatabaseException - If a database error occurs.

removeID

public boolean removeID(IndexBuffer buffer,
                        byte[] keyBytes,
                        EntryID entryID)
Add an remove entry ID operation into a index buffer.

Parameters:
buffer - The index buffer to insert the ID into.
keyBytes - The index key bytes.
entryID - The entry ID.
Returns:
True if the entry ID is inserted or ignored because the entry limit count is exceeded. False if it already exists in the entry ID set for the given key.

removeID

public void removeID(com.sleepycat.je.Transaction txn,
                     com.sleepycat.je.DatabaseEntry key,
                     EntryID entryID)
              throws com.sleepycat.je.DatabaseException
Remove an entry ID from the set of IDs indexed by a given key.

Parameters:
txn - A database transaction, or null if none is required.
key - The index key.
entryID - The entry ID.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.

delete

public void delete(com.sleepycat.je.Transaction txn,
                   java.util.Set<byte[]> keySet,
                   EntryID entryID)
            throws com.sleepycat.je.DatabaseException
Delete specified entry ID from all keys in the provided key set.

Parameters:
txn - A Transaction.
keySet - A set of keys.
entryID - The entry ID to delete.
Throws:
com.sleepycat.je.DatabaseException - If a database error occurs.

delete

public void delete(IndexBuffer buffer,
                   byte[] keyBytes)
Buffered delete of a key from the JE database.

Parameters:
buffer - The index buffer to use to store the deleted keys
keyBytes - The index key bytes.

containsID

public ConditionResult containsID(com.sleepycat.je.Transaction txn,
                                  com.sleepycat.je.DatabaseEntry key,
                                  EntryID entryID)
                           throws com.sleepycat.je.DatabaseException
Check if an entry ID is in the set of IDs indexed by a given key.

Parameters:
txn - A database transaction, or null if none is required.
key - The index key.
entryID - The entry ID.
Returns:
true if the entry ID is indexed by the given key, false if it is not indexed by the given key, undefined if the key has exceeded the entry limit.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.

readKey

public EntryIDSet readKey(com.sleepycat.je.DatabaseEntry key,
                          com.sleepycat.je.Transaction txn,
                          com.sleepycat.je.LockMode lockMode)
Reads the set of entry IDs for a given key.

Parameters:
key - The database key.
txn - A database transaction, or null if none is required.
lockMode - The JE locking mode to be used for the database read.
Returns:
The entry IDs indexed by this key.

writeKey

public void writeKey(com.sleepycat.je.Transaction txn,
                     com.sleepycat.je.DatabaseEntry key,
                     EntryIDSet entryIDList)
              throws com.sleepycat.je.DatabaseException
Writes the set of entry IDs for a given key.

Parameters:
key - The database key.
entryIDList - The entry IDs indexed by this key.
txn - A database transaction, or null if none is required.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.

readRange

public EntryIDSet readRange(byte[] lower,
                            byte[] upper,
                            boolean lowerIncluded,
                            boolean upperIncluded)
Reads a range of keys and collects all their entry IDs into a single set.

Parameters:
lower - The lower bound of the range. A 0 length byte array indicates no lower bound and the range will start from the smallest key.
upper - The upper bound of the range. A 0 length byte array indicates no upper bound and the range will end at the largest key.
lowerIncluded - true if a key exactly matching the lower bound is included in the range, false if only keys strictly greater than the lower bound are included. This value is ignored if the lower bound is not specified.
upperIncluded - true if a key exactly matching the upper bound is included in the range, false if only keys strictly less than the upper bound are included. This value is ignored if the upper bound is not specified.
Returns:
The set of entry IDs.

getEntryLimitExceededCount

public int getEntryLimitExceededCount()
Get the number of keys that have exceeded the entry limit since this object was created.

Returns:
The number of keys that have exceeded the entry limit since this object was created.

incEntryLimitExceededCount

public void incEntryLimitExceededCount()
Increment the count of the number of keys that have exceeded the entry limit since this object was created.


addEntry

public boolean addEntry(IndexBuffer buffer,
                        EntryID entryID,
                        Entry entry)
                 throws com.sleepycat.je.DatabaseException,
                        DirectoryException
Update the index buffer for a deleted entry.

Parameters:
buffer - The index buffer to use to store the deleted keys
entryID - The entry ID.
entry - The entry to be indexed.
Returns:
True if all the indexType keys for the entry are added. False if the entry ID already exists for some keys.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.
DirectoryException - If a Directory Server error occurs.

addEntry

public boolean addEntry(com.sleepycat.je.Transaction txn,
                        EntryID entryID,
                        Entry entry)
                 throws com.sleepycat.je.DatabaseException,
                        DirectoryException
Update the index for a new entry.

Parameters:
txn - A database transaction, or null if none is required.
entryID - The entry ID.
entry - The entry to be indexed.
Returns:
True if all the indexType keys for the entry are added. False if the entry ID already exists for some keys.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.
DirectoryException - If a Directory Server error occurs.

removeEntry

public void removeEntry(IndexBuffer buffer,
                        EntryID entryID,
                        Entry entry)
                 throws com.sleepycat.je.DatabaseException,
                        DirectoryException
Update the index buffer for a deleted entry.

Parameters:
buffer - The index buffer to use to store the deleted keys
entryID - The entry ID
entry - The contents of the deleted entry.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.
DirectoryException - If a Directory Server error occurs.

removeEntry

public void removeEntry(com.sleepycat.je.Transaction txn,
                        EntryID entryID,
                        Entry entry)
                 throws com.sleepycat.je.DatabaseException,
                        DirectoryException
Update the index for a deleted entry.

Parameters:
txn - A database transaction, or null if none is required.
entryID - The entry ID
entry - The contents of the deleted entry.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.
DirectoryException - If a Directory Server error occurs.

modifyEntry

public void modifyEntry(com.sleepycat.je.Transaction txn,
                        EntryID entryID,
                        Entry oldEntry,
                        Entry newEntry,
                        java.util.List<Modification> mods)
                 throws com.sleepycat.je.DatabaseException
Update the index to reflect a sequence of modifications in a Modify operation.

Parameters:
txn - A database transaction, or null if none is required.
entryID - The ID of the entry that was modified.
oldEntry - The entry before the modifications were applied.
newEntry - The entry after the modifications were applied.
mods - The sequence of modifications in the Modify operation.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.

modifyEntry

public void modifyEntry(IndexBuffer buffer,
                        EntryID entryID,
                        Entry oldEntry,
                        Entry newEntry,
                        java.util.List<Modification> mods)
                 throws com.sleepycat.je.DatabaseException
Update the index to reflect a sequence of modifications in a Modify operation.

Parameters:
buffer - The index buffer to use to store the deleted keys
entryID - The ID of the entry that was modified.
oldEntry - The entry before the modifications were applied.
newEntry - The entry after the modifications were applied.
mods - The sequence of modifications in the Modify operation.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.

setIndexEntryLimit

public boolean setIndexEntryLimit(int indexEntryLimit)
Set the index entry limit.

Parameters:
indexEntryLimit - The index entry limit to set.
Returns:
True if a rebuild is required or false otherwise.

setIndexer

public void setIndexer(Indexer indexer)
Set the indexer.

Parameters:
indexer - The indexer to set

getIndexEntryLimit

public int getIndexEntryLimit()
Return entry limit.

Returns:
The entry limit.

setTrusted

public void setTrusted(com.sleepycat.je.Transaction txn,
                       boolean trusted)
                throws com.sleepycat.je.DatabaseException
Set the index trust state.

Parameters:
txn - A database transaction, or null if none is required.
trusted - True if this index should be trusted or false otherwise.
Throws:
com.sleepycat.je.DatabaseException - If an error occurs in the JE database.

isTrusted

public boolean isTrusted()
Return true iff this index is trusted.

Returns:
the trusted state of this index

setRebuildStatus

public void setRebuildStatus(boolean rebuildRunning)
Set the rebuild status of this index.

Parameters:
rebuildRunning - True if a rebuild process on this index is running or False otherwise.

getMaintainCount

public boolean getMaintainCount()
Whether this index maintains a count of IDs for keys once the entry limit has exceeded.

Returns:
true if this index maintains court of IDs or false otherwise