Yuti-G commented on code in PR #914:
URL: https://github.com/apache/lucene/pull/914#discussion_r899773538


##########
lucene/facet/src/java/org/apache/lucene/facet/LongValueFacetCounts.java:
##########
@@ -346,6 +346,43 @@ private void increment(long value) {
     }
   }
 
+  @Override
+  public FacetResult getAllChildren(String dim, String... path) throws 
IOException {
+    if (dim.equals(field) == false) {
+      throw new IllegalArgumentException(
+          "invalid dim \"" + dim + "\"; should be \"" + field + "\"");
+    }
+    if (path.length != 0) {
+      throw new IllegalArgumentException("path.length should be 0");
+    }
+
+    List<LabelAndValue> labelValues = new ArrayList<>();
+    boolean countsAdded = false;
+    if (hashCounts.size() != 0) {
+      for (LongIntCursor c : hashCounts) {
+        int count = c.value;
+        if (count != 0) {
+          if (countsAdded == false && c.key >= counts.length) {
+            countsAdded = true;
+            appendCounts(labelValues);
+          }
+          labelValues.add(new LabelAndValue(Long.toString(c.key), count));
+        }
+      }
+    }
+
+    if (countsAdded == false) {
+      appendCounts(labelValues);
+    }
+
+    return new FacetResult(
+        field,
+        new String[0],
+        totCount,
+        labelValues.toArray(new LabelAndValue[0]),
+        labelValues.size());

Review Comment:
   Thank you so much for providing a simplified logic here!



-- 
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-unsubscr...@lucene.apache.org

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


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

Reply via email to