| | |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | | import static org.opends.messages.JebMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.util.Comparator; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedList; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | |
| | | import org.opends.server.types.SortOrder; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import static org.opends.messages.JebMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | /** |
| | | * This class represents a VLV index. Each database record is a sorted list |
| | | * of entry IDs followed by sets of attribute values used to sort the entries. |
| | |
| | | * index. |
| | | * @param state The state database to persist vlvIndex state info. |
| | | * @param env The JE Storage |
| | | * @param entryContainer The database entryContainer holding this vlvIndex. |
| | | * @param entryContainer The database entryContainer holding this vlvIndex. the sort order |
| | | * @param txn The transaction to use when creating this object |
| | | * @throws StorageRuntimeException |
| | | * If an error occurs in the JE database. |
| | | * @throws ConfigException if a error occurs while reading the VLV index |
| | |
| | | * @throws DirectoryException If a Directory Server |
| | | * error occurs. |
| | | */ |
| | | public boolean addEntry(IndexBuffer buffer, EntryID entryID, Entry entry) |
| | | throws DirectoryException |
| | | boolean addEntry(IndexBuffer buffer, EntryID entryID, Entry entry) throws DirectoryException |
| | | { |
| | | if (shouldInclude(entry)) |
| | | { |
| | |
| | | * or False otherwise. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | public boolean removeEntry(IndexBuffer buffer, EntryID entryID, Entry entry) |
| | | throws DirectoryException |
| | | boolean removeEntry(IndexBuffer buffer, EntryID entryID, Entry entry) throws DirectoryException |
| | | { |
| | | if (shouldInclude(entry)) |
| | | { |
| | |
| | | * JE database. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | public boolean modifyEntry(IndexBuffer buffer, |
| | | boolean modifyEntry(IndexBuffer buffer, |
| | | EntryID entryID, |
| | | Entry oldEntry, |
| | | Entry newEntry, |
| | |
| | | * JE database. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | public boolean containsValues(ReadableStorage txn, long entryID, |
| | | ByteString[] values, AttributeType[] types) |
| | | throws StorageRuntimeException, DirectoryException |
| | | boolean containsValues(ReadableStorage txn, long entryID, ByteString[] values, AttributeType[] types) |
| | | throws StorageRuntimeException, DirectoryException |
| | | { |
| | | SortValuesSet valuesSet = getSortValuesSet(txn, entryID, values, types); |
| | | int pos = valuesSet.binarySearch(entryID, values); |
| | |
| | | * @throws DirectoryException If a Directory Server |
| | | * error occurs. |
| | | */ |
| | | public void updateIndex(WriteableStorage txn, |
| | | TreeSet<SortValues> addedValues, |
| | | TreeSet<SortValues> deletedValues) |
| | | void updateIndex(WriteableStorage txn, TreeSet<SortValues> addedValues, TreeSet<SortValues> deletedValues) |
| | | throws DirectoryException, StorageRuntimeException |
| | | { |
| | | // Handle cases where nothing is changed early to avoid |
| | |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | public EntryIDSet evaluate(ReadableStorage txn, |
| | | EntryIDSet evaluate(ReadableStorage txn, |
| | | SearchOperation searchOperation, |
| | | ServerSideSortRequestControl sortControl, |
| | | VLVRequestControl vlvRequest, |
| | |
| | | * otherwise. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | public boolean shouldInclude(Entry entry) throws DirectoryException |
| | | boolean shouldInclude(Entry entry) throws DirectoryException |
| | | { |
| | | DN entryDN = entry.getName(); |
| | | return entryDN.matchesBaseAndScope(baseDN, scope) |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the sort order of this VLV index. |
| | | * |
| | | * @return the sort order |
| | | */ |
| | | SortOrder getSortOrder() |
| | | { |
| | | return sortOrder; |