More code cleanup:
Added generics
Ignored javadocs warnings
etc.
| | |
| | | import com.persistit.exception.RollbackException; |
| | | |
| | | /** PersistIt database implementation of the {@link Storage} engine. */ |
| | | @SuppressWarnings("javadoc") |
| | | public final class PersistItStorage implements Storage, ConfigurationChangeListener<PersistitBackendCfg>, |
| | | DiskSpaceMonitorHandler, AlertGenerator |
| | | { |
| | |
| | | private static final int BUFFER_SIZE = 16 * 1024; |
| | | |
| | | /** PersistIt implementation of the {@link Cursor} interface. */ |
| | | private final class CursorImpl implements Cursor |
| | | private final class CursorImpl implements Cursor<ByteString, ByteString> |
| | | { |
| | | private ByteString currentKey; |
| | | private ByteString currentValue; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void put(final TreeName treeName, final ByteSequence key, |
| | | final ByteSequence value) |
| | | public void put(final TreeName treeName, final ByteSequence key, final ByteSequence value) |
| | | { |
| | | try |
| | | { |
| | | final Tree tree = trees.get(treeName); |
| | | importer.store(tree, bytesToKey(importKey, key), |
| | | importer.store(tree, |
| | | bytesToKey(importKey, key), |
| | | bytesToValue(importValue, value)); |
| | | } |
| | | catch (final Exception e) |
| | |
| | | @Override |
| | | public long getRecordCount(TreeName treeName) |
| | | { |
| | | // FIXME: is the a better/quicker way to do this? |
| | | final Cursor cursor = openCursor(treeName); |
| | | // FIXME: is there a better/quicker way to do this? |
| | | final Cursor<?, ?> cursor = openCursor(treeName); |
| | | try |
| | | { |
| | | long count = 0; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Cursor openCursor(final TreeName treeName) |
| | | public Cursor<ByteString, ByteString> openCursor(final TreeName treeName) |
| | | { |
| | | try |
| | | { |
| | |
| | | * by the ordering matching rule. If these could be guaranteed to be identical |
| | | * then we would not need a separate ordering index. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | class AttributeIndex |
| | | implements ConfigurationChangeListener<BackendIndexCfg>, Closeable |
| | | { |
| | |
| | | * @throws StorageRuntimeException If an error occurs in the database. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | void addEntry(IndexBuffer buffer, EntryID entryID, Entry entry) |
| | | throws StorageRuntimeException, DirectoryException |
| | | void addEntry(IndexBuffer buffer, EntryID entryID, Entry entry) throws StorageRuntimeException, DirectoryException |
| | | { |
| | | for (MatchingRuleIndex index : nameToIndexes.values()) |
| | | { |
| | |
| | | * @throws StorageRuntimeException If an error occurs in the database. |
| | | * @throws DirectoryException If a Directory Server error occurs. |
| | | */ |
| | | void removeEntry(IndexBuffer buffer, EntryID entryID, Entry entry) |
| | | throws StorageRuntimeException, DirectoryException |
| | | void removeEntry(IndexBuffer buffer, EntryID entryID, Entry entry) throws StorageRuntimeException, DirectoryException |
| | | { |
| | | for (MatchingRuleIndex index : nameToIndexes.values()) |
| | | { |
| | |
| | | * @param entryID The ID of the entry that was modified. |
| | | * @param oldEntry The entry before the modifications were applied. |
| | | * @param newEntry The entry after the modifications were applied. |
| | | * @param mods The sequence of modifications in the Modify operation. |
| | | * @throws StorageRuntimeException If an error occurs during an operation on a |
| | | * database. |
| | | */ |
| | | void modifyEntry(IndexBuffer buffer, |
| | | EntryID entryID, |
| | | Entry oldEntry, |
| | | Entry newEntry, |
| | | List<Modification> mods) |
| | | throws StorageRuntimeException |
| | | void modifyEntry(IndexBuffer buffer, EntryID entryID, Entry oldEntry, Entry newEntry) throws StorageRuntimeException |
| | | { |
| | | for (MatchingRuleIndex index : nameToIndexes.values()) |
| | | { |
| | |
| | | * @return The candidate entry IDs that might contain a value |
| | | * that matches the filter type. |
| | | */ |
| | | EntryIDSet evaluateFilter(IndexQueryFactory<IndexQuery> indexQueryFactory, |
| | | IndexFilterType indexFilterType, |
| | | EntryIDSet evaluateFilter(IndexQueryFactory<IndexQuery> indexQueryFactory, IndexFilterType indexFilterType, |
| | | SearchFilter filter, StringBuilder debugBuffer, DatabaseEnvironmentMonitor monitor) |
| | | { |
| | | try |
| | |
| | | */ |
| | | private ConditionResult containsReferrals(ReadableTransaction txn) |
| | | { |
| | | Cursor cursor = txn.openCursor(getName()); |
| | | Cursor<?, ?> cursor = txn.openCursor(getName()); |
| | | try |
| | | { |
| | | return ConditionResult.valueOf(cursor.next()); |
| | |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | | import static org.forgerock.util.Reject.checkNotNull; |
| | | import static org.opends.messages.JebMessages.ERR_JEB_INDEX_CORRUPT_REQUIRES_REBUILD; |
| | | import static org.forgerock.util.Reject.*; |
| | | import static org.opends.messages.JebMessages.*; |
| | | import static org.opends.server.backends.pluggable.EntryIDSet.*; |
| | | import static org.opends.server.backends.pluggable.State.IndexFlag.COMPACTED; |
| | | import static org.opends.server.backends.pluggable.State.IndexFlag.TRUSTED; |
| | | import static org.opends.server.backends.pluggable.State.IndexFlag.*; |
| | | |
| | | import java.util.EnumSet; |
| | | |
| | |
| | | * is a byte array, and is constructed from some normalized form of an attribute value (or fragment |
| | | * of a value) appearing in the entry. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | class DefaultIndex extends AbstractDatabaseContainer implements Index |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public final Cursor<ByteString, EntryIDSet> openCursor(ReadableTransaction txn) |
| | | { |
| | | checkNotNull(txn, "txn must not be null"); |
| | |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public final void importPut(WriteableTransaction txn, ImportIDSet idsToBeAdded) throws StorageRuntimeException |
| | | { |
| | | ByteSequence key = idsToBeAdded.getKey(); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public final void importRemove(WriteableTransaction txn, ImportIDSet idsToBeRemoved) throws StorageRuntimeException |
| | | { |
| | | ByteSequence key = idsToBeRemoved.getKey(); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public final void update(final WriteableTransaction txn, final ByteString key, final EntryIDSet deletedIDs, |
| | | final EntryIDSet addedIDs) throws StorageRuntimeException |
| | | { |
| | |
| | | logger.error(ERR_JEB_INDEX_CORRUPT_REQUIRES_REBUILD, getName()); |
| | | } |
| | | |
| | | @Override |
| | | public final EntryIDSet get(ReadableTransaction txn, ByteSequence key) |
| | | { |
| | | try |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public final boolean setIndexEntryLimit(int indexEntryLimit) |
| | | { |
| | | final boolean rebuildRequired = this.indexEntryLimit < indexEntryLimit; |
| | |
| | | return rebuildRequired; |
| | | } |
| | | |
| | | @Override |
| | | public final int getIndexEntryLimit() |
| | | { |
| | | return indexEntryLimit; |
| | | } |
| | | |
| | | @Override |
| | | public final synchronized void setTrusted(WriteableTransaction txn, boolean trusted) throws StorageRuntimeException |
| | | { |
| | | this.trusted = trusted; |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public final boolean isTrusted() |
| | | { |
| | | return trusted; |
| | | } |
| | | |
| | | @Override |
| | | public final boolean getMaintainCount() |
| | | { |
| | | return maintainCount; |
| | |
| | | // Check whether any modifications apply to this indexed attribute. |
| | | if (isAttributeModified(index, mods)) |
| | | { |
| | | index.modifyEntry(buffer, entryID, oldEntry, newEntry, mods); |
| | | index.modifyEntry(buffer, entryID, oldEntry, newEntry); |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * Decorates a {@link Storage} with additional trace logging. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | final class TracedStorage implements Storage |
| | | { |
| | | /** |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Cursor openCursor(final TreeName name) |
| | | public Cursor<ByteString, ByteString> openCursor(final TreeName name) |
| | | { |
| | | final Cursor cursor = txn.openCursor(name); |
| | | final Cursor<ByteString, ByteString> cursor = txn.openCursor(name); |
| | | logger.trace("Storage@%s.ReadableStorage@%s.openCursor(%s, %s)", |
| | | storageId(), id(), backendId, name); |
| | | return cursor; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Cursor openCursor(final TreeName name) |
| | | public Cursor<ByteString, ByteString> openCursor(final TreeName name) |
| | | { |
| | | final Cursor cursor = txn.openCursor(name); |
| | | final Cursor<ByteString, ByteString> cursor = txn.openCursor(name); |
| | | logger.trace("Storage@%s.WriteableStorage@%s.openCursor(%s, %s)", |
| | | storageId(), id(), backendId, name); |
| | | return cursor; |
| | |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | | import static org.opends.messages.JebMessages.*; |
| | | import static org.opends.messages.BackendMessages.*; |
| | | import static org.opends.messages.JebMessages.*; |
| | | import static org.opends.server.backends.pluggable.EntryIDSet.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | * "tie-breaker" and ensures that keys correspond to one and only one entry. This ensures that all |
| | | * database updates can be performed using lock-free operations. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | class VLVIndex extends AbstractDatabaseContainer implements ConfigurationChangeListener<BackendVLVIndexCfg>, Closeable |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | |
| | | { |
| | | return evaluateVLVRequestByOffset(txn, searchOperation, vlvRequest, debugBuilder); |
| | | } |
| | | return evaluateVLVRequestByAssertion(txn, searchOperation, vlvRequest, debugBuilder); |
| | | return evaluateVLVRequestByAssertion(txn, searchOperation, vlvRequest); |
| | | } |
| | | return evaluateNonVLVRequest(txn, debugBuilder); |
| | | } |
| | | |
| | | private EntryIDSet evaluateNonVLVRequest(final ReadableTransaction txn, final StringBuilder debugBuilder) |
| | | { |
| | | final Cursor cursor = txn.openCursor(getName()); |
| | | final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName()); |
| | | try |
| | | { |
| | | final long[] selectedIDs = readRange(cursor, count.get(), debugBuilder); |
| | |
| | | * entries following the nearest entry. |
| | | */ |
| | | private EntryIDSet evaluateVLVRequestByAssertion(final ReadableTransaction txn, |
| | | final SearchOperation searchOperation, final VLVRequestControl vlvRequest, final StringBuilder debugBuilder) |
| | | final SearchOperation searchOperation, final VLVRequestControl vlvRequest) |
| | | throws DirectoryException |
| | | { |
| | | final int currentCount = count.get(); |
| | |
| | | final ByteString assertion = vlvRequest.getGreaterThanOrEqualAssertion(); |
| | | final ByteSequence encodedTargetAssertion = |
| | | encodeTargetAssertion(sortOrder, assertion, searchOperation, currentCount); |
| | | @SuppressWarnings("unchecked") |
| | | final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName()); |
| | | try |
| | | { |
| | |
| | | } |
| | | |
| | | final int count = 1 + beforeCount + afterCount; |
| | | final Cursor cursor = txn.openCursor(getName()); |
| | | final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName()); |
| | | try |
| | | { |
| | | final long[] selectedIDs; |
| | |
| | | * the tree name |
| | | * @return a new cursor |
| | | */ |
| | | Cursor openCursor(TreeName treeName); |
| | | Cursor<ByteString, ByteString> openCursor(TreeName treeName); |
| | | |
| | | /** |
| | | * Returns the number of key/value pairs in the provided tree. |