diff --git a/solr/core/src/java/org/apache/solr/search/facet/BitmapFrequencyCounter.java b/solr/core/src/java/org/apache/solr/search/facet/BitmapFrequencyCounter.java index ad34bf6c1612..bcb0cda51513 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/BitmapFrequencyCounter.java +++ b/solr/core/src/java/org/apache/solr/search/facet/BitmapFrequencyCounter.java @@ -65,12 +65,10 @@ public void add(int value) { bitmap = bitmaps[i] = new RoaringBitmap(); } - if (!bitmap.contains(value)) { + if (!bitmap.checkedRemove(value)) { bitmap.add(value); return; } - - bitmap.remove(value); } // If we reach this point, the frequency of this value is >= 2^(bitmaps.length) @@ -234,7 +232,7 @@ public BitmapFrequencyCounter merge(BitmapFrequencyCounter other) { int freq = 1 << bitmaps.length; for (int k = 0; k < bitmaps.length; k++) { - if (bitmaps[j].contains(value)) { + if (bitmaps[k].checkedRemove(value)) { freq += 1 << k; } }