mirror of https://github.com/apache/activemq.git
Adding a isEmpty() method to the btree indexes.. related to the fix created for AMQ-2512
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@901763 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
36770e727d
commit
a33d6684eb
|
@ -207,13 +207,7 @@ public class KahaDBStore extends MessageDatabase implements PersistenceAdapter {
|
|||
public Boolean execute(Transaction tx) throws IOException {
|
||||
// Iterate through all index entries to get a count of messages in the destination.
|
||||
StoredDestination sd = getStoredDestination(dest, tx);
|
||||
boolean result = true;
|
||||
for (Iterator<Entry<Location, Long>> iterator = sd.locationIndex.iterator(tx); iterator.hasNext();) {
|
||||
iterator.next();
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
return sd.locationIndex.isEmpty(tx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -220,6 +220,10 @@ public class BTreeIndex<Key,Value> implements Index<Key,Value> {
|
|||
pw.flush();
|
||||
}
|
||||
|
||||
synchronized public boolean isEmpty(final Transaction tx) throws IOException {
|
||||
return getRoot(tx).isEmpty(tx);
|
||||
}
|
||||
|
||||
synchronized public Iterator<Map.Entry<Key,Value>> iterator(final Transaction tx) throws IOException {
|
||||
return getRoot(tx).iterator(tx);
|
||||
}
|
||||
|
|
|
@ -507,6 +507,10 @@ public final class BTreeNode<Key,Value> {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty(final Transaction tx) throws IOException {
|
||||
return keys.length==0;
|
||||
}
|
||||
|
||||
public void visit(Transaction tx, BTreeVisitor<Key, Value> visitor) throws IOException {
|
||||
if (visitor == null) {
|
||||
throw new IllegalArgumentException("Visitor cannot be null");
|
||||
|
|
Loading…
Reference in New Issue