LUCENE-4951: cutover another freq -> cost

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1471738 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2013-04-24 22:20:20 +00:00
parent 5ba67e9c74
commit 992dab017e
2 changed files with 16 additions and 7 deletions

View File

@ -131,8 +131,11 @@ class DrillSidewaysQuery extends Query {
dims[dim].docsEnums = new DocsEnum[drillDownTerms[dim].length];
for(int i=0;i<drillDownTerms[dim].length;i++) {
if (termsEnum.seekExact(drillDownTerms[dim][i].bytes(), false)) {
dims[dim].maxFreq = Math.max(dims[dim].maxFreq, termsEnum.docFreq());
dims[dim].docsEnums[i] = termsEnum.docs(null, null);
DocsEnum docsEnum = termsEnum.docs(null, null);
if (docsEnum != null) {
dims[dim].docsEnums[i] = docsEnum;
dims[dim].maxCost = Math.max(dims[dim].maxCost, docsEnum.cost());
}
}
}
}

View File

@ -107,7 +107,7 @@ class DrillSidewaysScorer extends Scorer {
/*
System.out.println("\nbaseDocID=" + baseScorer.docID() + " est=" + estBaseHitCount);
System.out.println(" maxDoc=" + context.reader().maxDoc());
System.out.println(" maxFreq=" + maxFreq);
System.out.println(" maxCost=" + maxCost);
System.out.println(" dims[0].freq=" + dims[0].freq);
if (numDims > 1) {
System.out.println(" dims[1].freq=" + dims[1].freq);
@ -119,7 +119,7 @@ class DrillSidewaysScorer extends Scorer {
if (baseQueryCost < drillDownCost/10) {
//System.out.println("baseAdvance");
doBaseAdvanceScoring(collector, docsEnums, sidewaysCollectors);
} else if (numDims > 1 && (dims[1].maxFreq < baseQueryCost/10)) {
} else if (numDims > 1 && (dims[1].maxCost < baseQueryCost/10)) {
//System.out.println("drillDownAdvance");
doDrillDownAdvanceScoring(collector, docsEnums, sidewaysCollectors);
} else {
@ -640,14 +640,20 @@ class DrillSidewaysScorer extends Scorer {
static class DocsEnumsAndFreq implements Comparable<DocsEnumsAndFreq> {
DocsEnum[] docsEnums;
// Max docFreq for all docsEnums for this dim:
int maxFreq;
// Max cost for all docsEnums for this dim:
long maxCost;
Collector sidewaysCollector;
String dim;
@Override
public int compareTo(DocsEnumsAndFreq other) {
return maxFreq - other.maxFreq;
if (maxCost < other.maxCost) {
return -1;
} else if (maxCost > other.maxCost) {
return 1;
} else {
return 0;
}
}
}
}