You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2013/02/10 09:54:50 UTC
svn commit: r1444512 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/facet/ lucene/facet/src/java/org/apache/lucene/facet/sampling/
lucene/facet/src/java/org/apache/lucene/facet/search/
lucene/facet/src/java/org/apache/lucene/facet/util/
Author: shaie
Date: Sun Feb 10 08:54:50 2013
New Revision: 1444512
URL: http://svn.apache.org/r1444512
Log:
LUCENE-4759: remove FacetRequest.SortBy
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/lucene/facet/ (props changed)
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/sampling/Sampler.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/DepthOneFacetResultsHandler.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetRequest.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetsAccumulator.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/ResultSortUtils.java
Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1444512&r1=1444511&r2=1444512&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Sun Feb 10 08:54:50 2013
@@ -54,6 +54,9 @@ Changes in backwards compatibility polic
* LUCENE-4750: Convert DrillDown to DrillDownQuery, so you can initialize it
and add drill-down categories to it. (Michael McCandless, Shai Erera)
+* LUCENE-4759: remove FacetRequest.SortBy; result categories are always
+ sorted by value, while ties are broken by category ordinal. (Shai Erera)
+
Optimizations
* LUCENE-4687: BloomFilterPostingsFormat now lazily initializes delegate
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/sampling/Sampler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/sampling/Sampler.java?rev=1444512&r1=1444511&r2=1444512&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/sampling/Sampler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/sampling/Sampler.java Sun Feb 10 08:54:50 2013
@@ -222,7 +222,6 @@ public abstract class Sampler {
setDepth(orig.getDepth());
setNumLabel(orig.getNumLabel());
setResultMode(orig.getResultMode());
- setSortBy(orig.getSortBy());
setSortOrder(orig.getSortOrder());
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/DepthOneFacetResultsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/DepthOneFacetResultsHandler.java?rev=1444512&r1=1444511&r2=1444512&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/DepthOneFacetResultsHandler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/DepthOneFacetResultsHandler.java Sun Feb 10 08:54:50 2013
@@ -6,7 +6,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
-import org.apache.lucene.facet.search.FacetRequest.SortBy;
import org.apache.lucene.facet.search.FacetRequest.SortOrder;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.ParallelTaxonomyArrays;
@@ -65,7 +64,6 @@ public abstract class DepthOneFacetResul
assert facetRequest.getDepth() == 1 : "this handler only computes the top-K facets at depth 1";
assert facetRequest.numResults == facetRequest.getNumLabel() : "this handler always labels all top-K results";
assert facetRequest.getSortOrder() == SortOrder.DESCENDING : "this handler always sorts results in descending order";
- assert facetRequest.getSortBy() == SortBy.VALUE : "this handler always sorts results by value";
}
/** Returnt the value of the requested ordinal. Called once for the result root. */
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetRequest.java?rev=1444512&r1=1444511&r2=1444512&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetRequest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetRequest.java Sun Feb 10 08:54:50 2013
@@ -63,15 +63,6 @@ public abstract class FacetRequest {
*/
public enum FacetArraysSource { INT, FLOAT, BOTH }
- /** Sort options for facet results. */
- public enum SortBy {
- /** sort by category ordinal with the taxonomy */
- ORDINAL,
-
- /** sort by computed category value */
- VALUE
- }
-
/** Requested sort order for the results. */
public enum SortOrder { ASCENDING, DESCENDING }
@@ -82,12 +73,6 @@ public abstract class FacetRequest {
public static final int DEFAULT_DEPTH = 1;
/**
- * Default sort mode.
- * @see #getSortBy()
- */
- public static final SortBy DEFAULT_SORT_BY = SortBy.VALUE;
-
- /**
* Default result mode
* @see #getResultMode()
*/
@@ -99,7 +84,6 @@ public abstract class FacetRequest {
private int numLabel;
private int depth;
private SortOrder sortOrder;
- private SortBy sortBy;
/**
* Computed at construction, this hashCode is based on two final members
@@ -135,7 +119,6 @@ public abstract class FacetRequest {
this.numResults = numResults;
numLabel = numResults;
depth = DEFAULT_DEPTH;
- sortBy = DEFAULT_SORT_BY;
sortOrder = SortOrder.DESCENDING;
hashCode = categoryPath.hashCode() ^ this.numResults;
@@ -221,11 +204,6 @@ public abstract class FacetRequest {
return resultMode;
}
- /** Specify how should results be sorted. */
- public final SortBy getSortBy() {
- return sortBy;
- }
-
/** Return the requested order of results. */
public final SortOrder getSortOrder() {
return sortOrder;
@@ -276,10 +254,6 @@ public abstract class FacetRequest {
this.resultMode = resultMode;
}
- public void setSortBy(SortBy sortBy) {
- this.sortBy = sortBy;
- }
-
public void setSortOrder(SortOrder sortOrder) {
this.sortOrder = sortOrder;
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetsAccumulator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetsAccumulator.java?rev=1444512&r1=1444511&r2=1444512&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetsAccumulator.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetsAccumulator.java Sun Feb 10 08:54:50 2013
@@ -13,7 +13,6 @@ import org.apache.lucene.facet.params.Fa
import org.apache.lucene.facet.params.CategoryListParams.OrdinalPolicy;
import org.apache.lucene.facet.search.FacetRequest.FacetArraysSource;
import org.apache.lucene.facet.search.FacetRequest.ResultMode;
-import org.apache.lucene.facet.search.FacetRequest.SortBy;
import org.apache.lucene.facet.search.FacetRequest.SortOrder;
import org.apache.lucene.facet.search.FacetsCollector.MatchingDocs;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
@@ -99,7 +98,7 @@ public class FacetsAccumulator {
* {@link FacetRequest}.
*/
protected FacetResultsHandler createFacetResultsHandler(FacetRequest fr) {
- if (fr.getDepth() == 1 && fr.getSortOrder() == SortOrder.DESCENDING && fr.getSortBy() == SortBy.VALUE) {
+ if (fr.getDepth() == 1 && fr.getSortOrder() == SortOrder.DESCENDING) {
FacetArraysSource fas = fr.getFacetArraysSource();
if (fas == FacetArraysSource.INT) {
return new IntFacetResultsHandler(taxonomyReader, fr, facetArrays);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java?rev=1444512&r1=1444511&r2=1444512&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKInEachNodeHandler.java Sun Feb 10 08:54:50 2013
@@ -38,12 +38,8 @@ import org.apache.lucene.util.PriorityQu
* {@link FacetRequest#categoryPath}, and the enumerated children,
* {@link FacetResultNode#subResults}, of each node in that {@link FacetResult}
* are the top K ( = {@link FacetRequest#numResults}) among its children in the
- * taxonomy. Top in the sense {@link FacetRequest#getSortBy()}, which can be by
- * the values aggregated in the count arrays, or by ordinal numbers; also
- * specified is the sort order, {@link FacetRequest#getSortOrder()}, ascending
- * or descending, of these values or ordinals before their top K are selected.
- * The depth (number of levels excluding the root) of the {@link FacetResult}
- * tree is specified by {@link FacetRequest#getDepth()}.
+ * taxonomy. The depth (number of levels excluding the root) of the
+ * {@link FacetResult} tree is specified by {@link FacetRequest#getDepth()}.
* <p>
* Because the number of selected children of each node is restricted, and not
* the overall number of nodes in the {@link FacetResult}, facets not selected
@@ -536,21 +532,10 @@ public class TopKInEachNodeHandler exten
private ACComparator getSuitableACComparator() {
if (facetRequest.getSortOrder() == SortOrder.ASCENDING) {
- switch (facetRequest.getSortBy()) {
- case VALUE:
- return new AscValueACComparator();
- case ORDINAL:
- return new AscOrdACComparator();
- }
+ return new AscValueACComparator();
} else {
- switch (facetRequest.getSortBy()) {
- case VALUE:
- return new DescValueACComparator();
- case ORDINAL:
- return new DescOrdACComparator();
- }
+ return new DescValueACComparator();
}
- return null;
}
/**
@@ -584,26 +569,6 @@ public class TopKInEachNodeHandler exten
}
}
- private static final class AscOrdACComparator extends ACComparator {
-
- AscOrdACComparator() { }
-
- @Override
- protected boolean leftGoesNow (int ord1, double val1, int ord2, double val2) {
- return (ord1 < ord2);
- }
- }
-
- private static final class DescOrdACComparator extends ACComparator {
-
- DescOrdACComparator() { }
-
- @Override
- protected boolean leftGoesNow (int ord1, double val1, int ord2, double val2) {
- return (ord1 > ord2);
- }
- }
-
/**
* Intermediate result to hold counts from one or more partitions processed
* thus far. Its main field, constructor parameter <i>mapToAACOs</i>, is a map
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/ResultSortUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/ResultSortUtils.java?rev=1444512&r1=1444511&r2=1444512&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/ResultSortUtils.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/ResultSortUtils.java Sun Feb 10 08:54:50 2013
@@ -49,21 +49,10 @@ public class ResultSortUtils {
}
if (accending) {
- switch (facetRequest.getSortBy()) {
- case VALUE:
- return new MaxValueHeap(nresults);
- case ORDINAL:
- return new MaxOrdinalHeap(nresults);
- }
+ return new MaxValueHeap(nresults);
} else {
- switch (facetRequest.getSortBy()) {
- case VALUE:
- return new MinValueHeap(nresults);
- case ORDINAL:
- return new MinOrdinalHeap(nresults);
- }
+ return new MinValueHeap(nresults);
}
- throw new IllegalArgumentException("none supported facet request: "+facetRequest);
}
private static class MinValueHeap extends PriorityQueue<FacetResultNode> implements Heap<FacetResultNode> {
@@ -105,30 +94,6 @@ public class ResultSortUtils {
}
}
- private static class MinOrdinalHeap extends PriorityQueue<FacetResultNode> implements Heap<FacetResultNode> {
- public MinOrdinalHeap(int size) {
- super(size);
- }
-
- @Override
- protected boolean lessThan(FacetResultNode arg0, FacetResultNode arg1) {
- return arg0.ordinal < arg1.ordinal;
- }
-
- }
-
- private static class MaxOrdinalHeap extends PriorityQueue<FacetResultNode> implements Heap<FacetResultNode> {
- public MaxOrdinalHeap(int size) {
- super(size);
- }
-
- @Override
- protected boolean lessThan(FacetResultNode arg0, FacetResultNode arg1) {
- return arg0.ordinal > arg1.ordinal;
- }
-
- }
-
/**
* Create a Heap-Look-Alike, which implements {@link Heap}, but uses a
* regular <code>ArrayList</code> for holding <b>ALL</b> the objects given,