From d2572ceaee84a14d383c05c73d4c7ce2b4e5487b Mon Sep 17 00:00:00 2001 From: Alan Protasio Date: Wed, 19 Sep 2018 12:20:59 -0700 Subject: [PATCH] AMQ-7055 - Optimization on SequenceSet to prevent iterating through the whole set when a value bigger than the last value is added Signed-off-by: gtully (cherry picked from commit 8f88dcda09760df3aba3306f49a3311fb22a654f) --- .../store/kahadb/disk/util/Sequence.java | 4 +++ .../store/kahadb/disk/util/SequenceSet.java | 7 +++++ .../kahadb/disk/util/SequenceSetTest.java | 31 +++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/Sequence.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/Sequence.java index f52931bd25..25e594b1df 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/Sequence.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/Sequence.java @@ -38,6 +38,10 @@ public class Sequence extends LinkedNode { return last + 1 == value; } + public boolean isBiggerButNotAdjacentToLast(long value) { + return last + 1 < value; + } + public boolean isAdjacentToFirst(long value) { return first - 1 == value; } diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/SequenceSet.java b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/SequenceSet.java index 2946a223c2..fac831bf70 100644 --- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/SequenceSet.java +++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/disk/util/SequenceSet.java @@ -114,6 +114,13 @@ public class SequenceSet extends LinkedNodeList implements Iterable