epotyom commented on code in PR #13568:
URL: https://github.com/apache/lucene/pull/13568#discussion_r1692792372


##########
lucene/sandbox/src/java/org/apache/lucene/sandbox/facet/ComparableUtils.java:
##########
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.sandbox.facet;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.lucene.sandbox.facet.ordinals.OrdToComparable;
+import org.apache.lucene.sandbox.facet.ordinals.OrdinalGetter;
+import org.apache.lucene.sandbox.facet.recorders.CountFacetRecorder;
+import org.apache.lucene.sandbox.facet.recorders.LongAggregationsFacetRecorder;
+import org.apache.lucene.util.InPlaceMergeSorter;
+
+/**
+ * Collection of static methods to provide most common comparables for sandbox 
faceting. You can
+ * also use it as an example for creating your own {@link OrdToComparable} to 
enable custom facets
+ * top-n and sorting.
+ */
+public class ComparableUtils {

Review Comment:
   > I really struggled with the naming of these static methods. I'm going to 
propose some alternatives here. Maybe there's something else even better?
   >     * ordToComparableOrd -> byOrdinal
   >     * ordToComparableCountOrd -> byCount
   >     * ordToComparableRankCountOrd -> byAggregatedValue
   
   I like the proposal! The only thing I'm not sure about is that we don't 
mention tie-breaking logic in the names. For me as a user it might be important 
to have it right there in the name, e.g. it might not be obvious that 
`byAggregatedValue` tie-breaks by count. At the same time shorter, more concise 
names do look appealing to me. I'll summon @Shradha26 and @stefanvodita again, 
I always struggle with naming.
   
   
   > If you feel OK with a different naming strategy, here might be some 
alternative class names as well:
   >     * ComparableOrd -> ByOrdinalComparable
   >     * ComparableIntOrd -> ByCountComparable (yes, I know it's more generic 
than just count, but I can't really imagine other use-cases...)
   >     * ComparableLongIntOrd -> ByAggregatedValueComparable (same 
justification as above...)
   
   Sounds good to me too! Same comment about tie-breaking applies though. As 
for other use case, I agree. Worst case scenario we need to create a copy of 
this class with a different name if/when there is a use case; but these classes 
are very small so I think we'll be fine.
   
   > Also, as one last comment, should we make the comparator classes final? If 
users need custom comparison logic, I suspect they'll create their own factory 
and comparator classes from scratch. Not sure these need to be extension points.
   
   I agree - users could extend them to e.g. change the order from descending 
to ascending, but I agree that it's safer to lock extension - creating custom 
comparator from scratch shouldn't be a big deal for users.
   
   



-- 
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