activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r901763 - in /activemq/trunk: activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java kahadb/src/main/java/org/apache/kahadb/index/BTreeIndex.java kahadb/src/main/java/org/apache/kahadb/index/BTreeNode.java
Date Thu, 21 Jan 2010 16:37:37 GMT
Author: chirino
Date: Thu Jan 21 16:37:37 2010
New Revision: 901763

URL: http://svn.apache.org/viewvc?rev=901763&view=rev
Log:
Adding a isEmpty() method to the btree indexes..  related to the fix created for AMQ-2512

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/BTreeIndex.java
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/BTreeNode.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java?rev=901763&r1=901762&r2=901763&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java
Thu Jan 21 16:37:37 2010
@@ -207,13 +207,7 @@
                     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);
                     }
                 });
             }

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/BTreeIndex.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/BTreeIndex.java?rev=901763&r1=901762&r2=901763&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/BTreeIndex.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/BTreeIndex.java Thu Jan 21
16:37:37 2010
@@ -220,6 +220,10 @@
         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);
     }

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/BTreeNode.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/BTreeNode.java?rev=901763&r1=901762&r2=901763&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/BTreeNode.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/index/BTreeNode.java Thu Jan 21
16:37:37 2010
@@ -507,6 +507,10 @@
         }
     }
     
+    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");



Mime
View raw message