From 21664a960963bb5767d941accb71e1f9aae172fb Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Tue, 23 Nov 2010 19:36:35 +0000 Subject: [PATCH] https://issues.apache.org/activemq/browse/AMQ-2695 - rework getMessageCount to just use the index, build on changes from - https://issues.apache.org/activemq/browse/AMQ-2985 git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1038296 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/store/kahadb/KahaDBStore.java | 29 ++++--------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java b/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java index 9954bee21b..9e2b206e79 100644 --- a/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java +++ b/activemq-core/src/main/java/org/apache/activemq/store/kahadb/KahaDBStore.java @@ -720,7 +720,6 @@ public class KahaDBStore extends MessageDatabase implements PersistenceAdapter { public int getMessageCount(String clientId, String subscriptionName) throws IOException { final String subscriptionKey = subscriptionKey(clientId, subscriptionName); - final SubscriptionInfo info = lookupSubscription(clientId, subscriptionName); indexLock.writeLock().lock(); try { return pageFile.tx().execute(new Transaction.CallableClosure() { @@ -733,30 +732,12 @@ public class KahaDBStore extends MessageDatabase implements PersistenceAdapter { } int counter = 0; - try { - String selector = info.getSelector(); - BooleanExpression selectorExpression = null; - if (selector != null) { - selectorExpression = SelectorParser.parse(selector); + for (Iterator>> iterator = + sd.ackPositions.iterator(tx, cursorPos.lastAckedSequence); iterator.hasNext();) { + Entry> entry = iterator.next(); + if (entry.getValue().contains(subscriptionKey)) { + counter++; } - sd.orderIndex.resetCursorPosition(); - sd.orderIndex.setBatch(tx, cursorPos); - for (Iterator> iterator = sd.orderIndex.iterator(tx); iterator - .hasNext();) { - Entry entry = iterator.next(); - if (selectorExpression != null) { - MessageEvaluationContext ctx = new MessageEvaluationContext(); - ctx.setMessageReference(loadMessage(entry.getValue().location)); - if (selectorExpression.matches(ctx)) { - counter++; - } - } else { - counter++; - } - } - sd.orderIndex.resetCursorPosition(); - } catch (Exception e) { - throw IOExceptionSupport.create(e); } return counter; }