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/01/21 12:29:02 UTC
svn commit: r1436281 [1/2] - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/facet/
lucene/facet/src/examples/org/apache/lucene/facet/example/simple/
lucene/facet/src/java/org/apache/lucene/facet/search/
lucene/facet/src/java/org/apache/lucene/fac...
Author: shaie
Date: Mon Jan 21 11:29:01 2013
New Revision: 1436281
URL: http://svn.apache.org/viewvc?rev=1436281&view=rev
Log:
LUCENE-4697: make FacetResultNode a simple bin
Removed:
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/results/MutableFacetResultNode.java
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/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/AdaptiveFacetsAccumulator.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetResultsHandler.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/SamplingWrapper.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKFacetResultsHandler.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/search/results/FacetResultNode.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/SamplingAccumulator.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/TakmiSampleFixer.java
lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/util/ResultSortUtils.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestAssociationExample.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestMultiCLExample.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestSimpleExample.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/OrdinalMappingReaderTest.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/TestFacetsPayloadMigrationReader.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestStandardFacetsAccumulator.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/associations/AssociationsFacetRequestTest.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/BaseSampleTestTopK.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/OversampleWithDepthTest.java
lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/sampling/SamplingAccumulatorTest.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=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Mon Jan 21 11:29:01 2013
@@ -14,6 +14,9 @@ Changes in backwards compatibility polic
support in-memory caching, CategoryListCache was removed too.
(Shai Erera, Michael McCandless)
+* LUCENE-4697: FacetResultNode is now a concrete class with public members
+ (instead of getter methods). (Shai Erera)
+
Optimizations
* LUCENE-4687: BloomFilterPostingsFormat now lazily initializes delegate
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/examples/org/apache/lucene/facet/example/simple/SimpleSearcher.java Mon Jan 21 11:29:01 2013
@@ -148,9 +148,9 @@ public class SimpleSearcher {
// assume the user is interested in the second sub-result
// (just take the second sub-result returned by the iterator - we know there are 3 results!)
- Iterator<? extends FacetResultNode> resIterator = fres.getFacetResultNode().getSubResults().iterator();
+ Iterator<? extends FacetResultNode> resIterator = fres.getFacetResultNode().subResults.iterator();
resIterator.next(); // skip first result
- CategoryPath categoryOfInterest = resIterator.next().getLabel();
+ CategoryPath categoryOfInterest = resIterator.next().label;
// drill-down preparation: turn the base query into a drill-down query for the category of interest
Query q2 = DrillDown.query(indexingParams, baseQuery, categoryOfInterest);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/AdaptiveFacetsAccumulator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/AdaptiveFacetsAccumulator.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/AdaptiveFacetsAccumulator.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/AdaptiveFacetsAccumulator.java Mon Jan 21 11:29:01 2013
@@ -37,8 +37,8 @@ import org.apache.lucene.index.IndexRead
* <p>
* Note: Sampling accumulation (Accumulation over a sampled-set of the results),
* does not guarantee accurate values for
- * {@link FacetResult#getNumValidDescendants()} &
- * {@link FacetResultNode#getResidue()}.
+ * {@link FacetResult#getNumValidDescendants()} and
+ * {@link FacetResultNode#residue}.
*
* @lucene.experimental
*/
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetResultsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetResultsHandler.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetResultsHandler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/FacetResultsHandler.java Mon Jan 21 11:29:01 2013
@@ -120,7 +120,7 @@ public abstract class FacetResultsHandle
* rendered facet results, fixed their counts, and now it is needed
* to sort the results differently according to the fixed counts.
* @param facetResult result to be rearranged.
- * @see FacetResultNode#setValue(double)
+ * @see FacetResultNode#value
*/
public abstract FacetResult rearrangeFacetResult(FacetResult facetResult);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/SamplingWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/SamplingWrapper.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/SamplingWrapper.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/SamplingWrapper.java Mon Jan 21 11:29:01 2013
@@ -32,8 +32,8 @@ import org.apache.lucene.facet.search.sa
* <p>
* Note: Sampling accumulation (Accumulation over a sampled-set of the results),
* does not guarantee accurate values for
- * {@link FacetResult#getNumValidDescendants()} &
- * {@link FacetResultNode#getResidue()}.
+ * {@link FacetResult#getNumValidDescendants()} and
+ * {@link FacetResultNode#residue}.
*
* @lucene.experimental
*/
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKFacetResultsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKFacetResultsHandler.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKFacetResultsHandler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/TopKFacetResultsHandler.java Mon Jan 21 11:29:01 2013
@@ -7,7 +7,6 @@ import org.apache.lucene.facet.search.pa
import org.apache.lucene.facet.search.results.FacetResult;
import org.apache.lucene.facet.search.results.FacetResultNode;
import org.apache.lucene.facet.search.results.IntermediateFacetResult;
-import org.apache.lucene.facet.search.results.MutableFacetResultNode;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.ParallelTaxonomyArrays;
import org.apache.lucene.facet.util.ResultSortUtils;
@@ -64,8 +63,7 @@ public class TopKFacetResultsHandler ext
}
// TODO (Facet): should initial value of "residue" depend on aggregator if not sum?
- MutableFacetResultNode parentResultNode =
- new MutableFacetResultNode(ordinal, value);
+ FacetResultNode parentResultNode = new FacetResultNode(ordinal, value);
Heap<FacetResultNode> heap = ResultSortUtils.createSuitableHeap(facetRequest);
int totalFacets = heapDescendants(ordinal, heap, parentResultNode, facetArrays, offset);
@@ -80,7 +78,7 @@ public class TopKFacetResultsHandler ext
public IntermediateFacetResult mergeResults(IntermediateFacetResult... tmpResults) throws IOException {
int ordinal = taxonomyReader.getOrdinal(facetRequest.categoryPath);
- MutableFacetResultNode resNode = new MutableFacetResultNode(ordinal, 0);
+ FacetResultNode resNode = new FacetResultNode(ordinal, 0);
int totalFacets = 0;
Heap<FacetResultNode> heap = null;
@@ -91,7 +89,7 @@ public class TopKFacetResultsHandler ext
TopKFacetResult fres = (TopKFacetResult) tmpFres;
totalFacets += fres.getNumValidDescendants();
// set the value for the result node representing the facet request
- resNode.increaseValue(fres.getFacetResultNode().getValue());
+ resNode.value += fres.getFacetResultNode().value;
Heap<FacetResultNode> tmpHeap = fres.getHeap();
if (heap == null) {
heap = tmpHeap;
@@ -102,7 +100,7 @@ public class TopKFacetResultsHandler ext
FacetResultNode a = heap.insertWithOverflow(tmpHeap.pop());
if (a != null) {
- resNode.increaseResidue(a.getResidue());
+ resNode.residue += a.residue;
}
}
}
@@ -119,8 +117,8 @@ public class TopKFacetResultsHandler ext
* they join the overall priority queue pq of size K.
* @return total number of descendants considered here by pq, excluding ordinal itself.
*/
- private int heapDescendants(int ordinal, Heap<FacetResultNode> pq,
- MutableFacetResultNode parentResultNode, FacetArrays facetArrays, int offset) throws IOException {
+ private int heapDescendants(int ordinal, Heap<FacetResultNode> pq, FacetResultNode parentResultNode,
+ FacetArrays facetArrays, int offset) throws IOException {
int partitionSize = facetArrays.arrayLength;
int endOffset = offset + partitionSize;
ParallelTaxonomyArrays childrenArray = taxonomyReader.getParallelTaxonomyArrays();
@@ -172,16 +170,20 @@ public class TopKFacetResultsHandler ext
if (value != 0 && !Double.isNaN(value)) {
// Count current ordinal -- the TOS
if (reusable == null) {
- reusable = new MutableFacetResultNode(tosOrdinal, value);
+ reusable = new FacetResultNode(tosOrdinal, value);
} else {
// it is safe to cast since reusable was created here.
- ((MutableFacetResultNode)reusable).reset(tosOrdinal, value);
+ reusable.ordinal = tosOrdinal;
+ reusable.value = value;
+ reusable.subResults.clear();
+ reusable.label = null;
+ reusable.residue = 0;
}
++childrenCounter;
reusable = pq.insertWithOverflow(reusable);
if (reusable != null) {
// TODO (Facet): is other logic (not add) needed, per aggregator?
- parentResultNode.increaseResidue(reusable.getValue());
+ parentResultNode.residue += reusable.value;
}
}
}
@@ -205,9 +207,12 @@ public class TopKFacetResultsHandler ext
TopKFacetResult res = (TopKFacetResult) tmpResult; // cast is safe by contract of this class
if (res != null) {
Heap<FacetResultNode> heap = res.getHeap();
- MutableFacetResultNode resNode = (MutableFacetResultNode)res.getFacetResultNode(); // cast safe too
+ FacetResultNode resNode = res.getFacetResultNode();
+ if (resNode.subResults == FacetResultNode.EMPTY_SUB_RESULTS) {
+ resNode.subResults = new ArrayList<FacetResultNode>();
+ }
for (int i = heap.size(); i > 0; i--) {
- resNode.insertSubResult(heap.pop());
+ resNode.subResults.add(0, heap.pop());
}
}
return res;
@@ -218,8 +223,8 @@ public class TopKFacetResultsHandler ext
TopKFacetResult res = (TopKFacetResult) facetResult; // cast is safe by contract of this class
Heap<FacetResultNode> heap = res.getHeap();
heap.clear(); // just to be safe
- MutableFacetResultNode topFrn = (MutableFacetResultNode) res.getFacetResultNode(); // safe cast
- for (FacetResultNode frn : topFrn.getSubResults()) {
+ FacetResultNode topFrn = res.getFacetResultNode();
+ for (FacetResultNode frn : topFrn.subResults) {
heap.add(frn);
}
int size = heap.size();
@@ -227,23 +232,22 @@ public class TopKFacetResultsHandler ext
for (int i = heap.size(); i > 0; i--) {
subResults.add(0,heap.pop());
}
- topFrn.setSubResults(subResults);
+ topFrn.subResults = subResults;
return res;
}
@Override
- // label top K sub results
public void labelResult(FacetResult facetResult) throws IOException {
if (facetResult != null) { // any result to label?
FacetResultNode facetResultNode = facetResult.getFacetResultNode();
if (facetResultNode != null) { // any result to label?
- facetResultNode.getLabel(taxonomyReader);
+ facetResultNode.label = taxonomyReader.getPath(facetResultNode.ordinal);
int num2label = facetRequest.getNumLabel();
- for (FacetResultNode frn : facetResultNode.getSubResults()) {
+ for (FacetResultNode frn : facetResultNode.subResults) {
if (--num2label < 0) {
break;
}
- frn.getLabel(taxonomyReader);
+ frn.label = taxonomyReader.getPath(frn.ordinal);
}
}
}
@@ -267,7 +271,7 @@ public class TopKFacetResultsHandler ext
* @param facetResultNode top result node for this facet result.
* @param totalFacets - number of children of the targetFacet, up till the requested depth.
*/
- TopKFacetResult(FacetRequest facetRequest, MutableFacetResultNode facetResultNode, int totalFacets) {
+ TopKFacetResult(FacetRequest facetRequest, FacetResultNode facetResultNode, int totalFacets) {
super(facetRequest, facetResultNode, totalFacets);
}
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=1436281&r1=1436280&r2=1436281&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 Mon Jan 21 11:29:01 2013
@@ -9,7 +9,6 @@ import org.apache.lucene.facet.search.pa
import org.apache.lucene.facet.search.results.FacetResult;
import org.apache.lucene.facet.search.results.FacetResultNode;
import org.apache.lucene.facet.search.results.IntermediateFacetResult;
-import org.apache.lucene.facet.search.results.MutableFacetResultNode;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.ParallelTaxonomyArrays;
import org.apache.lucene.util.PriorityQueue;
@@ -39,7 +38,7 @@ import org.apache.lucene.util.collection
* subtree of the taxonomy tree. Its root node,
* {@link FacetResult#getFacetResultNode()}, is the facet specified by
* {@link FacetRequest#categoryPath}, and the enumerated children,
- * {@link FacetResultNode#getSubResults()}, of each node in that
+ * {@link FacetResultNode#subResults}, of each node in that
* {@link FacetResult} are the top K ( = {@link FacetRequest#getNumResults()})
* among its children in the taxonomy. Top in the sense
* {@link FacetRequest#getSortBy()}, which can be by the values aggregated in
@@ -70,8 +69,7 @@ import org.apache.lucene.util.collection
*/
public class TopKInEachNodeHandler extends FacetResultsHandler {
- public TopKInEachNodeHandler(TaxonomyReader taxonomyReader,
- FacetRequest facetRequest) {
+ public TopKInEachNodeHandler(TaxonomyReader taxonomyReader, FacetRequest facetRequest) {
super(taxonomyReader, facetRequest);
}
@@ -546,7 +544,7 @@ public class TopKInEachNodeHandler exten
@Override
protected boolean lessThan(FacetResultNode arg1, FacetResultNode arg2) {
- return merger.leftGoesNow(arg2.getOrdinal(), arg2.getValue(), arg1.getOrdinal(), arg1.getValue());
+ return merger.leftGoesNow(arg2.ordinal, arg2.value, arg1.ordinal, arg1.value);
}
}
@@ -718,14 +716,11 @@ public class TopKInEachNodeHandler exten
if (node == null) {
return;
}
- node.getLabel(this.taxonomyReader); // attach a label -- category path -- to the node
- if (null == node.getSubResults()) {
- return; // if node has no children -- done
- }
+ node.label = taxonomyReader.getPath(node.ordinal);
- // otherwise, label the first numToLabel of these children, and recursively -- their children.
+ // label the first numToLabel of these children, and recursively -- their children.
int numLabeled = 0;
- for (FacetResultNode frn : node.getSubResults()) {
+ for (FacetResultNode frn : node.subResults) {
// go over the children of node from first to last, no more than numToLable of them
recursivelyLabel(frn, numToLabel);
if (++numLabeled >= numToLabel) {
@@ -743,24 +738,23 @@ public class TopKInEachNodeHandler exten
public FacetResult rearrangeFacetResult(FacetResult facetResult) {
PriorityQueue<FacetResultNode> nodesHeap =
new ResultNodeHeap(this.facetRequest.getNumResults(), this.getSuitableACComparator());
- MutableFacetResultNode topFrn = (MutableFacetResultNode) facetResult.getFacetResultNode(); // safe cast
+ FacetResultNode topFrn = facetResult.getFacetResultNode();
rearrangeChilrenOfNode(topFrn, nodesHeap);
return facetResult;
}
- private void rearrangeChilrenOfNode(FacetResultNode node,
- PriorityQueue<FacetResultNode> nodesHeap) {
+ private void rearrangeChilrenOfNode(FacetResultNode node, PriorityQueue<FacetResultNode> nodesHeap) {
nodesHeap.clear(); // just to be safe
- for (FacetResultNode frn : node.getSubResults()) {
+ for (FacetResultNode frn : node.subResults) {
nodesHeap.add(frn);
}
int size = nodesHeap.size();
ArrayList<FacetResultNode> subResults = new ArrayList<FacetResultNode>(size);
- while (nodesHeap.size()>0) {
- subResults.add(0,nodesHeap.pop());
+ while (nodesHeap.size() > 0) {
+ subResults.add(0, nodesHeap.pop());
}
- ((MutableFacetResultNode)node).setSubResults(subResults);
- for (FacetResultNode frn : node.getSubResults()) {
+ node.subResults = subResults;
+ for (FacetResultNode frn : node.subResults) {
rearrangeChilrenOfNode(frn, nodesHeap);
}
@@ -777,13 +771,13 @@ public class TopKInEachNodeHandler exten
if (tmp.isRootNodeIncluded) {
value = tmp.rootNodeValue;
}
- MutableFacetResultNode root = generateNode (ordinal, value, tmp.mapToAACOs);
+ FacetResultNode root = generateNode(ordinal, value, tmp.mapToAACOs);
return new FacetResult (tmp.facetRequest, root, tmp.totalNumOfFacetsConsidered);
}
- private MutableFacetResultNode generateNode (int ordinal, double val, IntToObjectMap<AACO> mapToAACOs) {
- MutableFacetResultNode node = new MutableFacetResultNode(ordinal, val);
+ private FacetResultNode generateNode(int ordinal, double val, IntToObjectMap<AACO> mapToAACOs) {
+ FacetResultNode node = new FacetResultNode(ordinal, val);
AACO aaco = mapToAACOs.get(ordinal);
if (null == aaco) {
return node;
@@ -792,8 +786,8 @@ public class TopKInEachNodeHandler exten
for (int i = 0; i < aaco.ordinals.length; i++) {
list.add(generateNode(aaco.ordinals[i], aaco.values[i], mapToAACOs));
}
- node.setSubResults(list);
- node.setResidue(aaco.residue);
+ node.subResults = list;
+ node.residue = aaco.residue;
return node;
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/results/FacetResultNode.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/results/FacetResultNode.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/results/FacetResultNode.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/results/FacetResultNode.java Mon Jan 21 11:29:01 2013
@@ -1,10 +1,11 @@
package org.apache.lucene.facet.search.results;
-import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
-import org.apache.lucene.facet.search.FacetResultsHandler;
+import org.apache.lucene.facet.search.params.CountFacetRequest;
import org.apache.lucene.facet.search.params.FacetRequest;
-import org.apache.lucene.facet.search.sampling.SampleFixer;
+import org.apache.lucene.facet.search.params.FacetRequest.ResultMode;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
@@ -26,85 +27,86 @@ import org.apache.lucene.facet.taxonomy.
*/
/**
- * Result of faceted search for a certain taxonomy node.
+ * Result of faceted search for a certain taxonomy node. This class serves as a
+ * bin of different attributes of the result node, such as its {@link #ordinal}
+ * as well as {@link #label}. You are not expected to modify those values.
*
* @lucene.experimental
*/
-public interface FacetResultNode {
+public class FacetResultNode {
- /**
- * String representation of this facet result node.
- * Use with caution: might return a very long string.
- * @param prefix prefix for each result line
- */
- public String toString(String prefix);
-
- /**
- * Ordinal of the category of this result.
- */
- public int getOrdinal();
+ public static final List<FacetResultNode> EMPTY_SUB_RESULTS = Collections.emptyList();
+
+ /** The category ordinal of this node. */
+ public int ordinal;
/**
- * Category path of the category of this result, or null if not computed,
- * because the application did not request to compute it.
- * To force computing the label in case not yet computed use
- * {@link #getLabel(TaxonomyReader)}.
- * @see FacetRequest#getNumLabel()
- * @see #getLabel(TaxonomyReader)
- */
- public CategoryPath getLabel();
-
- /**
- * Category path of the category of this result.
- * If not already computed, will be computed now.
- * <p>
- * Use with <b>caution</b>: loading a label for results is costly, performance wise.
- * Therefore force labels loading only when really needed.
- * @param taxonomyReader taxonomy reader for forcing (lazy) labeling of this result.
- * @throws IOException on error
- * @see FacetRequest#getNumLabel()
- */
- public CategoryPath getLabel(TaxonomyReader taxonomyReader) throws IOException;
-
- /**
- * Value of this result - usually either count or a value derived from some
- * computing on the association of it.
- */
- public double getValue();
-
- /**
- * Value of screened out sub results.
+ * The {@link CategoryPath label} of this result. May be {@code null} if not
+ * computed, in which case use {@link TaxonomyReader#getPath(int)} to label
+ * it.
* <p>
- * If only part of valid results are returned, e.g. because top K were requested,
- * provide info on "what else is there under this result node".
+ * <b>NOTE:</b> by default, all nodes are labeled. Only when
+ * {@link FacetRequest#getNumLabel()} <
+ * {@link FacetRequest#getNumResults()} there will be unlabeled nodes.
*/
- public double getResidue();
-
+ public CategoryPath label;
+
/**
- * Contained sub results.
- * These are either child facets, if a tree result was requested, or simply descendants, in case
- * tree result was not requested. In the first case, all returned are both descendants of
- * this node in the taxonomy and siblings of each other in the taxonomy.
- * In the latter case they are only guaranteed to be descendants of
- * this node in the taxonomy.
+ * The value of this result. Its actual type depends on the
+ * {@link FacetRequest} used (e.g. in case of {@link CountFacetRequest} it is
+ * {@code int}).
*/
- public Iterable<? extends FacetResultNode> getSubResults();
+ public double value;
/**
- * Number of sub results
+ * The total value of screened out sub results. If only part of the results
+ * were returned (usually because only the top-K categories are requested),
+ * then this provides information on "what else is there under this result
+ * node".
*/
- public int getNumSubResults();
-
+ public double residue;
+
/**
- * Expert: Set a new value for this result node.
+ * The sub-results of this result. If {@link FacetRequest#getResultMode()} is
+ * {@link ResultMode#PER_NODE_IN_TREE}, every sub result denotes an immediate
+ * child of this node. Otherwise, it is a descendant of any level.
* <p>
- * Allows to modify the value of this facet node.
- * Used for example to tune a sampled value, e.g. by
- * {@link SampleFixer#fixResult(org.apache.lucene.facet.search.ScoredDocIDs, FacetResult)}
- * @param value the new value to set
- * @see #getValue()
- * @see FacetResultsHandler#rearrangeFacetResult(FacetResult)
- */
- public void setValue(double value);
+ * <b>NOTE:</b> this member should not be {@code null}. To denote that a
+ * result does not have sub results, set it to {@link #EMPTY_SUB_RESULTS} (or
+ * don't modify it).
+ */
+ public List<FacetResultNode> subResults = EMPTY_SUB_RESULTS;
+
+ public FacetResultNode() {
+ // empty constructor
+ }
+
+ public FacetResultNode(int ordinal, double value) {
+ this.ordinal = ordinal;
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return toString("");
+ }
+
+ /** Returns a String representation of this facet result node. */
+ public String toString(String prefix) {
+ StringBuilder sb = new StringBuilder(prefix);
+ if (label == null) {
+ sb.append("not labeled (ordinal=").append(ordinal).append(")");
+ } else {
+ sb.append(label.toString());
+ }
+ sb.append(" (").append(Double.toString(value)).append(")");
+ if (residue > 0) {
+ sb.append(" (residue=").append(residue).append(")");
+ }
+ for (FacetResultNode sub : subResults) {
+ sb.append("\n").append(prefix).append(sub.toString(prefix + " "));
+ }
+ return sb.toString();
+ }
-}
\ No newline at end of file
+}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/Sampler.java Mon Jan 21 11:29:01 2013
@@ -11,7 +11,6 @@ import org.apache.lucene.facet.search.pa
import org.apache.lucene.facet.search.params.FacetSearchParams;
import org.apache.lucene.facet.search.results.FacetResult;
import org.apache.lucene.facet.search.results.FacetResultNode;
-import org.apache.lucene.facet.search.results.MutableFacetResultNode;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.index.IndexReader;
@@ -41,7 +40,7 @@ import org.apache.lucene.index.IndexRead
* Note: Sampling accumulation (Accumulation over a sampled-set of the results),
* does not guarantee accurate values for
* {@link FacetResult#getNumValidDescendants()} &
- * {@link FacetResultNode#getResidue()}.
+ * {@link FacetResultNode#residue}.
*
* @lucene.experimental
*/
@@ -169,12 +168,39 @@ public abstract class Sampler {
FacetRequest origFrq = sampledFreq.orig;
- MutableFacetResultNode trimmedRootNode = MutableFacetResultNode.toImpl(facetResult.getFacetResultNode());
- trimmedRootNode.trimSubResults(origFrq.getNumResults());
+ FacetResultNode trimmedRootNode = facetResult.getFacetResultNode();
+ trimSubResults(trimmedRootNode, origFrq.getNumResults());
return new FacetResult(origFrq, trimmedRootNode, facetResult.getNumValidDescendants());
}
+ /** Trim sub results to a given size. */
+ private void trimSubResults(FacetResultNode node, int size) {
+ if (node.subResults == FacetResultNode.EMPTY_SUB_RESULTS || node.subResults.size() == 0) {
+ return;
+ }
+
+ ArrayList<FacetResultNode> trimmed = new ArrayList<FacetResultNode>(size);
+ for (int i = 0; i < node.subResults.size() && i < size; i++) {
+ FacetResultNode trimmedNode = node.subResults.get(i);
+ trimSubResults(trimmedNode, size);
+ trimmed.add(trimmedNode);
+ }
+
+ /*
+ * If we are trimming, it means Sampling is in effect and the extra
+ * (over-sampled) results are being trimmed. Although the residue is not
+ * guaranteed to be accurate for Sampling, we try our best to fix it.
+ * The node's residue now will take under account the sub-nodes we're
+ * trimming.
+ */
+ for (int i = size; i < node.subResults.size(); i++) {
+ node.residue += node.subResults.get(i).value;
+ }
+
+ node.subResults = trimmed;
+ }
+
/**
* Over-sampled search params, wrapping each request with an over-sampled one.
*/
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/SamplingAccumulator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/SamplingAccumulator.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/SamplingAccumulator.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/SamplingAccumulator.java Mon Jan 21 11:29:01 2013
@@ -49,7 +49,7 @@ import org.apache.lucene.index.IndexRead
* Note: Sampling accumulation (Accumulation over a sampled-set of the results),
* does not guarantee accurate values for
* {@link FacetResult#getNumValidDescendants()} &
- * {@link FacetResultNode#getResidue()}.
+ * {@link FacetResultNode#residue}.
*
* @see Sampler
* @lucene.experimental
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/TakmiSampleFixer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/TakmiSampleFixer.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/TakmiSampleFixer.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/java/org/apache/lucene/facet/search/sampling/TakmiSampleFixer.java Mon Jan 21 11:29:01 2013
@@ -74,10 +74,9 @@ class TakmiSampleFixer implements Sample
* docids in effect
* @throws IOException If there is a low-level I/O error.
*/
- private void fixResultNode(FacetResultNode facetResNode, ScoredDocIDs docIds)
- throws IOException {
+ private void fixResultNode(FacetResultNode facetResNode, ScoredDocIDs docIds) throws IOException {
recount(facetResNode, docIds);
- for (FacetResultNode frn : facetResNode.getSubResults()) {
+ for (FacetResultNode frn : facetResNode.subResults) {
fixResultNode(frn, docIds);
}
}
@@ -101,7 +100,10 @@ class TakmiSampleFixer implements Sample
* facet results was exercise, we need to calculate them anyway, so
* in essence sampling with recounting spends some extra cycles for
* labeling results for which labels are not required. */
- CategoryPath catPath = fresNode.getLabel(taxonomyReader); // force labeling
+ if (fresNode.label == null) {
+ fresNode.label = taxonomyReader.getPath(fresNode.ordinal);
+ }
+ CategoryPath catPath = fresNode.label;
Term drillDownTerm = DrillDown.term(searchParams, catPath);
// TODO (Facet): avoid Multi*?
@@ -109,8 +111,7 @@ class TakmiSampleFixer implements Sample
int updatedCount = countIntersection(MultiFields.getTermDocsEnum(indexReader, liveDocs,
drillDownTerm.field(), drillDownTerm.bytes(),
0), docIds.iterator());
-
- fresNode.setValue(updatedCount);
+ fresNode.value = updatedCount;
}
/**
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=1436281&r1=1436280&r2=1436281&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 Mon Jan 21 11:29:01 2013
@@ -73,12 +73,12 @@ public class ResultSortUtils {
@Override
protected boolean lessThan(FacetResultNode arg0, FacetResultNode arg1) {
- double value0 = arg0.getValue();
- double value1 = arg1.getValue();
+ double value0 = arg0.value;
+ double value1 = arg1.value;
int valueCompare = Double.compare(value0, value1);
if (valueCompare == 0) {
- return arg0.getOrdinal() < arg1.getOrdinal();
+ return arg0.ordinal < arg1.ordinal;
}
return valueCompare < 0;
@@ -93,40 +93,38 @@ public class ResultSortUtils {
@Override
protected boolean lessThan(FacetResultNode arg0, FacetResultNode arg1) {
- double value0 = arg0.getValue();
- double value1 = arg1.getValue();
+ double value0 = arg0.value;
+ double value1 = arg1.value;
int valueCompare = Double.compare(value0, value1);
if (valueCompare == 0) {
- return arg0.getOrdinal() > arg1.getOrdinal();
+ return arg0.ordinal > arg1.ordinal;
}
return valueCompare > 0;
}
}
- private static class MinOrdinalHeap extends
- PriorityQueue<FacetResultNode> implements Heap<FacetResultNode> {
+ 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.getOrdinal() < arg1.getOrdinal();
+ return arg0.ordinal < arg1.ordinal;
}
}
- private static class MaxOrdinalHeap extends
- PriorityQueue<FacetResultNode> implements Heap<FacetResultNode> {
+ 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.getOrdinal() > arg1.getOrdinal();
+ return arg0.ordinal > arg1.ordinal;
}
}
@@ -156,10 +154,9 @@ public class ResultSortUtils {
Collections.sort(resultNodes, new Comparator<FacetResultNode>() {
@Override
public int compare(FacetResultNode o1, FacetResultNode o2) {
- int value = Double.compare(o1.getValue(), o2
- .getValue());
+ int value = Double.compare(o1.value, o2.value);
if (value == 0) {
- value = o1.getOrdinal() - o2.getOrdinal();
+ value = o1.ordinal - o2.ordinal;
}
if (accending) {
value = -value;
@@ -198,4 +195,5 @@ public class ResultSortUtils {
resultNodes.clear();
}
}
+
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestBase.java Mon Jan 21 11:29:01 2013
@@ -247,7 +247,7 @@ public abstract class FacetTestBase exte
/** convenience method: convert sub results to an array */
protected static FacetResultNode[] resultNodesAsArray(FacetResultNode parentRes) {
ArrayList<FacetResultNode> a = new ArrayList<FacetResultNode>();
- for (FacetResultNode frn : parentRes.getSubResults()) {
+ for (FacetResultNode frn : parentRes.subResults) {
a.add(frn);
}
return a.toArray(new FacetResultNode[0]);
@@ -306,42 +306,27 @@ public abstract class FacetTestBase exte
/** Validate counts for returned facets, and that there are not too many results */
private static void assertCountsAndCardinality(Map<CategoryPath,Integer> facetCountsTruth, FacetResultNode resNode, int reqNumResults) throws Exception {
- int actualNumResults = resNode.getNumSubResults();
+ int actualNumResults = resNode.subResults.size();
if (VERBOSE) {
System.out.println("NumResults: " + actualNumResults);
}
assertTrue("Too many results!", actualNumResults <= reqNumResults);
- for (FacetResultNode subRes : resNode.getSubResults()) {
- assertEquals("wrong count for: "+subRes, facetCountsTruth.get(subRes.getLabel()).intValue(), (int)subRes.getValue());
+ for (FacetResultNode subRes : resNode.subResults) {
+ assertEquals("wrong count for: "+subRes, facetCountsTruth.get(subRes.label).intValue(), (int)subRes.value);
assertCountsAndCardinality(facetCountsTruth, subRes, reqNumResults); // recurse into child results
}
}
/** Validate results equality */
protected static void assertSameResults(List<FacetResult> expected, List<FacetResult> actual) {
- String expectedResults = resStringValueOnly(expected);
- String actualResults = resStringValueOnly(actual);
- if (!expectedResults.equals(actualResults)) {
- System.err.println("Results are not the same!");
- System.err.println("Expected:\n" + expectedResults);
- System.err.println("Actual:\n" + actualResults);
- throw new NotSameResultError();
- }
- }
-
- /** exclude the residue and numDecendants because it is incorrect in sampling */
- private static final String resStringValueOnly(List<FacetResult> results) {
- StringBuilder sb = new StringBuilder();
- for (FacetResult facetRes : results) {
- sb.append(facetRes.toString()).append('\n');
- }
- return sb.toString().replaceAll("Residue:.*.0", "").replaceAll("Num valid Descendants.*", "");
- }
-
- /** Special Error class for ability to ignore only this error and retry... */
- public static class NotSameResultError extends Error {
- public NotSameResultError() {
- super("Results are not the same!");
+ assertEquals("wrong number of facet results", expected.size(), actual.size());
+ int size = expected.size();
+ for (int i = 0; i < size; i++) {
+ FacetResult expectedResult = expected.get(i);
+ FacetResult actualResult = actual.get(i);
+ String expectedStr = FacetTestUtils.toSimpleString(expectedResult);
+ String actualStr = FacetTestUtils.toSimpleString(actualResult);
+ assertEquals("Results not the same!\nExpected:" + expectedStr + "\nActual:\n" + actualStr, expectedStr, actualStr);
}
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/FacetTestUtils.java Mon Jan 21 11:29:01 2013
@@ -10,6 +10,8 @@ import org.apache.lucene.facet.search.Fa
import org.apache.lucene.facet.search.params.CountFacetRequest;
import org.apache.lucene.facet.search.params.FacetRequest;
import org.apache.lucene.facet.search.params.FacetSearchParams;
+import org.apache.lucene.facet.search.results.FacetResult;
+import org.apache.lucene.facet.search.results.FacetResultNode;
import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
@@ -45,6 +47,33 @@ import org.apache.lucene.util.LuceneTest
public class FacetTestUtils {
+ public static class IndexTaxonomyReaderPair {
+ public DirectoryReader indexReader;
+ public DirectoryTaxonomyReader taxReader;
+ public IndexSearcher indexSearcher;
+
+ public void close() throws IOException {
+ indexReader.close();
+ taxReader.close();
+ }
+
+ }
+
+ public static class IndexTaxonomyWriterPair {
+ public IndexWriter indexWriter;
+ public TaxonomyWriter taxWriter;
+
+ public void close() throws IOException {
+ indexWriter.close();
+ taxWriter.close();
+ }
+
+ public void commit() throws IOException {
+ indexWriter.commit();
+ taxWriter.commit();
+ }
+ }
+
public static Directory[][] createIndexTaxonomyDirs(int number) {
Directory[][] dirs = new Directory[number][2];
for (int i = 0; i < number; i++) {
@@ -66,7 +95,7 @@ public class FacetTestUtils {
}
return pairs;
}
-
+
public static IndexTaxonomyWriterPair[] createIndexTaxonomyWriterPair(
Directory[][] dirs) throws IOException {
IndexTaxonomyWriterPair[] pairs = new IndexTaxonomyWriterPair[dirs.length];
@@ -109,31 +138,17 @@ public class FacetTestUtils {
searcher.search(new MatchAllDocsQuery(), mColl);
return collectors;
}
-
- public static class IndexTaxonomyReaderPair {
- public DirectoryReader indexReader;
- public DirectoryTaxonomyReader taxReader;
- public IndexSearcher indexSearcher;
-
- public void close() throws IOException {
- indexReader.close();
- taxReader.close();
- }
+ public static String toSimpleString(FacetResult fr) {
+ StringBuilder sb = new StringBuilder();
+ toSimpleString(0, sb, fr.getFacetResultNode(), "");
+ return sb.toString();
}
-
- public static class IndexTaxonomyWriterPair {
- public IndexWriter indexWriter;
- public TaxonomyWriter taxWriter;
-
- public void close() throws IOException {
- indexWriter.close();
- taxWriter.close();
- }
-
- public void commit() throws IOException {
- indexWriter.commit();
- taxWriter.commit();
+
+ private static void toSimpleString(int depth, StringBuilder sb, FacetResultNode node, String indent) {
+ sb.append(indent + node.label.components[depth] + " (" + (int) node.value + ")\n");
+ for (FacetResultNode childNode : node.subResults) {
+ toSimpleString(depth + 1, sb, childNode, indent + " ");
}
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestAssociationExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestAssociationExample.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestAssociationExample.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestAssociationExample.java Mon Jan 21 11:29:01 2013
@@ -43,10 +43,10 @@ public class TestAssociationExample exte
assertEquals("Wrong number of results!", 1, res.getFacetResults().size());
assertEquals("Wrong number of facets!", 2, res.getFacetResults().get(0).getNumValidDescendants());
- Iterable<? extends FacetResultNode> it = res.getFacetResults().get(0).getFacetResultNode().getSubResults();
+ Iterable<? extends FacetResultNode> it = res.getFacetResults().get(0).getFacetResultNode().subResults;
int i = 0;
for (FacetResultNode fResNode : it) {
- assertEquals("Wrong result for facet "+fResNode.getLabel(), expectedResults[i++], fResNode.getValue(), 1E-5);
+ assertEquals("Wrong result for facet "+fResNode.label, expectedResults[i++], fResNode.value, 1E-5);
}
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestMultiCLExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestMultiCLExample.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestMultiCLExample.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestMultiCLExample.java Mon Jan 21 11:29:01 2013
@@ -41,45 +41,35 @@ public class TestMultiCLExample extends
List<FacetResult> results = exampleResults.getFacetResults();
FacetResult result = results.get(0);
assertNotNull("Result should not be null", result);
- assertEquals("Invalid label", "5", result.getFacetResultNode()
- .getLabel().toString());
- assertEquals("Invalid value", 2.0, result.getFacetResultNode()
- .getValue(), 0.0);
- assertEquals("Invalid # of subresults", 3, result.getFacetResultNode()
- .getNumSubResults());
+ FacetResultNode node = result.getFacetResultNode();
+ assertEquals("Invalid label", "5", node.label.toString());
+ assertEquals("Invalid value", 2.0, node.value, 0.0);
+ assertEquals("Invalid # of subresults", 3, node.subResults.size());
- Iterator<? extends FacetResultNode> subResults = result
- .getFacetResultNode().getSubResults().iterator();
+ Iterator<? extends FacetResultNode> subResults = node.subResults.iterator();
FacetResultNode sub = subResults.next();
- assertEquals("Invalid subresult value", 1.0, sub.getValue(), 0.0);
- assertEquals("Invalid subresult label", "5/2", sub.getLabel()
- .toString());
+ assertEquals("Invalid subresult value", 1.0, sub.value, 0.0);
+ assertEquals("Invalid subresult label", "5/2", sub.label.toString());
sub = subResults.next();
- assertEquals("Invalid subresult value", 1.0, sub.getValue(), 0.0);
- assertEquals("Invalid subresult label", "5/7", sub.getLabel()
- .toString());
+ assertEquals("Invalid subresult value", 1.0, sub.value, 0.0);
+ assertEquals("Invalid subresult label", "5/7", sub.label.toString());
sub = subResults.next();
- assertEquals("Invalid subresult value", 1.0, sub.getValue(), 0.0);
- assertEquals("Invalid subresult label", "5/5", sub.getLabel()
- .toString());
+ assertEquals("Invalid subresult value", 1.0, sub.value, 0.0);
+ assertEquals("Invalid subresult label", "5/5", sub.label.toString());
result = results.get(1);
+ node = result.getFacetResultNode();
assertNotNull("Result should not be null", result);
- assertEquals("Invalid label", "5/5", result.getFacetResultNode()
- .getLabel().toString());
- assertEquals("Invalid value", 1,
- result.getFacetResultNode().getValue(), 0.0);
- assertEquals("Invalid number of subresults", 0, result
- .getFacetResultNode().getNumSubResults());
+ assertEquals("Invalid label", "5/5", node.label.toString());
+ assertEquals("Invalid value", 1, node.value, 0.0);
+ assertEquals("Invalid number of subresults", 0, node.subResults.size());
result = results.get(2);
+ node = result.getFacetResultNode();
assertNotNull("Result should not be null", result);
- assertEquals("Invalid label", "6/2", result.getFacetResultNode()
- .getLabel().toString());
- assertEquals("Invalid value", 1,
- result.getFacetResultNode().getValue(), 0.0);
- assertEquals("Invalid number of subresults", 0, result
- .getFacetResultNode().getNumSubResults());
+ assertEquals("Invalid label", "6/2", node.label.toString());
+ assertEquals("Invalid value", 1, node.value, 0.0);
+ assertEquals("Invalid number of subresults", 0, node.subResults.size());
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestSimpleExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestSimpleExample.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestSimpleExample.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/example/TestSimpleExample.java Mon Jan 21 11:29:01 2013
@@ -55,11 +55,11 @@ public class TestSimpleExample extends L
FacetResult facetResult = res.getFacetResults().get(0);
assertEquals("Wrong number of facets!",2, facetResult.getNumValidDescendants());
- Iterator<? extends FacetResultNode> resIterator = facetResult.getFacetResultNode().getSubResults().iterator();
+ Iterator<? extends FacetResultNode> resIterator = facetResult.getFacetResultNode().subResults.iterator();
assertTrue("Too few results", resIterator.hasNext());
- assertEquals("wrong count for first result out of 2", 1, (int)resIterator.next().getValue());
+ assertEquals("wrong count for first result out of 2", 1, (int)resIterator.next().value);
assertTrue("Too few results", resIterator.hasNext());
- assertEquals("wrong count for second result out of 2", 1, (int)resIterator.next().getValue());
+ assertEquals("wrong count for second result out of 2", 1, (int)resIterator.next().value);
assertFalse("Too many results!", resIterator.hasNext());
}
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/OrdinalMappingReaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/OrdinalMappingReaderTest.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/OrdinalMappingReaderTest.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/OrdinalMappingReaderTest.java Mon Jan 21 11:29:01 2013
@@ -77,9 +77,9 @@ public class OrdinalMappingReaderTest ex
searcher.search(new MatchAllDocsQuery(), collector);
FacetResult result = collector.getFacetResults().get(0);
FacetResultNode node = result.getFacetResultNode();
- for (FacetResultNode facet: node.getSubResults()) {
- int weight = (int)facet.getValue();
- int label = Integer.parseInt(facet.getLabel().components[1]);
+ for (FacetResultNode facet: node.subResults) {
+ int weight = (int)facet.value;
+ int label = Integer.parseInt(facet.label.components[1]);
//System.out.println(label + ": " + weight);
if (VERBOSE) {
System.out.println(label + ": " + weight);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/TestFacetsPayloadMigrationReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/TestFacetsPayloadMigrationReader.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/TestFacetsPayloadMigrationReader.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/index/TestFacetsPayloadMigrationReader.java Mon Jan 21 11:29:01 2013
@@ -275,8 +275,8 @@ public class TestFacetsPayloadMigrationR
assertEquals(requests.size(), facetResults.size());
for (FacetResult res : facetResults) {
FacetResultNode node = res.getFacetResultNode();
- String dim = node.getLabel().components[0];
- assertEquals("wrong count for " + dim, expectedCounts.get(dim).intValue(), (int) node.getValue());
+ String dim = node.label.components[0];
+ assertEquals("wrong count for " + dim, expectedCounts.get(dim).intValue(), (int) node.value);
}
}
@@ -296,7 +296,7 @@ public class TestFacetsPayloadMigrationR
List<FacetResult> facetResults = fc.getFacetResults();
assertEquals(1, facetResults.size());
FacetResultNode rootNode = facetResults.get(0).getFacetResultNode();
- assertEquals("wrong count for " + dim, expectedCounts.get(dim).intValue(), (int) rootNode.getValue());
+ assertEquals("wrong count for " + dim, expectedCounts.get(dim).intValue(), (int) rootNode.value);
}
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestDemoFacets.java Mon Jan 21 11:29:01 2013
@@ -131,8 +131,8 @@ public class TestDemoFacets extends Luce
}
private void toSimpleString(int depth, StringBuilder sb, FacetResultNode node, String indent) {
- sb.append(indent + node.getLabel().components[depth] + " (" + (int) node.getValue() + ")\n");
- for(FacetResultNode childNode : node.getSubResults()) {
+ sb.append(indent + node.label.components[depth] + " (" + (int) node.value + ")\n");
+ for(FacetResultNode childNode : node.subResults) {
toSimpleString(depth+1, sb, childNode, indent + " ");
}
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsAccumulatorWithComplement.java Mon Jan 21 11:29:01 2013
@@ -118,8 +118,8 @@ public class TestFacetsAccumulatorWithCo
FacetResultNode parentResWithComp = countResWithComplement.get(0).getFacetResultNode();
FacetResultNode parentResNoComp = countResWithComplement.get(0).getFacetResultNode();
- assertEquals("Wrong number of top count aggregated categories with complement!",3,parentResWithComp.getNumSubResults());
- assertEquals("Wrong number of top count aggregated categories no complement!",3,parentResNoComp.getNumSubResults());
+ assertEquals("Wrong number of top count aggregated categories with complement!",3,parentResWithComp.subResults.size());
+ assertEquals("Wrong number of top count aggregated categories no complement!",3,parentResNoComp.subResults.size());
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestFacetsCollector.java Mon Jan 21 11:29:01 2013
@@ -78,7 +78,7 @@ public class TestFacetsCollector extends
new IndexSearcher(r).search(new MatchAllDocsQuery(), MultiCollector.wrap(fc, topDocs));
List<FacetResult> res = fc.getFacetResults();
- double value = res.get(0).getFacetResultNode().getValue();
+ double value = res.get(0).getFacetResultNode().value;
double expected = topDocs.topDocs().getMaxScore() * r.numDocs();
assertEquals(expected, value, 1E-10);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestMultipleCategoryLists.java Mon Jan 21 11:29:01 2013
@@ -273,7 +273,7 @@ public class TestMultipleCategoryLists e
FacetResult results = res.get(0);
FacetResultNode resNode = results.getFacetResultNode();
- Iterable<? extends FacetResultNode> subResults = resNode.getSubResults();
+ Iterable<? extends FacetResultNode> subResults = resNode.subResults;
Iterator<? extends FacetResultNode> subIter = subResults.iterator();
checkResult(resNode, "Band", 5.0);
@@ -282,7 +282,7 @@ public class TestMultipleCategoryLists e
results = res.get(1);
resNode = results.getFacetResultNode();
- subResults = resNode.getSubResults();
+ subResults = resNode.subResults;
subIter = subResults.iterator();
checkResult(resNode, "Band", 5.0);
@@ -296,7 +296,7 @@ public class TestMultipleCategoryLists e
results = res.get(2);
resNode = results.getFacetResultNode();
- subResults = resNode.getSubResults();
+ subResults = resNode.subResults;
subIter = subResults.iterator();
checkResult(resNode, "Author", 3.0);
@@ -306,7 +306,7 @@ public class TestMultipleCategoryLists e
results = res.get(3);
resNode = results.getFacetResultNode();
- subResults = resNode.getSubResults();
+ subResults = resNode.subResults;
subIter = subResults.iterator();
checkResult(resNode, "Band/Rock & Pop", 4.0);
@@ -352,8 +352,8 @@ public class TestMultipleCategoryLists e
}
private static void checkResult(FacetResultNode sub, String label, double value) {
- assertEquals("Label of subresult " + sub.getLabel() + " was incorrect", label, sub.getLabel().toString());
- assertEquals("Value for " + sub.getLabel() + " subresult was incorrect", value, sub.getValue(), 0.0);
+ assertEquals("Label of subresult " + sub.label + " was incorrect", label, sub.label.toString());
+ assertEquals("Value for " + sub.label + " subresult was incorrect", value, sub.value, 0.0);
}
}
\ No newline at end of file
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestScoredDocIdCollector.java Mon Jan 21 11:29:01 2013
@@ -89,10 +89,8 @@ public class TestScoredDocIdCollector ex
FacetResultNode parentCountRes = countRes.get(0).getFacetResultNode();
FacetResultNode parentScoreRes = scoreRes.get(0).getFacetResultNode();
- assertEquals("Wrong number of top count aggregated categories!", 3,
- parentCountRes.getNumSubResults());
- assertEquals("Wrong number of top score aggregated categories!", 3,
- parentScoreRes.getNumSubResults());
+ assertEquals("Wrong number of top count aggregated categories!", 3, parentCountRes.subResults.size());
+ assertEquals("Wrong number of top score aggregated categories!", 3, parentScoreRes.subResults.size());
// rely on that facet value is computed as doc-score, and
// accordingly compare values of the two top-category results.
@@ -101,12 +99,8 @@ public class TestScoredDocIdCollector ex
FacetResultNode[] scoreResNodes = resultNodesAsArray(parentScoreRes);
for (int i = 0; i < scoreResNodes.length; i++) {
- assertEquals("Ordinals differ!",
- countResNodes[i].getOrdinal(), scoreResNodes[i].getOrdinal());
- assertEquals("Wrong scores!",
- constScore * countResNodes[i].getValue(),
- scoreResNodes[i].getValue(),
- Double.MIN_VALUE);
+ assertEquals("Ordinals differ!", countResNodes[i].ordinal, scoreResNodes[i].ordinal);
+ assertEquals("Wrong scores!", constScore * countResNodes[i].value, scoreResNodes[i].value, Double.MIN_VALUE);
}
}
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestStandardFacetsAccumulator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestStandardFacetsAccumulator.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestStandardFacetsAccumulator.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestStandardFacetsAccumulator.java Mon Jan 21 11:29:01 2013
@@ -118,10 +118,10 @@ public class TestStandardFacetsAccumulat
List<FacetResult> results = fc.getFacetResults();
assertEquals("received too many facet results", 1, results.size());
FacetResultNode frn = results.get(0).getFacetResultNode();
- assertEquals("wrong weight for \"A\"", 4, (int) frn.getValue());
- assertEquals("wrong number of children", 2, frn.getNumSubResults());
- for (FacetResultNode node : frn.getSubResults()) {
- assertEquals("wrong weight for child " + node.getLabel(), 2, (int) node.getValue());
+ assertEquals("wrong weight for \"A\"", 4, (int) frn.value);
+ assertEquals("wrong number of children", 2, frn.subResults.size());
+ for (FacetResultNode node : frn.subResults) {
+ assertEquals("wrong weight for child " + node.label, 2, (int) node.value);
}
IOUtils.close(indexReader, taxoReader);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKInEachNodeResultHandler.java Mon Jan 21 11:29:01 2013
@@ -183,40 +183,40 @@ public class TestTopKInEachNodeResultHan
boolean hasDoctor = "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
assertEquals(9, fr.getNumValidDescendants());
FacetResultNode parentRes = fr.getFacetResultNode();
- assertEquals(16.0, parentRes.getValue(), Double.MIN_VALUE);
- assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
- assertEquals(2, parentRes.getNumSubResults());
+ assertEquals(16.0, parentRes.value, Double.MIN_VALUE);
+ assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+ assertEquals(2, parentRes.subResults.size());
// two nodes sorted by descending values: a/b with 8 and a/c with 6
// a/b has residue 2 and two children a/b/2 with value 3, and a/b/1 with value 2.
// a/c has residue 0, and one child a/c/1 with value 1.
double [] expectedValues0 = { 8.0, 2.0, 3.0, 0.0, 2.0, 0.0, 6.0, 0.0, 1.0, 0.0 };
int i = 0;
- for (FacetResultNode node : parentRes.getSubResults()) {
- assertEquals(expectedValues0[i++], node.getValue(), Double.MIN_VALUE);
- assertEquals(expectedValues0[i++], node.getResidue(), Double.MIN_VALUE);
- for (FacetResultNode node2 : node.getSubResults()) {
- assertEquals(expectedValues0[i++], node2.getValue(), Double.MIN_VALUE);
- assertEquals(expectedValues0[i++], node2.getResidue(), Double.MIN_VALUE);
+ for (FacetResultNode node : parentRes.subResults) {
+ assertEquals(expectedValues0[i++], node.value, Double.MIN_VALUE);
+ assertEquals(expectedValues0[i++], node.residue, Double.MIN_VALUE);
+ for (FacetResultNode node2 : node.subResults) {
+ assertEquals(expectedValues0[i++], node2.value, Double.MIN_VALUE);
+ assertEquals(expectedValues0[i++], node2.residue, Double.MIN_VALUE);
}
}
// now just change the value of the first child of the root to 5, and then rearrange
// expected are: first a/c of value 6 and residue 0, and one child a/c/1 with value 1
// then a/b with value 5 and residue 2, and both children: a/b/2 with value 3, and a/b/1 with value 2.
- for (FacetResultNode node : parentRes.getSubResults()) {
- node.setValue(5.0);
+ for (FacetResultNode node : parentRes.subResults) {
+ node.value = 5.0;
break;
}
// now rearrange
double [] expectedValues00 = { 6.0, 0.0, 1.0, 0.0, 5.0, 2.0, 3.0, 0.0, 2.0, 0.0 };
fr = cfra23.createFacetResultsHandler(tr).rearrangeFacetResult(fr);
i = 0;
- for (FacetResultNode node : parentRes.getSubResults()) {
- assertEquals(expectedValues00[i++], node.getValue(), Double.MIN_VALUE);
- assertEquals(expectedValues00[i++], node.getResidue(), Double.MIN_VALUE);
- for (FacetResultNode node2 : node.getSubResults()) {
- assertEquals(expectedValues00[i++], node2.getValue(), Double.MIN_VALUE);
- assertEquals(expectedValues00[i++], node2.getResidue(), Double.MIN_VALUE);
+ for (FacetResultNode node : parentRes.subResults) {
+ assertEquals(expectedValues00[i++], node.value, Double.MIN_VALUE);
+ assertEquals(expectedValues00[i++], node.residue, Double.MIN_VALUE);
+ for (FacetResultNode node2 : node.subResults) {
+ assertEquals(expectedValues00[i++], node2.value, Double.MIN_VALUE);
+ assertEquals(expectedValues00[i++], node2.residue, Double.MIN_VALUE);
}
}
@@ -224,19 +224,19 @@ public class TestTopKInEachNodeResultHan
hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
assertEquals(9, fr.getNumValidDescendants());
parentRes = fr.getFacetResultNode();
- assertEquals(16.0, parentRes.getValue(), Double.MIN_VALUE);
- assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
- assertEquals(2, parentRes.getNumSubResults());
+ assertEquals(16.0, parentRes.value, Double.MIN_VALUE);
+ assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+ assertEquals(2, parentRes.subResults.size());
// two nodes sorted by descending values: a/b with 8 and a/c with 6
// a/b has residue 2 and two children a/b/2 with value 3, and a/b/1 with value 2.
// a/c has residue 0, and one child a/c/1 with value 1.
i = 0;
- for (FacetResultNode node : parentRes.getSubResults()) {
- assertEquals(expectedValues0[i++], node.getValue(), Double.MIN_VALUE);
- assertEquals(expectedValues0[i++], node.getResidue(), Double.MIN_VALUE);
- for (FacetResultNode node2 : node.getSubResults()) {
- assertEquals(expectedValues0[i++], node2.getValue(), Double.MIN_VALUE);
- assertEquals(expectedValues0[i++], node2.getResidue(), Double.MIN_VALUE);
+ for (FacetResultNode node : parentRes.subResults) {
+ assertEquals(expectedValues0[i++], node.value, Double.MIN_VALUE);
+ assertEquals(expectedValues0[i++], node.residue, Double.MIN_VALUE);
+ for (FacetResultNode node2 : node.subResults) {
+ assertEquals(expectedValues0[i++], node2.value, Double.MIN_VALUE);
+ assertEquals(expectedValues0[i++], node2.residue, Double.MIN_VALUE);
}
}
@@ -244,70 +244,70 @@ public class TestTopKInEachNodeResultHan
hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
assertEquals(4, fr.getNumValidDescendants(), 4);
parentRes = fr.getFacetResultNode();
- assertEquals(16.0, parentRes.getValue(), Double.MIN_VALUE);
- assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
- assertEquals(2, parentRes.getNumSubResults());
+ assertEquals(16.0, parentRes.value, Double.MIN_VALUE);
+ assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+ assertEquals(2, parentRes.subResults.size());
// two nodes sorted by descending values:
// a/b with value 8 and residue 0 (because no children considered),
// and a/c with value 6 and residue 0 (because no children considered)
double [] expectedValues2 = { 8.0, 0.0, 6.0, 0.0 };
i = 0;
- for (FacetResultNode node : parentRes.getSubResults()) {
- assertEquals(expectedValues2[i++], node.getValue(), Double.MIN_VALUE);
- assertEquals(expectedValues2[i++], node.getResidue(), Double.MIN_VALUE);
- assertEquals(node.getNumSubResults(), 0);
+ for (FacetResultNode node : parentRes.subResults) {
+ assertEquals(expectedValues2[i++], node.value, Double.MIN_VALUE);
+ assertEquals(expectedValues2[i++], node.residue, Double.MIN_VALUE);
+ assertEquals(node.subResults.size(), 0);
}
fr = facetResults.get(3); // a/b, depth=3, K=2
hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
assertEquals(4, fr.getNumValidDescendants());
parentRes = fr.getFacetResultNode();
- assertEquals(8.0, parentRes.getValue(), Double.MIN_VALUE);
- assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
- assertEquals(2, parentRes.getNumSubResults());
+ assertEquals(8.0, parentRes.value, Double.MIN_VALUE);
+ assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+ assertEquals(2, parentRes.subResults.size());
double [] expectedValues3 = { 3.0, 2.0 };
i = 0;
- for (FacetResultNode node : parentRes.getSubResults()) {
- assertEquals(expectedValues3[i++], node.getValue(), Double.MIN_VALUE);
- assertEquals(0.0, node.getResidue(), Double.MIN_VALUE);
- assertEquals(0, node.getNumSubResults());
+ for (FacetResultNode node : parentRes.subResults) {
+ assertEquals(expectedValues3[i++], node.value, Double.MIN_VALUE);
+ assertEquals(0.0, node.residue, Double.MIN_VALUE);
+ assertEquals(0, node.subResults.size());
}
fr = facetResults.get(4); // a/b, depth=2, K=2
hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
assertEquals(4, fr.getNumValidDescendants());
parentRes = fr.getFacetResultNode();
- assertEquals(8.0, parentRes.getValue(), Double.MIN_VALUE);
- assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
- assertEquals(2, parentRes.getNumSubResults());
- i = 0;
- for (FacetResultNode node : parentRes.getSubResults()) {
- assertEquals(expectedValues3[i++], node.getValue(), Double.MIN_VALUE);
- assertEquals(0.0, node.getResidue(), Double.MIN_VALUE);
- assertEquals(0, node.getNumSubResults());
+ assertEquals(8.0, parentRes.value, Double.MIN_VALUE);
+ assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+ assertEquals(2, parentRes.subResults.size());
+ i = 0;
+ for (FacetResultNode node : parentRes.subResults) {
+ assertEquals(expectedValues3[i++], node.value, Double.MIN_VALUE);
+ assertEquals(0.0, node.residue, Double.MIN_VALUE);
+ assertEquals(0, node.subResults.size());
}
fr = facetResults.get(5); // a/b, depth=1, K=2
hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
assertEquals(4, fr.getNumValidDescendants());
parentRes = fr.getFacetResultNode();
- assertEquals(8.0, parentRes.getValue(), Double.MIN_VALUE);
- assertEquals(2.0, parentRes.getResidue(), Double.MIN_VALUE);
- assertEquals(2, parentRes.getNumSubResults());
- i = 0;
- for (FacetResultNode node : parentRes.getSubResults()) {
- assertEquals(expectedValues3[i++], node.getValue(), Double.MIN_VALUE);
- assertEquals(0.0, node.getResidue(), Double.MIN_VALUE);
- assertEquals(0, node.getNumSubResults());
+ assertEquals(8.0, parentRes.value, Double.MIN_VALUE);
+ assertEquals(2.0, parentRes.residue, Double.MIN_VALUE);
+ assertEquals(2, parentRes.subResults.size());
+ i = 0;
+ for (FacetResultNode node : parentRes.subResults) {
+ assertEquals(expectedValues3[i++], node.value, Double.MIN_VALUE);
+ assertEquals(0.0, node.residue, Double.MIN_VALUE);
+ assertEquals(0, node.subResults.size());
}
fr = facetResults.get(6); // a/b, depth=0, K=2
hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
assertEquals(0, fr.getNumValidDescendants()); // 0 descendants but rootnode
parentRes = fr.getFacetResultNode();
- assertEquals(8.0, parentRes.getValue(), Double.MIN_VALUE);
- assertEquals(0.0, parentRes.getResidue(), Double.MIN_VALUE);
- assertEquals(0, parentRes.getNumSubResults());
+ assertEquals(8.0, parentRes.value, Double.MIN_VALUE);
+ assertEquals(0.0, parentRes.residue, Double.MIN_VALUE);
+ assertEquals(0, parentRes.subResults.size());
hasDoctor |= "Doctor".equals(fr.getFacetRequest().categoryPath.components[0]);
// doctor, depth=1, K=2
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandler.java Mon Jan 21 11:29:01 2013
@@ -99,52 +99,46 @@ public class TestTopKResultsHandler exte
};
searcher.search(new MatchAllDocsQuery(), fc);
- long start = System.currentTimeMillis();
List<FacetResult> facetResults = fc.getFacetResults();
- long end = System.currentTimeMillis();
-
- if (VERBOSE) {
- System.out.println("Time: " + (end - start));
- }
FacetResult fr = facetResults.get(0);
FacetResultNode parentRes = fr.getFacetResultNode();
- assertEquals(13.0, parentRes.getValue(), Double.MIN_VALUE);
+ assertEquals(13.0, parentRes.value, Double.MIN_VALUE);
FacetResultNode[] frn = resultNodesAsArray(parentRes);
- assertEquals(7.0, frn[0].getValue(), Double.MIN_VALUE);
- assertEquals(6.0, frn[1].getValue(), Double.MIN_VALUE);
+ assertEquals(7.0, frn[0].value, Double.MIN_VALUE);
+ assertEquals(6.0, frn[1].value, Double.MIN_VALUE);
fr = facetResults.get(1);
parentRes = fr.getFacetResultNode();
- assertEquals(13.0, parentRes.getValue(), Double.MIN_VALUE);
+ assertEquals(13.0, parentRes.value, Double.MIN_VALUE);
frn = resultNodesAsArray(parentRes);
- assertEquals(7.0, frn[0].getValue(), Double.MIN_VALUE);
- assertEquals(6.0, frn[1].getValue(), Double.MIN_VALUE);
- assertEquals(2.0, frn[2].getValue(), Double.MIN_VALUE);
- assertEquals(2.0, frn[3].getValue(), Double.MIN_VALUE);
- assertEquals(1.0, frn[4].getValue(), Double.MIN_VALUE);
- assertEquals(1.0, frn[5].getValue(), Double.MIN_VALUE);
+ assertEquals(7.0, frn[0].value, Double.MIN_VALUE);
+ assertEquals(6.0, frn[1].value, Double.MIN_VALUE);
+ assertEquals(2.0, frn[2].value, Double.MIN_VALUE);
+ assertEquals(2.0, frn[3].value, Double.MIN_VALUE);
+ assertEquals(1.0, frn[4].value, Double.MIN_VALUE);
+ assertEquals(1.0, frn[5].value, Double.MIN_VALUE);
fr = facetResults.get(2);
parentRes = fr.getFacetResultNode();
- assertEquals(7.0, parentRes.getValue(), Double.MIN_VALUE);
+ assertEquals(7.0, parentRes.value, Double.MIN_VALUE);
frn = resultNodesAsArray(parentRes);
- assertEquals(2.0, frn[0].getValue(), Double.MIN_VALUE);
- assertEquals(2.0, frn[1].getValue(), Double.MIN_VALUE);
- assertEquals(1.0, frn[2].getValue(), Double.MIN_VALUE);
- assertEquals(1.0, frn[3].getValue(), Double.MIN_VALUE);
+ assertEquals(2.0, frn[0].value, Double.MIN_VALUE);
+ assertEquals(2.0, frn[1].value, Double.MIN_VALUE);
+ assertEquals(1.0, frn[2].value, Double.MIN_VALUE);
+ assertEquals(1.0, frn[3].value, Double.MIN_VALUE);
fr = facetResults.get(3);
parentRes = fr.getFacetResultNode();
- assertEquals(2.0, parentRes.getValue(), Double.MIN_VALUE);
+ assertEquals(2.0, parentRes.value, Double.MIN_VALUE);
frn = resultNodesAsArray(parentRes);
assertEquals(0, frn.length);
fr = facetResults.get(4);
parentRes = fr.getFacetResultNode();
- assertEquals(6.0, parentRes.getValue(), Double.MIN_VALUE);
+ assertEquals(6.0, parentRes.value, Double.MIN_VALUE);
frn = resultNodesAsArray(parentRes);
- assertEquals(1.0, frn[0].getValue(), Double.MIN_VALUE);
+ assertEquals(1.0, frn[0].value, Double.MIN_VALUE);
closeAll();
}
}
@@ -172,13 +166,7 @@ public class TestTopKResultsHandler exte
};
searcher.search(new MatchAllDocsQuery(), fc);
- long start = System.currentTimeMillis();
List<FacetResult> results = fc.getFacetResults();
- long end = System.currentTimeMillis();
-
- if (VERBOSE) {
- System.out.println("Time: " + (end - start));
- }
assertEquals("Should only be one result as there's only one request", 1, results.size());
FacetResult res = results.get(0);
@@ -230,14 +218,8 @@ public class TestTopKResultsHandler exte
searcher.search(new MatchAllDocsQuery(), fc);
- long start = System.currentTimeMillis();
List<FacetResult> facetResults = fc.getFacetResults();
- long end = System.currentTimeMillis();
- if (VERBOSE) {
- System.out.println("Time: " + (end - start));
- }
-
assertEquals("Shouldn't have found anything for a FacetRequest "
+ "of a facet that doesn't exist in the index.", 0, facetResults.size());
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTopKResultsHandlerRandom.java Mon Jan 21 11:29:01 2013
@@ -88,15 +88,15 @@ public class TestTopKResultsHandlerRando
int k = 0;
for (FacetResult fr : allFacetResults) {
FacetResultNode topResNode = fr.getFacetResultNode();
- maxNumNodes = Math.max(maxNumNodes, topResNode.getNumSubResults());
+ maxNumNodes = Math.max(maxNumNodes, topResNode.subResults.size());
int prevCount = Integer.MAX_VALUE;
int pos = 0;
- for (FacetResultNode frn: topResNode.getSubResults()) {
- assertTrue("wrong counts order: prev="+prevCount+" curr="+frn.getValue(), prevCount>=frn.getValue());
- prevCount = (int) frn.getValue();
- String key = k+"--"+frn.getLabel()+"=="+frn.getValue();
+ for (FacetResultNode frn: topResNode.subResults) {
+ assertTrue("wrong counts order: prev="+prevCount+" curr="+frn.value, prevCount>=frn.value);
+ prevCount = (int) frn.value;
+ String key = k+"--"+frn.label+"=="+frn.value;
if (VERBOSE) {
- System.out.println(frn.getLabel() + " - " + frn.getValue() + " "+key+" "+pos);
+ System.out.println(frn.label + " - " + frn.value + " "+key+" "+pos);
}
all.put(key, pos++); // will use this later to verify order of sub-results
}
@@ -113,12 +113,12 @@ public class TestTopKResultsHandlerRando
k = 0;
for (FacetResult fr : someResults) {
FacetResultNode topResNode = fr.getFacetResultNode();
- assertTrue("too many results: n="+n+" but got "+topResNode.getNumSubResults(), n>=topResNode.getNumSubResults());
+ assertTrue("too many results: n="+n+" but got "+topResNode.subResults.size(), n>=topResNode.subResults.size());
int pos = 0;
- for (FacetResultNode frn: topResNode.getSubResults()) {
- String key = k+"--"+frn.getLabel()+"=="+frn.getValue();
+ for (FacetResultNode frn: topResNode.subResults) {
+ String key = k+"--"+frn.label+"=="+frn.value;
if (VERBOSE) {
- System.out.println(frn.getLabel() + " - " + frn.getValue() + " "+key+" "+pos);
+ System.out.println(frn.label + " - " + frn.value + " "+key+" "+pos);
}
Integer origPos = all.get(key);
assertNotNull("missing in all results: "+frn,origPos);
Modified: lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java?rev=1436281&r1=1436280&r2=1436281&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java (original)
+++ lucene/dev/branches/branch_4x/lucene/facet/src/test/org/apache/lucene/facet/search/TestTotalFacetCountsCache.java Mon Jan 21 11:29:01 2013
@@ -228,9 +228,9 @@ public class TestTotalFacetCountsCache e
FacetResult result = results.get(i);
assertNotNull("Result should not be null", result);
FacetResultNode resNode = result.getFacetResultNode();
- assertEquals("Invalid label", expLabels[i], resNode.getLabel().toString());
- assertEquals("Invalid value", expValues[i], resNode.getValue(), 0.0);
- assertEquals("Invalid number of subresults", 0, resNode.getNumSubResults());
+ assertEquals("Invalid label", expLabels[i], resNode.label.toString());
+ assertEquals("Invalid value", expValues[i], resNode.value, 0.0);
+ assertEquals("Invalid number of subresults", 0, resNode.subResults.size());
}
// we're done, close the index reader and the taxonomy.
slowIndexReader.close();