mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
12.45.2014 f62c39ffa948c06d92702924bb33e435c6c6f529
Code cleanup


AttributeIndex.java:
In substringKeys(), simplified reading the code a bit.

State.java:
In putIndexTrustState(), changed return type to void (return value was never used).

DN2ID.java:
Removed never used put(Transaction, DN, EntryID) method.
3 files modified
42 ■■■■ changed files
opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java 15 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/DN2ID.java 20 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/State.java 7 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/backends/jeb/AttributeIndex.java
@@ -372,19 +372,19 @@
  }
  /**
   * Makes a byte array representing a substring index key for
   * Makes a byte string representing a substring index key for
   * one substring of a value.
   *
   * @param bytes The byte array containing the value.
   * @param pos The starting position of the substring.
   * @param len The length of the substring.
   * @return A byte array containing a substring key.
   * @return A byte string containing a substring key.
   */
  private byte[] makeSubstringKey(byte[] bytes, int pos, int len)
  private ByteString makeSubstringKey(byte[] bytes, int pos, int len)
  {
    byte[] keyBytes = new byte[len];
    System.arraycopy(bytes, pos, keyBytes, 0, len);
    return keyBytes;
    return ByteString.wrap(keyBytes);
  }
  /**
@@ -411,15 +411,12 @@
    // We produce the keys ABC BCD CDE DE E
    // To find values containing a short substring such as DE,
    // iterate through keys with prefix DE. To find values
    // containing a longer substring such as BCDE, read keys
    // BCD and CDE.
    // containing a longer substring such as BCDE, read keys BCD and CDE.
    for (int i = 0, remain = value.length; remain > 0; i++, remain--)
    {
      int len = Math.min(substrLength, remain);
      byte[] keyBytes = makeSubstringKey(value, i, len);
      set.add(ByteString.wrap(keyBytes));
      set.add(makeSubstringKey(value, i, len));
    }
    return set;
  }
opendj3-server-dev/src/server/org/opends/server/backends/jeb/DN2ID.java
@@ -90,26 +90,6 @@
  }
  /**
   * Write a record to the DN database.  If a record with the given key already
   * exists, the record will be replaced, otherwise a new record will be
   * inserted.
   * @param txn A JE database transaction to be used for the database operation,
   * or null if none.
   * @param dn The entry DN, which is the key to the record.
   * @param id The entry ID, which is the value of the record.
   * @return true if the record was written, false if it was not written.
   * @throws DatabaseException If an error occurred while attempting to write
   * the record.
   */
  public boolean put(Transaction txn, DN dn, EntryID id) throws DatabaseException
  {
    DatabaseEntry key = new DatabaseEntry(dnToDNKey(dn, prefixRDNComponents));
    DatabaseEntry data = id.getDatabaseEntry();
    return put(txn, key, data) == SUCCESS;
  }
  /**
   * 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,
opendj3-server-dev/src/server/org/opends/server/backends/jeb/State.java
@@ -118,19 +118,16 @@
   * @param txn The database transaction or null if none.
   * @param index The index storing the trusted state info.
   * @param trusted The state value to put into the database.
   * @return true if the entry was written, false if it was not.
   * @throws DatabaseException If an error occurs in the JE database.
   */
  public boolean putIndexTrustState(Transaction txn, DatabaseContainer index,
                                    boolean trusted)
  public void putIndexTrustState(Transaction txn, DatabaseContainer index, boolean trusted)
       throws DatabaseException
  {
    DatabaseEntry key = keyForIndex(index);
    DatabaseEntry data = new DatabaseEntry();
    data.setData(trusted ? trueBytes : falseBytes);
    return put(txn, key, data) == SUCCESS;
    put(txn, key, data);
  }
}