| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Clear the contents for a attribute index from disk. |
| | | * |
| | | * @param index The attribute index to clear. |
| | | * @return The number of records deleted. |
| | | * @throws DatabaseException if a JE database error occurs. |
| | | */ |
| | | public long clearAttributeIndex(AttributeIndex index) |
| | | throws DatabaseException |
| | | { |
| | | long count = 0; |
| | | |
| | | index.close(); |
| | | try |
| | | { |
| | | if(env.getConfig().getTransactional()) |
| | | { |
| | | Transaction txn = beginTransaction(); |
| | | try |
| | | { |
| | | if(index.equalityIndex != null) |
| | | { |
| | | count += env.truncateDatabase(txn, index.equalityIndex.getName(), |
| | | true); |
| | | } |
| | | if(index.presenceIndex != null) |
| | | { |
| | | count += env.truncateDatabase(txn, index.presenceIndex.getName(), |
| | | true); |
| | | } |
| | | if(index.substringIndex != null) |
| | | { |
| | | count += env.truncateDatabase(txn, index.substringIndex.getName(), |
| | | true); |
| | | } |
| | | if(index.orderingIndex != null) |
| | | { |
| | | count += env.truncateDatabase(txn, index.orderingIndex.getName(), |
| | | true); |
| | | } |
| | | if(index.approximateIndex != null) |
| | | { |
| | | count += env.truncateDatabase(txn, index.approximateIndex.getName(), |
| | | true); |
| | | } |
| | | transactionCommit(txn); |
| | | } |
| | | catch(DatabaseException de) |
| | | { |
| | | transactionAbort(txn); |
| | | throw de; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if(index.equalityIndex != null) |
| | | { |
| | | count += env.truncateDatabase(null, index.equalityIndex.getName(), |
| | | true); |
| | | } |
| | | if(index.presenceIndex != null) |
| | | { |
| | | count += env.truncateDatabase(null, index.presenceIndex.getName(), |
| | | true); |
| | | } |
| | | if(index.substringIndex != null) |
| | | { |
| | | count += env.truncateDatabase(null, index.substringIndex.getName(), |
| | | true); |
| | | } |
| | | if(index.orderingIndex != null) |
| | | { |
| | | count += env.truncateDatabase(null, index.orderingIndex.getName(), |
| | | true); |
| | | } |
| | | if(index.approximateIndex != null) |
| | | { |
| | | count += env.truncateDatabase(null, index.approximateIndex.getName(), |
| | | true); |
| | | } |
| | | } |
| | | } |
| | | finally |
| | | { |
| | | index.open(); |
| | | } |
| | | if(debugEnabled()) |
| | | { |
| | | TRACER.debugVerbose("Cleared %d existing records from the " + |
| | | "index %s", count, index.getAttributeType().getNameOrOID()); |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Finds an existing entry whose DN is the closest ancestor of a given baseDN. |