You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2023/03/06 21:05:54 UTC
[lucene] branch branch_9x updated: Remove LongValueFacetCounts#getTopChildrenSortByCount since it provides redundant functionality (#11744)
This is an automated email from the ASF dual-hosted git repository.
gsmiller pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 52ff5c51e35 Remove LongValueFacetCounts#getTopChildrenSortByCount since it provides redundant functionality (#11744)
52ff5c51e35 is described below
commit 52ff5c51e3574b88ea6b285c700f75c531c69f97
Author: Greg Miller <gs...@gmail.com>
AuthorDate: Mon Mar 6 12:12:23 2023 -0800
Remove LongValueFacetCounts#getTopChildrenSortByCount since it provides redundant functionality (#11744)
---
lucene/CHANGES.txt | 2 ++
.../apache/lucene/facet/LongValueFacetCounts.java | 22 ++++++++++++++++++----
.../lucene/facet/TestLongValueFacetCounts.java | 8 ++++----
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 1ae1fa30d7b..193f1731626 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -18,6 +18,8 @@ API Changes
* GITHUB#12173: TermInSetQuery#getTermData has been deprecated. This exposes internal implementation details that we
may want to change in the future, and users shouldn't rely on the encoding directly. (Greg Miller)
+* GITHUB#11746: Deprecate LongValueFacetCounts#getTopChildrenSortByCount. (Greg Miller)
+
New Features
---------------------
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/LongValueFacetCounts.java b/lucene/facet/src/java/org/apache/lucene/facet/LongValueFacetCounts.java
index 0a4a7514fb9..edbe2b696f6 100644
--- a/lucene/facet/src/java/org/apache/lucene/facet/LongValueFacetCounts.java
+++ b/lucene/facet/src/java/org/apache/lucene/facet/LongValueFacetCounts.java
@@ -42,8 +42,9 @@ import org.apache.lucene.util.PriorityQueue;
* {@link Facets} implementation that computes counts for all unique long values, more efficiently
* counting small values (0-1023) using an int array, and switching to a <code>HashMap</code> for
* values above 1023. Retrieve all facet counts, in value order, with {@link
- * #getAllChildrenSortByValue}, or get the topN values sorted by count with {@link
- * #getTopChildrenSortByCount}.
+ * #getAllChildrenSortByValue}, or get all children with no ordering requirements with {@link
+ * #getAllChildren(String, String...)}, or get the topN values sorted by count with {@link
+ * #getTopChildren(int, String, String...)}.
*
* @lucene.experimental
*/
@@ -385,7 +386,13 @@ public class LongValueFacetCounts extends Facets {
long value;
}
- /** Returns the specified top number of facets, sorted by count. */
+ /**
+ * Returns the specified top number of facets, sorted by count.
+ *
+ * @deprecated Please use {@link #getTopChildren(int, String, String...)} instead for the same
+ * functionality.
+ */
+ @Deprecated
public FacetResult getTopChildrenSortByCount(int topN) {
PriorityQueue<Entry> pq =
new PriorityQueue<>(Math.min(topN, counts.length + hashCounts.size())) {
@@ -434,7 +441,14 @@ public class LongValueFacetCounts extends Facets {
return new FacetResult(field, new String[0], totCount, results, childCount);
}
- /** Returns all unique values seen, sorted by value. */
+ /**
+ * Returns all unique values seen, sorted by value. This functionality is very similar to {@link
+ * #getAllChildren(String, String...)}, but it guarantees the returned values will be sorted by
+ * value (while {@code #getAllChildren} doesn't guarantee any sort order).
+ *
+ * <p>Note: If you don't care about the order of children returned, it may be slightly more
+ * efficient to use {@link #getAllChildren(String, String...)}.
+ */
public FacetResult getAllChildrenSortByValue() {
List<LabelAndValue> labelValues = new ArrayList<>();
diff --git a/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java b/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java
index b68c3e14c73..58c232c8c6e 100644
--- a/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java
+++ b/lucene/facet/src/test/org/apache/lucene/facet/TestLongValueFacetCounts.java
@@ -399,7 +399,7 @@ public class TestLongValueFacetCounts extends FacetTestCase {
if (VERBOSE) {
System.out.println(" topN=" + topN);
}
- actual = facetCounts.getTopChildrenSortByCount(topN);
+ actual = facetCounts.getTopChildren(topN, "field");
assertSame(
"all docs, sort facets by count",
expectedCounts,
@@ -488,7 +488,7 @@ public class TestLongValueFacetCounts extends FacetTestCase {
} else {
topN = random().nextInt(docCount);
}
- actual = facetCounts.getTopChildrenSortByCount(topN);
+ actual = facetCounts.getTopChildren(topN, "field");
assertSame(
"id " + minId + "-" + maxId + ", sort facets by count",
expectedCounts,
@@ -662,7 +662,7 @@ public class TestLongValueFacetCounts extends FacetTestCase {
if (VERBOSE) {
System.out.println(" topN=" + topN);
}
- actual = facetCounts.getTopChildrenSortByCount(topN);
+ actual = facetCounts.getTopChildren(topN, "field");
assertSame(
"all docs, sort facets by count",
expectedCounts,
@@ -729,7 +729,7 @@ public class TestLongValueFacetCounts extends FacetTestCase {
} else {
topN = random().nextInt(docCount);
}
- actual = facetCounts.getTopChildrenSortByCount(topN);
+ actual = facetCounts.getTopChildren(topN, "field");
assertSame(
"id " + minId + "-" + maxId + ", sort facets by count",
expectedCounts,