OPENDJ-1855: minor code cleanup
* reduce visibility of methods
* remove unnecessary boilerplate Javadoc
* remove unnecessary method overrides
* add some comments explaining some subtle behavior when processing IndexBuffers.
| | |
| | | |
| | | import static org.opends.server.backends.pluggable.JebFormat.*; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.backends.pluggable.spi.ReadableStorage; |
| | | import org.opends.server.backends.pluggable.spi.Storage; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Write a record to the DN database, where the key and value are already |
| | | * formatted. |
| | | * |
| | | * @param txn |
| | | * A JE database transaction to be used for the database operation, |
| | | * or null if none. |
| | | * @param key |
| | | * A ByteString containing the record key. |
| | | * @param value |
| | | * A ByteString containing the record value. |
| | | * @throws StorageRuntimeException |
| | | * If an error occurred while attempting to write the record. |
| | | */ |
| | | @Override |
| | | public void put(WriteableStorage txn, ByteSequence key, ByteSequence value) throws StorageRuntimeException |
| | | { |
| | | super.put(txn, key, value); |
| | | } |
| | | |
| | | /** |
| | | * Remove a record from the DN database. |
| | | * @param txn A JE database transaction to be used for the database operation, |
| | | * or null if none. |
| | |
| | | * @return The entry ID, or null if the given DN is not in the DN database. |
| | | * @throws StorageRuntimeException If an error occurs in the JE database. |
| | | */ |
| | | public EntryID get(ReadableStorage txn, DN dn, boolean isRMW) throws StorageRuntimeException |
| | | EntryID get(ReadableStorage txn, DN dn, boolean isRMW) throws StorageRuntimeException |
| | | { |
| | | ByteString key = dnToDNKey(dn, prefixRDNComponents); |
| | | ByteString value = read(txn, key, isRMW); |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ByteString read(ReadableStorage txn, ByteSequence key, boolean isRMW) |
| | | { |
| | | return super.read(txn, key, isRMW); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Replace or insert a record into a JE database, with optional debug logging. |
| | | * This is a simple wrapper around the JE Database.put method. |
| | | * @param txn The JE transaction handle, or null if none. |
| | | * @param key The record key. |
| | | * @param value The record value. |
| | | * @throws StorageRuntimeException If an error occurs in the JE operation. |
| | | */ |
| | | void put(WriteableStorage txn, ByteSequence key, ByteSequence value) throws StorageRuntimeException |
| | | { |
| | | txn.create(treeName, key, value); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Read a record from a JE database, with optional debug logging. This is a |
| | | * simple wrapper around the JE Database.get method. |
| | | * @param txn The JE transaction handle, or null if none. |
| | | * @param key The key of the record to be read. |
| | | * @param isRMW whether the read operation is part of a larger read-modify-write operation |
| | | * @return The operation status. |
| | | * @throws StorageRuntimeException If an error occurs in the JE operation. |
| | | */ |
| | | ByteString read(ReadableStorage txn, ByteSequence key, boolean isRMW) throws StorageRuntimeException |
| | | { |
| | | ByteString value = isRMW ? txn.getRMW(treeName, key) : txn.read(treeName, key); |
| | |
| | | void updateKey(WriteableStorage txn, ByteString key, EntryIDSet deletedIDs, EntryIDSet addedIDs) |
| | | throws StorageRuntimeException |
| | | { |
| | | if(deletedIDs == null && addedIDs == null) |
| | | /* |
| | | * Check the special condition where both deletedIDs and addedIDs are null. This is used when |
| | | * deleting entries and corresponding id2children and id2subtree records must be completely |
| | | * removed. |
| | | */ |
| | | if (deletedIDs == null && addedIDs == null) |
| | | { |
| | | boolean success = delete(txn, key); |
| | | if (success && logger.isTraceEnabled()) |
| | |
| | | private final LinkedHashMap<VLVIndex, BufferedVLVIndexValues> bufferedVLVIndexes = |
| | | new LinkedHashMap<VLVIndex, BufferedVLVIndexValues>(); |
| | | |
| | | /** A simple class representing a pair of added and deleted indexed IDs. */ |
| | | /** |
| | | * A simple class representing a pair of added and deleted indexed IDs. Initially both addedIDs |
| | | * and deletedIDs are {@code null} indicating that that the whole record should be deleted. This |
| | | * state is only ever used when updating the id2children and id2subtree indexes when deleting an |
| | | * entry. |
| | | */ |
| | | static class BufferedIndexValues |
| | | { |
| | | private EntryIDSet addedIDs; |