You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2015/06/25 19:07:14 UTC
svn commit: r1687581 [6/9] - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/analysis/common/src/test/org/apache/lucene/analysis/core/
lucene/analysis/common/src/test/org/apache/lucene/analysis/sinks/
lucene/analysis/common/src/test/org/apache/luc...
Modified: lucene/dev/branches/branch_5x/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java (original)
+++ lucene/dev/branches/branch_5x/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java Thu Jun 25 17:07:11 2015
@@ -104,7 +104,7 @@ public class FieldTermStack {
if (!termSet.contains(term)) {
continue;
}
- dpEnum = termsEnum.postings(null, dpEnum, PostingsEnum.POSITIONS);
+ dpEnum = termsEnum.postings(dpEnum, PostingsEnum.POSITIONS);
dpEnum.nextDoc();
// For weight look here: http://lucene.apache.org/core/3_6_0/api/core/org/apache/lucene/search/DefaultSimilarity.html
Modified: lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsQuery.java Thu Jun 25 17:07:11 2015
@@ -139,13 +139,13 @@ final class GlobalOrdinalsQuery extends
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
SortedDocValues values = DocValues.getSorted(context.reader(), joinField);
if (values == null) {
return null;
}
- Scorer approximationScorer = approximationWeight.scorer(context, acceptDocs);
+ Scorer approximationScorer = approximationWeight.scorer(context);
if (approximationScorer == null) {
return null;
}
Modified: lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsWithScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsWithScoreQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsWithScoreQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsWithScoreQuery.java Thu Jun 25 17:07:11 2015
@@ -155,13 +155,13 @@ final class GlobalOrdinalsWithScoreQuery
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
SortedDocValues values = DocValues.getSorted(context.reader(), joinField);
if (values == null) {
return null;
}
- Scorer approximationScorer = approximationWeight.scorer(context, acceptDocs);
+ Scorer approximationScorer = approximationWeight.scorer(context);
if (approximationScorer == null) {
return null;
} else if (globalOrds != null) {
Modified: lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java Thu Jun 25 17:07:11 2015
@@ -133,7 +133,7 @@ class TermsIncludingScoreQuery extends Q
PostingsEnum postingsEnum = null;
for (int i = 0; i < TermsIncludingScoreQuery.this.terms.size(); i++) {
if (segmentTermsEnum.seekExact(TermsIncludingScoreQuery.this.terms.get(ords[i], spare))) {
- postingsEnum = segmentTermsEnum.postings(null, postingsEnum, PostingsEnum.NONE);
+ postingsEnum = segmentTermsEnum.postings(postingsEnum, PostingsEnum.NONE);
if (postingsEnum.advance(doc) == doc) {
final float score = TermsIncludingScoreQuery.this.scores[ords[i]];
return Explanation.match(score, "Score based on join value " + segmentTermsEnum.term().utf8ToString());
@@ -155,7 +155,7 @@ class TermsIncludingScoreQuery extends Q
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
Terms terms = context.reader().terms(field);
if (terms == null) {
return null;
@@ -166,9 +166,9 @@ class TermsIncludingScoreQuery extends Q
TermsEnum segmentTermsEnum = terms.iterator();
if (multipleValuesPerDocument) {
- return new MVInOrderScorer(this, acceptDocs, segmentTermsEnum, context.reader().maxDoc(), cost);
+ return new MVInOrderScorer(this, segmentTermsEnum, context.reader().maxDoc(), cost);
} else {
- return new SVInOrderScorer(this, acceptDocs, segmentTermsEnum, context.reader().maxDoc(), cost);
+ return new SVInOrderScorer(this, segmentTermsEnum, context.reader().maxDoc(), cost);
}
}
@@ -183,21 +183,21 @@ class TermsIncludingScoreQuery extends Q
int currentDoc = -1;
- SVInOrderScorer(Weight weight, Bits acceptDocs, TermsEnum termsEnum, int maxDoc, long cost) throws IOException {
+ SVInOrderScorer(Weight weight, TermsEnum termsEnum, int maxDoc, long cost) throws IOException {
super(weight);
FixedBitSet matchingDocs = new FixedBitSet(maxDoc);
this.scores = new float[maxDoc];
- fillDocsAndScores(matchingDocs, acceptDocs, termsEnum);
+ fillDocsAndScores(matchingDocs, termsEnum);
this.matchingDocsIterator = new BitSetIterator(matchingDocs, cost);
this.cost = cost;
}
- protected void fillDocsAndScores(FixedBitSet matchingDocs, Bits acceptDocs, TermsEnum termsEnum) throws IOException {
+ protected void fillDocsAndScores(FixedBitSet matchingDocs, TermsEnum termsEnum) throws IOException {
BytesRef spare = new BytesRef();
PostingsEnum postingsEnum = null;
for (int i = 0; i < terms.size(); i++) {
if (termsEnum.seekExact(terms.get(ords[i], spare))) {
- postingsEnum = termsEnum.postings(acceptDocs, postingsEnum, PostingsEnum.NONE);
+ postingsEnum = termsEnum.postings(postingsEnum, PostingsEnum.NONE);
float score = TermsIncludingScoreQuery.this.scores[ords[i]];
for (int doc = postingsEnum.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = postingsEnum.nextDoc()) {
matchingDocs.set(doc);
@@ -243,17 +243,17 @@ class TermsIncludingScoreQuery extends Q
// This scorer deals with the fact that a document can have more than one score from multiple related documents.
class MVInOrderScorer extends SVInOrderScorer {
- MVInOrderScorer(Weight weight, Bits acceptDocs, TermsEnum termsEnum, int maxDoc, long cost) throws IOException {
- super(weight, acceptDocs, termsEnum, maxDoc, cost);
+ MVInOrderScorer(Weight weight, TermsEnum termsEnum, int maxDoc, long cost) throws IOException {
+ super(weight, termsEnum, maxDoc, cost);
}
@Override
- protected void fillDocsAndScores(FixedBitSet matchingDocs, Bits acceptDocs, TermsEnum termsEnum) throws IOException {
+ protected void fillDocsAndScores(FixedBitSet matchingDocs, TermsEnum termsEnum) throws IOException {
BytesRef spare = new BytesRef();
PostingsEnum postingsEnum = null;
for (int i = 0; i < terms.size(); i++) {
if (termsEnum.seekExact(terms.get(ords[i], spare))) {
- postingsEnum = termsEnum.postings(acceptDocs, postingsEnum, PostingsEnum.NONE);
+ postingsEnum = termsEnum.postings(postingsEnum, PostingsEnum.NONE);
float score = TermsIncludingScoreQuery.this.scores[ords[i]];
for (int doc = postingsEnum.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = postingsEnum.nextDoc()) {
// I prefer this:
Modified: lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java Thu Jun 25 17:07:11 2015
@@ -33,7 +33,6 @@ import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
import org.apache.lucene.util.BitDocIdSet;
import org.apache.lucene.util.BitSet;
-import org.apache.lucene.util.Bits;
/**
* Just like {@link ToParentBlockJoinQuery}, except this
@@ -122,9 +121,9 @@ public class ToChildBlockJoinQuery exten
// NOTE: acceptDocs applies (and is checked) only in the
// child document space
@Override
- public Scorer scorer(LeafReaderContext readerContext, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext readerContext) throws IOException {
- final Scorer parentScorer = parentWeight.scorer(readerContext, null);
+ final Scorer parentScorer = parentWeight.scorer(readerContext);
if (parentScorer == null) {
// No matches
@@ -139,12 +138,12 @@ public class ToChildBlockJoinQuery exten
return null;
}
- return new ToChildBlockJoinScorer(this, parentScorer, parents.bits(), doScores, acceptDocs);
+ return new ToChildBlockJoinScorer(this, parentScorer, parents.bits(), doScores);
}
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
- ToChildBlockJoinScorer scorer = (ToChildBlockJoinScorer) scorer(context, context.reader().getLiveDocs());
+ ToChildBlockJoinScorer scorer = (ToChildBlockJoinScorer) scorer(context);
if (scorer != null && scorer.advance(doc) == doc) {
int parentDoc = scorer.getParentDoc();
return Explanation.match(
@@ -161,7 +160,6 @@ public class ToChildBlockJoinQuery exten
private final Scorer parentScorer;
private final BitSet parentBits;
private final boolean doScores;
- private final Bits acceptDocs;
private float parentScore;
private int parentFreq = 1;
@@ -169,12 +167,11 @@ public class ToChildBlockJoinQuery exten
private int childDoc = -1;
private int parentDoc = 0;
- public ToChildBlockJoinScorer(Weight weight, Scorer parentScorer, BitSet parentBits, boolean doScores, Bits acceptDocs) {
+ public ToChildBlockJoinScorer(Weight weight, Scorer parentScorer, BitSet parentBits, boolean doScores) {
super(weight);
this.doScores = doScores;
this.parentBits = parentBits;
this.parentScorer = parentScorer;
- this.acceptDocs = acceptDocs;
}
@Override
@@ -186,8 +183,6 @@ public class ToChildBlockJoinQuery exten
public int nextDoc() throws IOException {
//System.out.println("Q.nextDoc() parentDoc=" + parentDoc + " childDoc=" + childDoc);
- // Loop until we hit a childDoc that's accepted
- nextChildDoc:
while (true) {
if (childDoc+1 == parentDoc) {
// OK, we are done iterating through all children
@@ -224,20 +219,6 @@ public class ToChildBlockJoinQuery exten
continue;
}
- if (acceptDocs != null && !acceptDocs.get(childDoc)) {
- // find the first child that is accepted
- while (true) {
- if (childDoc+1 < parentDoc) {
- childDoc++;
- if (acceptDocs.get(childDoc))
- break;
- } else {
- // no child for this parent doc matches acceptDocs
- continue nextChildDoc;
- }
- }
- }
-
if (childDoc < parentDoc) {
if (doScores) {
parentScore = parentScorer.score();
@@ -252,9 +233,6 @@ public class ToChildBlockJoinQuery exten
} else {
assert childDoc < parentDoc: "childDoc=" + childDoc + " parentDoc=" + parentDoc;
childDoc++;
- if (acceptDocs != null && !acceptDocs.get(childDoc)) {
- continue;
- }
//System.out.println(" " + childDoc);
return childDoc;
}
@@ -323,9 +301,6 @@ public class ToChildBlockJoinQuery exten
assert !parentBits.get(childTarget);
childDoc = childTarget;
//System.out.println(" " + childDoc);
- if (acceptDocs != null && !acceptDocs.get(childDoc)) {
- nextDoc();
- }
return childDoc;
}
Modified: lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinIndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinIndexSearcher.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinIndexSearcher.java (original)
+++ lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinIndexSearcher.java Thu Jun 25 17:07:11 2015
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutorService;
-import org.apache.lucene.index.PostingsEnum;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.Collector;
@@ -30,6 +29,7 @@ import org.apache.lucene.search.IndexSea
import org.apache.lucene.search.LeafCollector;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
+import org.apache.lucene.util.Bits;
/**
* An {@link IndexSearcher} to use in conjunction with
@@ -56,12 +56,15 @@ public class ToParentBlockJoinIndexSearc
// we force the use of Scorer (not BulkScorer) to make sure
// that the scorer passed to LeafCollector.setScorer supports
// Scorer.getChildren
- Scorer scorer = weight.scorer(ctx, ctx.reader().getLiveDocs());
+ Scorer scorer = weight.scorer(ctx);
if (scorer != null) {
final LeafCollector leafCollector = collector.getLeafCollector(ctx);
leafCollector.setScorer(scorer);
+ final Bits liveDocs = ctx.reader().getLiveDocs();
for (int doc = scorer.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = scorer.nextDoc()) {
- leafCollector.collect(doc);
+ if (liveDocs == null || liveDocs.get(doc)) {
+ leafCollector.collect(doc);
+ }
}
}
}
Modified: lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java Thu Jun 25 17:07:11 2015
@@ -157,9 +157,9 @@ public class ToParentBlockJoinQuery exte
// NOTE: acceptDocs applies (and is checked) only in the
// parent document space
@Override
- public Scorer scorer(LeafReaderContext readerContext, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext readerContext) throws IOException {
- final Scorer childScorer = childWeight.scorer(readerContext, readerContext.reader().getLiveDocs());
+ final Scorer childScorer = childWeight.scorer(readerContext);
if (childScorer == null) {
// No matches
return null;
@@ -180,12 +180,12 @@ public class ToParentBlockJoinQuery exte
return null;
}
- return new BlockJoinScorer(this, childScorer, parents.bits(), firstChildDoc, scoreMode, acceptDocs);
+ return new BlockJoinScorer(this, childScorer, parents.bits(), firstChildDoc, scoreMode);
}
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
- BlockJoinScorer scorer = (BlockJoinScorer) scorer(context, context.reader().getLiveDocs());
+ BlockJoinScorer scorer = (BlockJoinScorer) scorer(context);
if (scorer != null && scorer.advance(doc) == doc) {
return scorer.explain(context.docBase);
}
@@ -197,7 +197,6 @@ public class ToParentBlockJoinQuery exte
private final Scorer childScorer;
private final BitSet parentBits;
private final ScoreMode scoreMode;
- private final Bits acceptDocs;
private int parentDoc = -1;
private int prevParentDoc;
private float parentScore;
@@ -207,13 +206,12 @@ public class ToParentBlockJoinQuery exte
private float[] pendingChildScores;
private int childDocUpto;
- public BlockJoinScorer(Weight weight, Scorer childScorer, BitSet parentBits, int firstChildDoc, ScoreMode scoreMode, Bits acceptDocs) {
+ public BlockJoinScorer(Weight weight, Scorer childScorer, BitSet parentBits, int firstChildDoc, ScoreMode scoreMode) {
super(weight);
//System.out.println("Q.init firstChildDoc=" + firstChildDoc);
this.parentBits = parentBits;
this.childScorer = childScorer;
this.scoreMode = scoreMode;
- this.acceptDocs = acceptDocs;
nextChildDoc = firstChildDoc;
}
@@ -256,104 +254,84 @@ public class ToParentBlockJoinQuery exte
@Override
public int nextDoc() throws IOException {
//System.out.println("Q.nextDoc() nextChildDoc=" + nextChildDoc);
- // Loop until we hit a parentDoc that's accepted
- while (true) {
- if (nextChildDoc == NO_MORE_DOCS) {
- //System.out.println(" end");
- return parentDoc = NO_MORE_DOCS;
- }
+ if (nextChildDoc == NO_MORE_DOCS) {
+ //System.out.println(" end");
+ return parentDoc = NO_MORE_DOCS;
+ }
- // Gather all children sharing the same parent as
- // nextChildDoc
+ // Gather all children sharing the same parent as
+ // nextChildDoc
- parentDoc = parentBits.nextSetBit(nextChildDoc);
+ parentDoc = parentBits.nextSetBit(nextChildDoc);
- // Parent & child docs are supposed to be
- // orthogonal:
- if (nextChildDoc == parentDoc) {
- throw new IllegalStateException("child query must only match non-parent docs, but parent docID=" + nextChildDoc + " matched childScorer=" + childScorer.getClass());
- }
+ // Parent & child docs are supposed to be
+ // orthogonal:
+ if (nextChildDoc == parentDoc) {
+ throw new IllegalStateException("child query must only match non-parent docs, but parent docID=" + nextChildDoc + " matched childScorer=" + childScorer.getClass());
+ }
- //System.out.println(" parentDoc=" + parentDoc);
- assert parentDoc != DocIdSetIterator.NO_MORE_DOCS;
+ //System.out.println(" parentDoc=" + parentDoc);
+ assert parentDoc != DocIdSetIterator.NO_MORE_DOCS;
- //System.out.println(" nextChildDoc=" + nextChildDoc);
- if (acceptDocs != null && !acceptDocs.get(parentDoc)) {
- // Parent doc not accepted; skip child docs until
- // we hit a new parent doc:
- do {
- nextChildDoc = childScorer.nextDoc();
- } while (nextChildDoc < parentDoc);
-
- // Parent & child docs are supposed to be
- // orthogonal:
- if (nextChildDoc == parentDoc) {
- throw new IllegalStateException("child query must only match non-parent docs, but parent docID=" + nextChildDoc + " matched childScorer=" + childScorer.getClass());
- }
+ float totalScore = 0;
+ float maxScore = Float.NEGATIVE_INFINITY;
+ float minScore = Float.POSITIVE_INFINITY;
- continue;
- }
+ childDocUpto = 0;
+ parentFreq = 0;
+ do {
- float totalScore = 0;
- float maxScore = Float.NEGATIVE_INFINITY;
- float minScore = Float.POSITIVE_INFINITY;
-
- childDocUpto = 0;
- parentFreq = 0;
- do {
-
- //System.out.println(" c=" + nextChildDoc);
- if (pendingChildDocs != null && pendingChildDocs.length == childDocUpto) {
- pendingChildDocs = ArrayUtil.grow(pendingChildDocs);
- }
- if (pendingChildScores != null && scoreMode != ScoreMode.None && pendingChildScores.length == childDocUpto) {
- pendingChildScores = ArrayUtil.grow(pendingChildScores);
- }
- if (pendingChildDocs != null) {
- pendingChildDocs[childDocUpto] = nextChildDoc;
- }
- if (scoreMode != ScoreMode.None) {
- // TODO: specialize this into dedicated classes per-scoreMode
- final float childScore = childScorer.score();
- final int childFreq = childScorer.freq();
- if (pendingChildScores != null) {
- pendingChildScores[childDocUpto] = childScore;
- }
- maxScore = Math.max(childScore, maxScore);
- minScore = Math.min(childFreq, minScore);
- totalScore += childScore;
- parentFreq += childFreq;
- }
- childDocUpto++;
- nextChildDoc = childScorer.nextDoc();
- } while (nextChildDoc < parentDoc);
-
- // Parent & child docs are supposed to be
- // orthogonal:
- if (nextChildDoc == parentDoc) {
- throw new IllegalStateException("child query must only match non-parent docs, but parent docID=" + nextChildDoc + " matched childScorer=" + childScorer.getClass());
+ //System.out.println(" c=" + nextChildDoc);
+ if (pendingChildDocs != null && pendingChildDocs.length == childDocUpto) {
+ pendingChildDocs = ArrayUtil.grow(pendingChildDocs);
}
-
- switch(scoreMode) {
- case Avg:
- parentScore = totalScore / childDocUpto;
- break;
- case Max:
- parentScore = maxScore;
- break;
- case Min:
- parentScore = minScore;
- break;
- case Total:
- parentScore = totalScore;
- break;
- case None:
- break;
+ if (pendingChildScores != null && scoreMode != ScoreMode.None && pendingChildScores.length == childDocUpto) {
+ pendingChildScores = ArrayUtil.grow(pendingChildScores);
}
-
- //System.out.println(" return parentDoc=" + parentDoc + " childDocUpto=" + childDocUpto);
- return parentDoc;
+ if (pendingChildDocs != null) {
+ pendingChildDocs[childDocUpto] = nextChildDoc;
+ }
+ if (scoreMode != ScoreMode.None) {
+ // TODO: specialize this into dedicated classes per-scoreMode
+ final float childScore = childScorer.score();
+ final int childFreq = childScorer.freq();
+ if (pendingChildScores != null) {
+ pendingChildScores[childDocUpto] = childScore;
+ }
+ maxScore = Math.max(childScore, maxScore);
+ minScore = Math.min(childFreq, minScore);
+ totalScore += childScore;
+ parentFreq += childFreq;
+ }
+ childDocUpto++;
+ nextChildDoc = childScorer.nextDoc();
+ } while (nextChildDoc < parentDoc);
+
+ // Parent & child docs are supposed to be
+ // orthogonal:
+ if (nextChildDoc == parentDoc) {
+ throw new IllegalStateException("child query must only match non-parent docs, but parent docID=" + nextChildDoc + " matched childScorer=" + childScorer.getClass());
+ }
+
+ switch(scoreMode) {
+ case Avg:
+ parentScore = totalScore / childDocUpto;
+ break;
+ case Max:
+ parentScore = maxScore;
+ break;
+ case Min:
+ parentScore = minScore;
+ break;
+ case Total:
+ parentScore = totalScore;
+ break;
+ case None:
+ break;
}
+
+ //System.out.println(" return parentDoc=" + parentDoc + " childDocUpto=" + childDocUpto);
+ return parentDoc;
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java (original)
+++ lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java Thu Jun 25 17:07:11 2015
@@ -55,6 +55,7 @@ import org.apache.lucene.search.Filter;
import org.apache.lucene.search.FilteredQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.search.PrefixQuery;
@@ -415,7 +416,7 @@ public class TestBlockJoin extends Lucen
w.close();
IndexSearcher s = newSearcher(r);
- ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(new MatchAllDocsQuery(), new BitDocIdSetCachingWrapperFilter(new QueryWrapperFilter(new MatchAllDocsQuery())), ScoreMode.Avg);
+ ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(new MatchNoDocsQuery(), new BitDocIdSetCachingWrapperFilter(new QueryWrapperFilter(new MatchAllDocsQuery())), ScoreMode.Avg);
QueryUtils.check(random(), q, s);
s.search(q, 10);
BooleanQuery bq = new BooleanQuery();
@@ -426,61 +427,6 @@ public class TestBlockJoin extends Lucen
dir.close();
}
- public void testNestedDocScoringWithDeletes() throws Exception {
- final Directory dir = newDirectory();
- final RandomIndexWriter w = new RandomIndexWriter(
- random(),
- dir,
- newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(NoMergePolicy.INSTANCE));
-
- // Cannot assert this since we use NoMergePolicy:
- w.setDoRandomForceMergeAssert(false);
-
- List<Document> docs = new ArrayList<>();
- docs.add(makeJob("java", 2007));
- docs.add(makeJob("python", 2010));
- docs.add(makeResume("Lisa", "United Kingdom"));
- w.addDocuments(docs);
-
- docs.clear();
- docs.add(makeJob("c", 1999));
- docs.add(makeJob("ruby", 2005));
- docs.add(makeJob("java", 2006));
- docs.add(makeResume("Frank", "United States"));
- w.addDocuments(docs);
-
- w.commit();
- IndexSearcher s = newSearcher(DirectoryReader.open(dir));
-
- ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(
- NumericRangeQuery.newIntRange("year", 1990, 2010, true, true),
- new BitDocIdSetCachingWrapperFilter(new QueryWrapperFilter(new TermQuery(new Term("docType", "resume")))),
- ScoreMode.Total
- );
-
- TopDocs topDocs = s.search(q, 10);
- assertEquals(2, topDocs.totalHits);
- assertEquals(6, topDocs.scoreDocs[0].doc);
- assertEquals(3.0f, topDocs.scoreDocs[0].score, 0.0f);
- assertEquals(2, topDocs.scoreDocs[1].doc);
- assertEquals(2.0f, topDocs.scoreDocs[1].score, 0.0f);
-
- s.getIndexReader().close();
- w.deleteDocuments(new Term("skill", "java"));
- w.close();
- s = newSearcher(DirectoryReader.open(dir));
-
- topDocs = s.search(q, 10);
- assertEquals(2, topDocs.totalHits);
- assertEquals(6, topDocs.scoreDocs[0].doc);
- assertEquals(2.0f, topDocs.scoreDocs[0].score, 0.0f);
- assertEquals(2, topDocs.scoreDocs[1].doc);
- assertEquals(1.0f, topDocs.scoreDocs[1].score, 0.0f);
-
- s.getIndexReader().close();
- dir.close();
- }
-
private String[][] getRandomFields(int maxUniqueValues) {
final String[][] fields = new String[TestUtil.nextInt(random(), 2, 4)][];
@@ -669,7 +615,7 @@ public class TestBlockJoin extends Lucen
for(int docIDX=0;docIDX<joinR.maxDoc();docIDX++) {
System.out.println(" docID=" + docIDX + " doc=" + joinR.document(docIDX) + " deleted?=" + (liveDocs != null && liveDocs.get(docIDX) == false));
}
- PostingsEnum parents = MultiFields.getTermDocsEnum(joinR, null, "isParent", new BytesRef("x"));
+ PostingsEnum parents = MultiFields.getTermDocsEnum(joinR, "isParent", new BytesRef("x"));
System.out.println("parent docIDs:");
while (parents.nextDoc() != PostingsEnum.NO_MORE_DOCS) {
System.out.println(" " + parents.docID());
@@ -1173,7 +1119,7 @@ public class TestBlockJoin extends Lucen
ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(tq, parentFilter, ScoreMode.Avg);
Weight weight = s.createNormalizedWeight(q, true);
- DocIdSetIterator disi = weight.scorer(s.getIndexReader().leaves().get(0), null);
+ DocIdSetIterator disi = weight.scorer(s.getIndexReader().leaves().get(0));
assertEquals(1, disi.advance(1));
r.close();
dir.close();
@@ -1207,7 +1153,7 @@ public class TestBlockJoin extends Lucen
ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(tq, parentFilter, ScoreMode.Avg);
Weight weight = s.createNormalizedWeight(q, true);
- DocIdSetIterator disi = weight.scorer(s.getIndexReader().leaves().get(0), null);
+ DocIdSetIterator disi = weight.scorer(s.getIndexReader().leaves().get(0));
assertEquals(2, disi.advance(0));
r.close();
dir.close();
@@ -1250,7 +1196,7 @@ public class TestBlockJoin extends Lucen
s.search(childJoinQuery, c);
//Get all child documents within groups
- @SuppressWarnings({"unchecked","rawtypes"})
+ @SuppressWarnings({"unchecked"})
TopGroups<Integer>[] getTopGroupsResults = new TopGroups[2];
getTopGroupsResults[0] = c.getTopGroups(childJoinQuery, null, 0, 10, 0, true);
getTopGroupsResults[1] = c.getTopGroupsWithAllChildDocs(childJoinQuery, null, 0, 0, true);
Modified: lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java (original)
+++ lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoinValidation.java Thu Jun 25 17:07:11 2015
@@ -131,7 +131,7 @@ public class TestBlockJoinValidation ext
final LeafReaderContext context = indexSearcher.getIndexReader().leaves().get(0);
Weight weight = indexSearcher.createNormalizedWeight(blockJoinQuery, true);
- Scorer scorer = weight.scorer(context, context.reader().getLiveDocs());
+ Scorer scorer = weight.scorer(context);
final Bits parentDocs = parentsFilter.getDocIdSet(context).bits();
int target;
Modified: lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java (original)
+++ lucene/dev/branches/branch_5x/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java Thu Jun 25 17:07:11 2015
@@ -370,8 +370,8 @@ public class TestJoinUtil extends Lucene
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- Scorer fieldScorer = fieldWeight.scorer(context, acceptDocs);
+ public Scorer scorer(LeafReaderContext context) throws IOException {
+ Scorer fieldScorer = fieldWeight.scorer(context);
final NumericDocValues price = context.reader().getNumericDocValues(priceField);
return new FilterScorer(fieldScorer, this) {
@Override
@@ -1096,7 +1096,7 @@ public class TestJoinUtil extends Lucene
for (BytesRef joinValue : joinValues) {
TermsEnum termsEnum = terms.iterator();
if (termsEnum.seekExact(joinValue)) {
- postingsEnum = termsEnum.postings(slowCompositeReader.getLiveDocs(), postingsEnum, PostingsEnum.NONE);
+ postingsEnum = termsEnum.postings(postingsEnum, PostingsEnum.NONE);
JoinScore joinScore = joinValueToJoinScores.get(joinValue);
for (int doc = postingsEnum.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = postingsEnum.nextDoc()) {
@@ -1219,7 +1219,7 @@ public class TestJoinUtil extends Lucene
}
for (RandomDoc otherSideDoc : otherMatchingDocs) {
- PostingsEnum postingsEnum = MultiFields.getTermDocsEnum(topLevelReader, MultiFields.getLiveDocs(topLevelReader), "id", new BytesRef(otherSideDoc.id), 0);
+ PostingsEnum postingsEnum = MultiFields.getTermDocsEnum(topLevelReader, "id", new BytesRef(otherSideDoc.id), 0);
assert postingsEnum != null;
int doc = postingsEnum.nextDoc();
expectedResult.set(doc);
Modified: lucene/dev/branches/branch_5x/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java (original)
+++ lucene/dev/branches/branch_5x/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java Thu Jun 25 17:07:11 2015
@@ -989,12 +989,12 @@ public class MemoryIndex {
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) {
+ public PostingsEnum postings(PostingsEnum reuse, int flags) {
if (reuse == null || !(reuse instanceof MemoryPostingsEnum)) {
reuse = new MemoryPostingsEnum();
}
final int ord = info.sortedTerms[termUpto];
- return ((MemoryPostingsEnum) reuse).reset(liveDocs, info.sliceArray.start[ord], info.sliceArray.end[ord], info.sliceArray.freq[ord]);
+ return ((MemoryPostingsEnum) reuse).reset(info.sliceArray.start[ord], info.sliceArray.end[ord], info.sliceArray.freq[ord]);
}
@Override
@@ -1016,7 +1016,6 @@ public class MemoryIndex {
private final SliceReader sliceReader;
private int posUpto; // for assert
private boolean hasNext;
- private Bits liveDocs;
private int doc = -1;
private int freq;
private int pos;
@@ -1030,8 +1029,7 @@ public class MemoryIndex {
this.payloadBuilder = storePayloads ? new BytesRefBuilder() : null;
}
- public PostingsEnum reset(Bits liveDocs, int start, int end, int freq) {
- this.liveDocs = liveDocs;
+ public PostingsEnum reset(int start, int end, int freq) {
this.sliceReader.reset(start, end);
posUpto = 0; // for assert
hasNext = true;
@@ -1049,7 +1047,7 @@ public class MemoryIndex {
@Override
public int nextDoc() {
pos = -1;
- if (hasNext && (liveDocs == null || liveDocs.get(0))) {
+ if (hasNext) {
hasNext = false;
return doc = 0;
} else {
Modified: lucene/dev/branches/branch_5x/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndexAgainstRAMDir.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndexAgainstRAMDir.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndexAgainstRAMDir.java (original)
+++ lucene/dev/branches/branch_5x/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndexAgainstRAMDir.java Thu Jun 25 17:07:11 2015
@@ -199,8 +199,8 @@ public class TestMemoryIndexAgainstRAMDi
while(iwTermsIter.next() != null) {
assertNotNull(memTermsIter.next());
assertEquals(iwTermsIter.term(), memTermsIter.term());
- PostingsEnum iwDocsAndPos = iwTermsIter.postings(null, null, PostingsEnum.ALL);
- PostingsEnum memDocsAndPos = memTermsIter.postings(null, null, PostingsEnum.ALL);
+ PostingsEnum iwDocsAndPos = iwTermsIter.postings(null, PostingsEnum.ALL);
+ PostingsEnum memDocsAndPos = memTermsIter.postings(null, PostingsEnum.ALL);
while(iwDocsAndPos.nextDoc() != PostingsEnum.NO_MORE_DOCS) {
assertEquals(iwDocsAndPos.docID(), memDocsAndPos.nextDoc());
assertEquals(iwDocsAndPos.freq(), memDocsAndPos.freq());
@@ -222,8 +222,8 @@ public class TestMemoryIndexAgainstRAMDi
} else {
while(iwTermsIter.next() != null) {
assertEquals(iwTermsIter.term(), memTermsIter.term());
- PostingsEnum iwDocsAndPos = iwTermsIter.postings(null, null);
- PostingsEnum memDocsAndPos = memTermsIter.postings(null, null);
+ PostingsEnum iwDocsAndPos = iwTermsIter.postings(null);
+ PostingsEnum memDocsAndPos = memTermsIter.postings(null);
while(iwDocsAndPos.nextDoc() != PostingsEnum.NO_MORE_DOCS) {
assertEquals(iwDocsAndPos.docID(), memDocsAndPos.nextDoc());
assertEquals(iwDocsAndPos.freq(), memDocsAndPos.freq());
@@ -320,7 +320,7 @@ public class TestMemoryIndexAgainstRAMDi
memory.addField("foo", "bar", analyzer);
LeafReader reader = (LeafReader) memory.createSearcher().getIndexReader();
TestUtil.checkReader(reader);
- PostingsEnum disi = TestUtil.docs(random(), reader, "foo", new BytesRef("bar"), null, null, PostingsEnum.NONE);
+ PostingsEnum disi = TestUtil.docs(random(), reader, "foo", new BytesRef("bar"), null, PostingsEnum.NONE);
int docid = disi.docID();
assertEquals(-1, docid);
assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
@@ -328,7 +328,7 @@ public class TestMemoryIndexAgainstRAMDi
// now reuse and check again
TermsEnum te = reader.terms("foo").iterator();
assertTrue(te.seekExact(new BytesRef("bar")));
- disi = te.postings(null, disi, PostingsEnum.NONE);
+ disi = te.postings(disi, PostingsEnum.NONE);
docid = disi.docID();
assertEquals(-1, docid);
assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
@@ -367,7 +367,7 @@ public class TestMemoryIndexAgainstRAMDi
// now reuse and check again
TermsEnum te = reader.terms("foo").iterator();
assertTrue(te.seekExact(new BytesRef("bar")));
- disi = te.postings(null, disi);
+ disi = te.postings(disi);
docid = disi.docID();
assertEquals(-1, docid);
assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
@@ -536,8 +536,8 @@ public class TestMemoryIndexAgainstRAMDi
assertNotNull(memTermEnum.next());
assertThat(termEnum.totalTermFreq(), equalTo(memTermEnum.totalTermFreq()));
- PostingsEnum docsPosEnum = termEnum.postings(null, null, PostingsEnum.POSITIONS);
- PostingsEnum memDocsPosEnum = memTermEnum.postings(null, null, PostingsEnum.POSITIONS);
+ PostingsEnum docsPosEnum = termEnum.postings(null, PostingsEnum.POSITIONS);
+ PostingsEnum memDocsPosEnum = memTermEnum.postings(null, PostingsEnum.POSITIONS);
String currentTerm = termEnum.term().utf8ToString();
assertThat("Token mismatch for field: " + field_name, currentTerm, equalTo(memTermEnum.term().utf8ToString()));
Modified: lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/index/SortingLeafReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/index/SortingLeafReader.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/index/SortingLeafReader.java (original)
+++ lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/index/SortingLeafReader.java Thu Jun 25 17:07:11 2015
@@ -132,7 +132,7 @@ public class SortingLeafReader extends F
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, final int flags) throws IOException {
+ public PostingsEnum postings( PostingsEnum reuse, final int flags) throws IOException {
if (hasPositions && PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
final PostingsEnum inReuse;
@@ -147,7 +147,7 @@ public class SortingLeafReader extends F
inReuse = reuse;
}
- final PostingsEnum inDocsAndPositions = in.postings(newToOld(liveDocs), inReuse, flags);
+ final PostingsEnum inDocsAndPositions = in.postings(inReuse, flags);
// we ignore the fact that offsets may be stored but not asked for,
// since this code is expected to be used during addIndexes which will
// ask for everything. if that assumption changes in the future, we can
@@ -168,7 +168,7 @@ public class SortingLeafReader extends F
inReuse = reuse;
}
- final PostingsEnum inDocs = in.postings(newToOld(liveDocs), inReuse, flags);
+ final PostingsEnum inDocs = in.postings(inReuse, flags);
final boolean withFreqs = indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS) >=0 && PostingsEnum.featureRequested(flags, PostingsEnum.FREQS);
return new SortingDocsEnum(docMap.size(), wrapReuse, inDocs, withFreqs, docMap);
}
Modified: lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/uninverting/DocTermOrds.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/uninverting/DocTermOrds.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/uninverting/DocTermOrds.java (original)
+++ lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/uninverting/DocTermOrds.java Thu Jun 25 17:07:11 2015
@@ -353,7 +353,7 @@ public class DocTermOrds implements Acco
final int df = te.docFreq();
if (df <= maxTermDocFreq) {
- postingsEnum = te.postings(liveDocs, postingsEnum, PostingsEnum.NONE);
+ postingsEnum = te.postings(postingsEnum, PostingsEnum.NONE);
// dF, but takes deletions into account
int actualDF = 0;
@@ -600,8 +600,8 @@ public class DocTermOrds implements Acco
}
@Override
- public PostingsEnum postings(Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
- return termsEnum.postings(liveDocs, reuse, flags);
+ public PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException {
+ return termsEnum.postings(reuse, flags);
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/uninverting/FieldCacheImpl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/uninverting/FieldCacheImpl.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/uninverting/FieldCacheImpl.java (original)
+++ lucene/dev/branches/branch_5x/lucene/misc/src/java/org/apache/lucene/uninverting/FieldCacheImpl.java Thu Jun 25 17:07:11 2015
@@ -288,7 +288,7 @@ class FieldCacheImpl implements FieldCac
break;
}
visitTerm(term);
- docs = termsEnum.postings(null, docs, PostingsEnum.NONE);
+ docs = termsEnum.postings(docs, PostingsEnum.NONE);
while (true) {
final int docID = docs.nextDoc();
if (docID == DocIdSetIterator.NO_MORE_DOCS) {
@@ -424,7 +424,7 @@ class FieldCacheImpl implements FieldCac
res = new FixedBitSet(maxDoc);
}
- docs = termsEnum.postings(null, docs, PostingsEnum.NONE);
+ docs = termsEnum.postings(docs, PostingsEnum.NONE);
// TODO: use bulk API
while (true) {
final int docID = docs.nextDoc();
@@ -708,7 +708,7 @@ class FieldCacheImpl implements FieldCac
}
termOrdToBytesOffset.add(bytes.copyUsingLengthPrefix(term));
- docs = termsEnum.postings(null, docs, PostingsEnum.NONE);
+ docs = termsEnum.postings(docs, PostingsEnum.NONE);
while (true) {
final int docID = docs.nextDoc();
if (docID == DocIdSetIterator.NO_MORE_DOCS) {
@@ -860,7 +860,7 @@ class FieldCacheImpl implements FieldCac
break;
}
final long pointer = bytes.copyUsingLengthPrefix(term);
- docs = termsEnum.postings(null, docs, PostingsEnum.NONE);
+ docs = termsEnum.postings(docs, PostingsEnum.NONE);
while (true) {
final int docID = docs.nextDoc();
if (docID == DocIdSetIterator.NO_MORE_DOCS) {
Modified: lucene/dev/branches/branch_5x/lucene/misc/src/test/org/apache/lucene/index/SorterTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/misc/src/test/org/apache/lucene/index/SorterTestBase.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/misc/src/test/org/apache/lucene/index/SorterTestBase.java (original)
+++ lucene/dev/branches/branch_5x/lucene/misc/src/test/org/apache/lucene/index/SorterTestBase.java Thu Jun 25 17:07:11 2015
@@ -235,7 +235,7 @@ public abstract class SorterTestBase ext
public void testDocsAndPositionsEnum() throws Exception {
TermsEnum termsEnum = sortedReader.terms(DOC_POSITIONS_FIELD).iterator();
assertEquals(SeekStatus.FOUND, termsEnum.seekCeil(new BytesRef(DOC_POSITIONS_TERM)));
- PostingsEnum sortedPositions = termsEnum.postings(null, null, PostingsEnum.ALL);
+ PostingsEnum sortedPositions = termsEnum.postings(null, PostingsEnum.ALL);
int doc;
// test nextDoc()
@@ -252,7 +252,7 @@ public abstract class SorterTestBase ext
// test advance()
final PostingsEnum reuse = sortedPositions;
- sortedPositions = termsEnum.postings(null, reuse, PostingsEnum.ALL);
+ sortedPositions = termsEnum.postings(reuse, PostingsEnum.ALL);
if (sortedPositions instanceof SortingDocsEnum) {
assertTrue(((SortingDocsEnum) sortedPositions).reused(reuse)); // make sure reuse worked
}
@@ -293,40 +293,25 @@ public abstract class SorterTestBase ext
@Test
public void testDocsEnum() throws Exception {
- Bits mappedLiveDocs = randomLiveDocs(sortedReader.maxDoc());
TermsEnum termsEnum = sortedReader.terms(DOCS_ENUM_FIELD).iterator();
assertEquals(SeekStatus.FOUND, termsEnum.seekCeil(new BytesRef(DOCS_ENUM_TERM)));
- PostingsEnum docs = termsEnum.postings(mappedLiveDocs, null);
+ PostingsEnum docs = termsEnum.postings(null);
int doc;
int prev = -1;
while ((doc = docs.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
- assertTrue("document " + doc + " marked as deleted", mappedLiveDocs == null || mappedLiveDocs.get(doc));
assertEquals("incorrect value; doc " + doc, sortedValues[doc].intValue(), Integer.parseInt(sortedReader.document(doc).get(ID_FIELD)));
- while (++prev < doc) {
- assertFalse("document " + prev + " not marked as deleted", mappedLiveDocs == null || mappedLiveDocs.get(prev));
- }
- }
- while (++prev < sortedReader.maxDoc()) {
- assertFalse("document " + prev + " not marked as deleted", mappedLiveDocs == null || mappedLiveDocs.get(prev));
}
PostingsEnum reuse = docs;
- docs = termsEnum.postings(mappedLiveDocs, reuse);
+ docs = termsEnum.postings(reuse);
if (docs instanceof SortingDocsEnum) {
assertTrue(((SortingDocsEnum) docs).reused(reuse)); // make sure reuse worked
}
doc = -1;
prev = -1;
while ((doc = docs.advance(doc + 1)) != DocIdSetIterator.NO_MORE_DOCS) {
- assertTrue("document " + doc + " marked as deleted", mappedLiveDocs == null || mappedLiveDocs.get(doc));
assertEquals("incorrect value; doc " + doc, sortedValues[doc].intValue(), Integer.parseInt(sortedReader.document(doc).get(ID_FIELD)));
- while (++prev < doc) {
- assertFalse("document " + prev + " not marked as deleted", mappedLiveDocs == null || mappedLiveDocs.get(prev));
- }
- }
- while (++prev < sortedReader.maxDoc()) {
- assertFalse("document " + prev + " not marked as deleted", mappedLiveDocs == null || mappedLiveDocs.get(prev));
}
}
Modified: lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/CustomScoreQuery.java Thu Jun 25 17:07:11 2015
@@ -228,14 +228,14 @@ public class CustomScoreQuery extends Qu
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- Scorer subQueryScorer = subQueryWeight.scorer(context, acceptDocs);
+ public Scorer scorer(LeafReaderContext context) throws IOException {
+ Scorer subQueryScorer = subQueryWeight.scorer(context);
if (subQueryScorer == null) {
return null;
}
Scorer[] valSrcScorers = new Scorer[valSrcWeights.length];
for(int i = 0; i < valSrcScorers.length; i++) {
- valSrcScorers[i] = valSrcWeights[i].scorer(context, acceptDocs);
+ valSrcScorers[i] = valSrcWeights[i].scorer(context);
}
return new CustomScorer(CustomScoreQuery.this.getCustomScoreProvider(context), this, queryWeight, subQueryScorer, valSrcScorers);
}
Modified: lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/TermsFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/TermsFilter.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/TermsFilter.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/TermsFilter.java Thu Jun 25 17:07:11 2015
@@ -32,6 +32,7 @@ import org.apache.lucene.index.LeafReade
import org.apache.lucene.index.Term;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.search.BitsFilteredDocIdSet;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.QueryWrapperFilter;
@@ -216,13 +217,13 @@ public final class TermsFilter extends F
spare.offset = offsets[i];
spare.length = offsets[i+1] - offsets[i];
if (termsEnum.seekExact(spare)) {
- docs = termsEnum.postings(acceptDocs, docs, PostingsEnum.NONE); // no freq since we don't need them
+ docs = termsEnum.postings(docs, PostingsEnum.NONE); // no freq since we don't need them
builder.or(docs);
}
}
}
}
- return builder.build();
+ return BitsFilteredDocIdSet.wrap(builder.build(), acceptDocs);
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/TermsQuery.java Thu Jun 25 17:07:11 2015
@@ -253,7 +253,7 @@ public class TermsQuery extends Query im
* On the given leaf context, try to either rewrite to a disjunction if
* there are few matching terms, or build a bitset containing matching docs.
*/
- private WeightOrBitSet rewrite(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ private WeightOrBitSet rewrite(LeafReaderContext context) throws IOException {
final LeafReader reader = context.reader();
// We will first try to collect up to 'threshold' terms into 'matchingTerms'
@@ -283,18 +283,18 @@ public class TermsQuery extends Query im
}
if (termsEnum != null && termsEnum.seekExact(term)) {
if (matchingTerms == null) {
- docs = termsEnum.postings(acceptDocs, docs, PostingsEnum.NONE);
+ docs = termsEnum.postings(docs, PostingsEnum.NONE);
builder.or(docs);
} else if (matchingTerms.size() < threshold) {
matchingTerms.add(new TermAndState(field, termsEnum));
} else {
assert matchingTerms.size() == threshold;
builder = new BitDocIdSet.Builder(reader.maxDoc());
- docs = termsEnum.postings(acceptDocs, docs, PostingsEnum.NONE);
+ docs = termsEnum.postings(docs, PostingsEnum.NONE);
builder.or(docs);
for (TermAndState t : matchingTerms) {
t.termsEnum.seekExact(t.term, t.state);
- docs = t.termsEnum.postings(acceptDocs, docs, PostingsEnum.NONE);
+ docs = t.termsEnum.postings(docs, PostingsEnum.NONE);
builder.or(docs);
}
matchingTerms = null;
@@ -330,10 +330,10 @@ public class TermsQuery extends Query im
}
@Override
- public BulkScorer bulkScorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- final WeightOrBitSet weightOrBitSet = rewrite(context, acceptDocs);
+ public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
+ final WeightOrBitSet weightOrBitSet = rewrite(context);
if (weightOrBitSet.weight != null) {
- return weightOrBitSet.weight.bulkScorer(context, acceptDocs);
+ return weightOrBitSet.weight.bulkScorer(context);
} else {
final Scorer scorer = scorer(weightOrBitSet.bitset);
if (scorer == null) {
@@ -344,10 +344,10 @@ public class TermsQuery extends Query im
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- final WeightOrBitSet weightOrBitSet = rewrite(context, acceptDocs);
+ public Scorer scorer(LeafReaderContext context) throws IOException {
+ final WeightOrBitSet weightOrBitSet = rewrite(context);
if (weightOrBitSet.weight != null) {
- return weightOrBitSet.weight.scorer(context, acceptDocs);
+ return weightOrBitSet.weight.scorer(context);
} else {
return scorer(weightOrBitSet.bitset);
}
Modified: lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/BoostedQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/BoostedQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/BoostedQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/BoostedQuery.java Thu Jun 25 17:07:11 2015
@@ -98,8 +98,8 @@ public class BoostedQuery extends Query
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- Scorer subQueryScorer = qWeight.scorer(context, acceptDocs);
+ public Scorer scorer(LeafReaderContext context) throws IOException {
+ Scorer subQueryScorer = qWeight.scorer(context);
if (subQueryScorer == null) {
return null;
}
Modified: lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/FunctionQuery.java Thu Jun 25 17:07:11 2015
@@ -89,13 +89,13 @@ public class FunctionQuery extends Query
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
- return new AllScorer(context, acceptDocs, this, queryWeight);
+ public Scorer scorer(LeafReaderContext context) throws IOException {
+ return new AllScorer(context, this, queryWeight);
}
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
- return ((AllScorer)scorer(context, context.reader().getLiveDocs())).explain(doc);
+ return ((AllScorer)scorer(context)).explain(doc);
}
}
@@ -106,15 +106,13 @@ public class FunctionQuery extends Query
final float qWeight;
int doc=-1;
final FunctionValues vals;
- final Bits acceptDocs;
- public AllScorer(LeafReaderContext context, Bits acceptDocs, FunctionWeight w, float qWeight) throws IOException {
+ public AllScorer(LeafReaderContext context, FunctionWeight w, float qWeight) throws IOException {
super(w);
this.weight = w;
this.qWeight = qWeight;
this.reader = context.reader();
this.maxDoc = reader.maxDoc();
- this.acceptDocs = acceptDocs;
vals = func.getValues(weight.context, context);
}
@@ -129,21 +127,16 @@ public class FunctionQuery extends Query
// Boost: foo:myTerm^floatline("myFloatField",1.0,0.0f)
@Override
public int nextDoc() throws IOException {
- for(;;) {
- ++doc;
- if (doc>=maxDoc) {
- return doc=NO_MORE_DOCS;
- }
- if (acceptDocs != null && !acceptDocs.get(doc)) continue;
- return doc;
+ ++doc;
+ if (doc>=maxDoc) {
+ return doc=NO_MORE_DOCS;
}
+ return doc;
}
@Override
public int advance(int target) throws IOException {
- // this will work even if target==NO_MORE_DOCS
- doc=target-1;
- return nextDoc();
+ return slowAdvance(target);
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/QueryValueSource.java Thu Jun 25 17:07:11 2015
@@ -80,7 +80,6 @@ public class QueryValueSource extends Va
class QueryDocValues extends FloatDocValues {
final LeafReaderContext readerContext;
- final Bits acceptDocs;
final Weight weight;
final float defVal;
final Map fcontext;
@@ -99,7 +98,6 @@ class QueryDocValues extends FloatDocVal
super(vs);
this.readerContext = readerContext;
- this.acceptDocs = readerContext.reader().getLiveDocs();
this.defVal = vs.defVal;
this.q = vs.q;
this.fcontext = fcontext;
@@ -126,7 +124,7 @@ class QueryDocValues extends FloatDocVal
try {
if (doc < lastDocRequested) {
if (noMatches) return defVal;
- scorer = weight.scorer(readerContext, acceptDocs);
+ scorer = weight.scorer(readerContext);
if (scorer==null) {
noMatches = true;
return defVal;
@@ -157,7 +155,7 @@ class QueryDocValues extends FloatDocVal
try {
if (doc < lastDocRequested) {
if (noMatches) return false;
- scorer = weight.scorer(readerContext, acceptDocs);
+ scorer = weight.scorer(readerContext);
scorerDoc = -1;
if (scorer==null) {
noMatches = true;
@@ -215,7 +213,7 @@ class QueryDocValues extends FloatDocVal
mval.exists = false;
return;
}
- scorer = weight.scorer(readerContext, acceptDocs);
+ scorer = weight.scorer(readerContext);
scorerDoc = -1;
if (scorer==null) {
noMatches = true;
Modified: lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/TFValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/TFValueSource.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/TFValueSource.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/TFValueSource.java Thu Jun 25 17:07:11 2015
@@ -72,7 +72,7 @@ public class TFValueSource extends TermF
if (terms != null) {
final TermsEnum termsEnum = terms.iterator();
if (termsEnum.seekExact(indexedBytes)) {
- docs = termsEnum.postings(null, null);
+ docs = termsEnum.postings(null);
} else {
docs = null;
}
Modified: lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/TermFreqValueSource.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/TermFreqValueSource.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/TermFreqValueSource.java (original)
+++ lucene/dev/branches/branch_5x/lucene/queries/src/java/org/apache/lucene/queries/function/valuesource/TermFreqValueSource.java Thu Jun 25 17:07:11 2015
@@ -65,7 +65,7 @@ public class TermFreqValueSource extends
if (terms != null) {
final TermsEnum termsEnum = terms.iterator();
if (termsEnum.seekExact(indexedBytes)) {
- docs = termsEnum.postings(null, null);
+ docs = termsEnum.postings(null);
} else {
docs = null;
}
Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInBBoxQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInBBoxQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInBBoxQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInBBoxQuery.java Thu Jun 25 17:07:11 2015
@@ -101,7 +101,7 @@ public class BKDPointInBBoxQuery extends
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
- final Scorer s = scorer(context, context.reader().getLiveDocs());
+ final Scorer s = scorer(context);
final boolean exists = s != null && s.advance(doc) == doc;
if (exists) {
@@ -113,7 +113,7 @@ public class BKDPointInBBoxQuery extends
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
LeafReader reader = context.reader();
SortedNumericDocValues sdv = reader.getSortedNumericDocValues(field);
if (sdv == null) {
@@ -127,7 +127,7 @@ public class BKDPointInBBoxQuery extends
BKDTreeSortedNumericDocValues treeDV = (BKDTreeSortedNumericDocValues) sdv;
BKDTreeReader tree = treeDV.getBKDTreeReader();
- DocIdSet result = tree.intersect(acceptDocs, minLat, maxLat, minLon, maxLon, treeDV.delegate);
+ DocIdSet result = tree.intersect(minLat, maxLat, minLon, maxLon, treeDV.delegate);
final DocIdSetIterator disi = result.iterator();
Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInPolygonQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInPolygonQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInPolygonQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDPointInPolygonQuery.java Thu Jun 25 17:07:11 2015
@@ -132,7 +132,7 @@ public class BKDPointInPolygonQuery exte
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
- final Scorer s = scorer(context, context.reader().getLiveDocs());
+ final Scorer s = scorer(context);
final boolean exists = s != null && s.advance(doc) == doc;
if (exists) {
@@ -144,7 +144,7 @@ public class BKDPointInPolygonQuery exte
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
LeafReader reader = context.reader();
SortedNumericDocValues sdv = reader.getSortedNumericDocValues(field);
if (sdv == null) {
@@ -160,7 +160,7 @@ public class BKDPointInPolygonQuery exte
// TODO: make this more efficient: as we recurse the BKD tree we should check whether the
// bbox we are recursing into intersects our shape; Apache SIS may have (non-GPL!) code to do this?
- DocIdSet result = tree.intersect(acceptDocs, minLat, maxLat, minLon, maxLon,
+ DocIdSet result = tree.intersect(minLat, maxLat, minLon, maxLon,
new BKDTreeReader.LatLonFilter() {
@Override
public boolean accept(double lat, double lon) {
Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeReader.java Thu Jun 25 17:07:11 2015
@@ -97,11 +97,11 @@ final class BKDTreeReader implements Acc
}
}
- public DocIdSet intersect(Bits acceptDocs, double latMin, double latMax, double lonMin, double lonMax, SortedNumericDocValues sndv) throws IOException {
- return intersect(acceptDocs, latMin, latMax, lonMin, lonMax, null, sndv);
+ public DocIdSet intersect(double latMin, double latMax, double lonMin, double lonMax, SortedNumericDocValues sndv) throws IOException {
+ return intersect(latMin, latMax, lonMin, lonMax, null, sndv);
}
- public DocIdSet intersect(Bits acceptDocs, double latMin, double latMax, double lonMin, double lonMax, LatLonFilter filter, SortedNumericDocValues sndv) throws IOException {
+ public DocIdSet intersect(double latMin, double latMax, double lonMin, double lonMax, LatLonFilter filter, SortedNumericDocValues sndv) throws IOException {
if (BKDTreeWriter.validLat(latMin) == false) {
throw new IllegalArgumentException("invalid latMin: " + latMin);
}
@@ -130,7 +130,7 @@ final class BKDTreeReader implements Acc
filter,
sndv);
- int hitCount = intersect(acceptDocs, state, 1,
+ int hitCount = intersect(state, 1,
BKDTreeWriter.encodeLat(-90.0),
BKDTreeWriter.encodeLat(Math.nextAfter(90.0, Double.POSITIVE_INFINITY)),
BKDTreeWriter.encodeLon(-180.0),
@@ -141,7 +141,7 @@ final class BKDTreeReader implements Acc
}
/** Fast path: this is called when the query rect fully encompasses all cells under this node. */
- private int addAll(Bits acceptDocs, QueryState state, int nodeID) throws IOException {
+ private int addAll(QueryState state, int nodeID) throws IOException {
//long latRange = (long) cellLatMaxEnc - (long) cellLatMinEnc;
//long lonRange = (long) cellLonMaxEnc - (long) cellLonMinEnc;
@@ -169,18 +169,9 @@ final class BKDTreeReader implements Acc
//System.out.println(" seek to leafFP=" + fp);
// How many points are stored in this leaf cell:
int count = state.in.readVInt();
- if (acceptDocs != null) {
- for(int i=0;i<count;i++) {
- int docID = state.in.readInt();
- if (acceptDocs.get(docID)) {
- state.bits.set(docID);
- }
- }
- } else {
- for(int i=0;i<count;i++) {
- int docID = state.in.readInt();
- state.bits.set(docID);
- }
+ for(int i=0;i<count;i++) {
+ int docID = state.in.readInt();
+ state.bits.set(docID);
}
//bits.or(allLeafDISI);
@@ -197,14 +188,14 @@ final class BKDTreeReader implements Acc
//System.out.println(" splitValue=" + splitValue);
//System.out.println(" addAll: inner");
- int count = addAll(acceptDocs, state, 2*nodeID);
- count += addAll(acceptDocs, state, 2*nodeID+1);
+ int count = addAll(state, 2*nodeID);
+ count += addAll(state, 2*nodeID+1);
//System.out.println(" addAll: return count=" + count);
return count;
}
}
- private int intersect(Bits acceptDocs, QueryState state,
+ private int intersect(QueryState state,
int nodeID,
int cellLatMinEnc, int cellLatMaxEnc, int cellLonMinEnc, int cellLonMaxEnc)
throws IOException {
@@ -225,7 +216,7 @@ final class BKDTreeReader implements Acc
return 0;
} else if (r == Relation.INSIDE) {
// This cell is fully inside of the query shape: recursively add all points in this cell without filtering
- return addAll(acceptDocs, state, nodeID);
+ return addAll(state, nodeID);
} else {
// The cell crosses the shape boundary, so we fall through and do full filtering
}
@@ -233,7 +224,7 @@ final class BKDTreeReader implements Acc
} else if (state.latMinEnc <= cellLatMinEnc && state.latMaxEnc >= cellLatMaxEnc && state.lonMinEnc <= cellLonMinEnc && state.lonMaxEnc >= cellLonMaxEnc) {
// Optimize the case when the query fully contains this cell: we can
// recursively add all points without checking if they match the query:
- return addAll(acceptDocs, state, nodeID);
+ return addAll(state, nodeID);
}
long latRange = (long) cellLatMaxEnc - (long) cellLatMinEnc;
@@ -275,28 +266,26 @@ final class BKDTreeReader implements Acc
for(int i=0;i<count;i++) {
int docID = state.in.readInt();
- if (acceptDocs == null || acceptDocs.get(docID)) {
- state.sndv.setDocument(docID);
- // How many values this doc has:
- int docValueCount = state.sndv.count();
- for(int j=0;j<docValueCount;j++) {
- long enc = state.sndv.valueAt(j);
-
- int latEnc = (int) ((enc>>32) & 0xffffffffL);
- int lonEnc = (int) (enc & 0xffffffffL);
-
- if (latEnc >= state.latMinEnc &&
- latEnc < state.latMaxEnc &&
- lonEnc >= state.lonMinEnc &&
- lonEnc < state.lonMaxEnc &&
- (state.latLonFilter == null ||
- state.latLonFilter.accept(BKDTreeWriter.decodeLat(latEnc), BKDTreeWriter.decodeLon(lonEnc)))) {
- state.bits.set(docID);
- hitCount++;
-
- // Stop processing values for this doc:
- break;
- }
+ state.sndv.setDocument(docID);
+ // How many values this doc has:
+ int docValueCount = state.sndv.count();
+ for(int j=0;j<docValueCount;j++) {
+ long enc = state.sndv.valueAt(j);
+
+ int latEnc = (int) ((enc>>32) & 0xffffffffL);
+ int lonEnc = (int) (enc & 0xffffffffL);
+
+ if (latEnc >= state.latMinEnc &&
+ latEnc < state.latMaxEnc &&
+ lonEnc >= state.lonMinEnc &&
+ lonEnc < state.lonMaxEnc &&
+ (state.latLonFilter == null ||
+ state.latLonFilter.accept(BKDTreeWriter.decodeLat(latEnc), BKDTreeWriter.decodeLon(lonEnc)))) {
+ state.bits.set(docID);
+ hitCount++;
+
+ // Stop processing values for this doc:
+ break;
}
}
}
@@ -332,7 +321,7 @@ final class BKDTreeReader implements Acc
// Left node:
if (state.latMinEnc < splitValue) {
//System.out.println(" recurse left");
- count += intersect(acceptDocs, state,
+ count += intersect(state,
2*nodeID,
cellLatMinEnc, splitValue, cellLonMinEnc, cellLonMaxEnc);
}
@@ -340,7 +329,7 @@ final class BKDTreeReader implements Acc
// Right node:
if (state.latMaxEnc >= splitValue) {
//System.out.println(" recurse right");
- count += intersect(acceptDocs, state,
+ count += intersect(state,
2*nodeID+1,
splitValue, cellLatMaxEnc, cellLonMinEnc, cellLonMaxEnc);
}
@@ -354,7 +343,7 @@ final class BKDTreeReader implements Acc
// Left node:
if (state.lonMinEnc < splitValue) {
// System.out.println(" recurse left");
- count += intersect(acceptDocs, state,
+ count += intersect(state,
2*nodeID,
cellLatMinEnc, cellLatMaxEnc, cellLonMinEnc, splitValue);
}
@@ -362,7 +351,7 @@ final class BKDTreeReader implements Acc
// Right node:
if (state.lonMaxEnc >= splitValue) {
// System.out.println(" recurse right");
- count += intersect(acceptDocs, state,
+ count += intersect(state,
2*nodeID+1,
cellLatMinEnc, cellLatMaxEnc, splitValue, cellLonMaxEnc);
}
Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/IDVersionPostingsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/IDVersionPostingsReader.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/IDVersionPostingsReader.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/IDVersionPostingsReader.java Thu Jun 25 17:07:11 2015
@@ -66,7 +66,7 @@ final class IDVersionPostingsReader exte
}
@Override
- public PostingsEnum postings(FieldInfo fieldInfo, BlockTermState termState, Bits liveDocs, PostingsEnum reuse, int flags) throws IOException {
+ public PostingsEnum postings(FieldInfo fieldInfo, BlockTermState termState, PostingsEnum reuse, int flags) throws IOException {
SingleDocsEnum docsEnum;
if (PostingsEnum.featureRequested(flags, PostingsEnum.POSITIONS)) {
@@ -78,7 +78,7 @@ final class IDVersionPostingsReader exte
posEnum = new SinglePostingsEnum();
}
IDVersionTermState _termState = (IDVersionTermState) termState;
- posEnum.reset(_termState.docID, _termState.idVersion, liveDocs);
+ posEnum.reset(_termState.docID, _termState.idVersion);
return posEnum;
}
@@ -87,7 +87,7 @@ final class IDVersionPostingsReader exte
} else {
docsEnum = new SingleDocsEnum();
}
- docsEnum.reset(((IDVersionTermState) termState).docID, liveDocs);
+ docsEnum.reset(((IDVersionTermState) termState).docID);
return docsEnum;
}
Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/IDVersionSegmentTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/IDVersionSegmentTermsEnum.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/IDVersionSegmentTermsEnum.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/IDVersionSegmentTermsEnum.java Thu Jun 25 17:07:11 2015
@@ -995,7 +995,7 @@ public final class IDVersionSegmentTerms
}
@Override
- public PostingsEnum postings(Bits skipDocs, PostingsEnum reuse, int flags) throws IOException {
+ public PostingsEnum postings(PostingsEnum reuse, int flags) throws IOException {
assert !eof;
//if (DEBUG) {
//System.out.println("BTTR.docs seg=" + segment);
@@ -1004,7 +1004,7 @@ public final class IDVersionSegmentTerms
//if (DEBUG) {
//System.out.println(" state=" + currentFrame.state);
//}
- return fr.parent.postingsReader.postings(fr.fieldInfo, currentFrame.state, skipDocs, reuse, flags);
+ return fr.parent.postingsReader.postings(fr.fieldInfo, currentFrame.state, reuse, flags);
}
@Override
Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/SingleDocsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/SingleDocsEnum.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/SingleDocsEnum.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/SingleDocsEnum.java Thu Jun 25 17:07:11 2015
@@ -20,25 +20,22 @@ package org.apache.lucene.codecs.idversi
import java.io.IOException;
import org.apache.lucene.index.PostingsEnum;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
class SingleDocsEnum extends PostingsEnum {
private int doc;
private int singleDocID;
- private Bits liveDocs;
/** For reuse */
- public void reset(int singleDocID, Bits liveDocs) {
+ public void reset(int singleDocID) {
doc = -1;
- this.liveDocs = liveDocs;
this.singleDocID = singleDocID;
}
@Override
public int nextDoc() {
- if (doc == -1 && (liveDocs == null || liveDocs.get(singleDocID))) {
+ if (doc == -1) {
doc = singleDocID;
} else {
doc = NO_MORE_DOCS;
@@ -54,7 +51,7 @@ class SingleDocsEnum extends PostingsEnu
@Override
public int advance(int target) {
- if (doc == -1 && target <= singleDocID && (liveDocs == null || liveDocs.get(singleDocID))) {
+ if (doc == -1 && target <= singleDocID) {
doc = singleDocID;
} else {
doc = NO_MORE_DOCS;
Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/SinglePostingsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/SinglePostingsEnum.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/SinglePostingsEnum.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/codecs/idversion/SinglePostingsEnum.java Thu Jun 25 17:07:11 2015
@@ -18,14 +18,12 @@ package org.apache.lucene.codecs.idversi
*/
import org.apache.lucene.index.PostingsEnum;
-import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
class SinglePostingsEnum extends PostingsEnum {
private int doc;
private int pos;
private int singleDocID;
- private Bits liveDocs;
private long version;
private final BytesRef payload;
@@ -35,16 +33,15 @@ class SinglePostingsEnum extends Posting
}
/** For reuse */
- public void reset(int singleDocID, long version, Bits liveDocs) {
+ public void reset(int singleDocID, long version) {
doc = -1;
- this.liveDocs = liveDocs;
this.singleDocID = singleDocID;
this.version = version;
}
@Override
public int nextDoc() {
- if (doc == -1 && (liveDocs == null || liveDocs.get(singleDocID))) {
+ if (doc == -1) {
doc = singleDocID;
} else {
doc = NO_MORE_DOCS;
@@ -61,7 +58,7 @@ class SinglePostingsEnum extends Posting
@Override
public int advance(int target) {
- if (doc == -1 && target <= singleDocID && (liveDocs == null || liveDocs.get(singleDocID))) {
+ if (doc == -1 && target <= singleDocID) {
doc = singleDocID;
pos = -1;
} else {
Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/DuplicateFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/DuplicateFilter.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/DuplicateFilter.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/sandbox/queries/DuplicateFilter.java Thu Jun 25 17:07:11 2015
@@ -24,6 +24,7 @@ import org.apache.lucene.index.LeafReade
import org.apache.lucene.index.SlowCompositeReaderWrapper;
import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.search.BitsFilteredDocIdSet;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.Filter;
@@ -106,7 +107,7 @@ public class DuplicateFilter extends Fil
if (currTerm == null) {
break;
} else {
- docs = termsEnum.postings(acceptDocs, docs, PostingsEnum.NONE);
+ docs = termsEnum.postings(docs, PostingsEnum.NONE);
int doc = docs.nextDoc();
if (doc != DocIdSetIterator.NO_MORE_DOCS) {
if (keepMode == KeepMode.KM_USE_FIRST_OCCURRENCE) {
@@ -126,7 +127,7 @@ public class DuplicateFilter extends Fil
}
}
}
- return new BitDocIdSet(bits, bits.approximateCardinality());
+ return BitsFilteredDocIdSet.wrap(new BitDocIdSet(bits, bits.approximateCardinality()), acceptDocs);
}
private DocIdSet fastBits(LeafReader reader, Bits acceptDocs) throws IOException {
@@ -144,7 +145,7 @@ public class DuplicateFilter extends Fil
} else {
if (termsEnum.docFreq() > 1) {
// unset potential duplicates
- docs = termsEnum.postings(acceptDocs, docs, PostingsEnum.NONE);
+ docs = termsEnum.postings(docs, PostingsEnum.NONE);
int doc = docs.nextDoc();
if (doc != DocIdSetIterator.NO_MORE_DOCS) {
if (keepMode == KeepMode.KM_USE_FIRST_OCCURRENCE) {
@@ -171,7 +172,7 @@ public class DuplicateFilter extends Fil
}
}
- return new BitDocIdSet(bits);
+ return BitsFilteredDocIdSet.wrap(new BitDocIdSet(bits), acceptDocs);
}
public String getFieldName() {
Modified: lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java?rev=1687581&r1=1687580&r2=1687581&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java (original)
+++ lucene/dev/branches/branch_5x/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java Thu Jun 25 17:07:11 2015
@@ -381,7 +381,7 @@ public class TermAutomatonQuery extends
}
@Override
- public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
+ public Scorer scorer(LeafReaderContext context) throws IOException {
// Initialize the enums; null for a given slot means that term didn't appear in this reader
EnumAndScorer[] enums = new EnumAndScorer[idToTerm.size()];
@@ -395,7 +395,7 @@ public class TermAutomatonQuery extends
TermsEnum termsEnum = context.reader().terms(field).iterator();
termsEnum.seekExact(term, state);
- enums[ent.getKey()] = new EnumAndScorer(ent.getKey(), termsEnum.postings(acceptDocs, null, PostingsEnum.POSITIONS));
+ enums[ent.getKey()] = new EnumAndScorer(ent.getKey(), termsEnum.postings(null, PostingsEnum.POSITIONS));
}
}