You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/09/09 19:35:00 UTC

[GitHub] [lucene] mdmarshmallow commented on a change in pull request #288: LUCENE 10080 Added FixedBitSet for one counts when counting taxonomy facet labels

mdmarshmallow commented on a change in pull request #288:
URL: https://github.com/apache/lucene/pull/288#discussion_r705638799



##########
File path: lucene/facet/src/java/org/apache/lucene/facet/taxonomy/IntTaxonomyFacets.java
##########
@@ -253,4 +257,78 @@ public FacetResult getTopChildren(int topN, String dim, String... path) throws I
 
     return new FacetResult(dim, path, totValue, labelValues, childCount);
   }
+
+  /**
+   * Class that uses FixedBitSet to store counts for all ordinals with 1 count and IntIntHashMap for
+   * all other counts
+   */
+  private static class IntIntHashMapWithFixedBitSet implements Iterable<IntIntCursor> {
+    // if the key exists, fixedBitSet[key] will be true, if fixedBitSet[key] is true but the key in
+    // intIntHashMap
+    // does not exist, then the value is 1
+    private final FixedBitSet fixedBitSet;
+    private final IntIntHashMap intIntHashMap;
+
+    IntIntHashMapWithFixedBitSet(int numCategories) {
+      fixedBitSet = new FixedBitSet(numCategories);
+      intIntHashMap = new IntIntHashMap();
+    }
+
+    public int addTo(int key, int incrementValue) {
+      if (!fixedBitSet.getAndSet(key) && incrementValue == 1) {

Review comment:
       Will change that.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org