|
@@ -472,7 +472,7 @@ public class QueryPhaseTests extends IndexShardTestCase {
|
|
|
context.parsedQuery(new ParsedQuery(new MatchAllDocsQuery()));
|
|
|
context.setSize(1);
|
|
|
context.setTask(new SearchShardTask(123L, "", "", "", null, Collections.emptyMap()));
|
|
|
- context.sort(new SortAndFormats(sort, new DocValueFormat[] {DocValueFormat.RAW}));
|
|
|
+ context.sort(new SortAndFormats(sort, new DocValueFormat[]{DocValueFormat.RAW}));
|
|
|
|
|
|
|
|
|
QueryPhase.executeInternal(context);
|
|
@@ -626,7 +626,7 @@ public class QueryPhaseTests extends IndexShardTestCase {
|
|
|
|
|
|
|
|
|
context.sort(new SortAndFormats(new Sort(new SortField("other", SortField.Type.INT)),
|
|
|
- new DocValueFormat[] { DocValueFormat.RAW }));
|
|
|
+ new DocValueFormat[]{DocValueFormat.RAW}));
|
|
|
topDocsContext = TopDocsCollectorContext.createTopDocsCollectorContext(context, false);
|
|
|
assertEquals(topDocsContext.create(null).scoreMode(), org.apache.lucene.search.ScoreMode.COMPLETE_NO_SCORES);
|
|
|
QueryPhase.executeInternal(context);
|
|
@@ -748,14 +748,16 @@ public class QueryPhaseTests extends IndexShardTestCase {
|
|
|
LongPoint.encodeDimension(value, longBytes, 0);
|
|
|
w.add(longBytes, docId);
|
|
|
}
|
|
|
- long indexFP;
|
|
|
- try (IndexOutput out = dir.createOutput("bkd", IOContext.DEFAULT)) {
|
|
|
- indexFP = w.finish(out);
|
|
|
+ try (IndexOutput metaout = dir.createOutput("bkdmeta", IOContext.DEFAULT);
|
|
|
+ IndexOutput indexout = dir.createOutput("bkdindex", IOContext.DEFAULT);
|
|
|
+ IndexOutput dataout = dir.createOutput("bkddata", IOContext.DEFAULT)) {
|
|
|
+ w.finish(metaout, indexout, dataout).run();
|
|
|
}
|
|
|
- try (IndexInput in = dir.openInput("bkd", IOContext.DEFAULT)) {
|
|
|
- in.seek(indexFP);
|
|
|
- BKDReader r = new BKDReader(in);
|
|
|
- assertTrue(pointsHaveDuplicateData(r, r.getDocCount()/2));
|
|
|
+ try (IndexInput metain = dir.openInput("bkdmeta", IOContext.DEFAULT);
|
|
|
+ IndexInput indexin = dir.openInput("bkdindex", IOContext.DEFAULT);
|
|
|
+ IndexInput datain = dir.openInput("bkddata", IOContext.DEFAULT)) {
|
|
|
+ BKDReader r = new BKDReader(metain, indexin, datain);
|
|
|
+ assertTrue(pointsHaveDuplicateData(r, r.getDocCount() / 2));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -776,12 +778,14 @@ public class QueryPhaseTests extends IndexShardTestCase {
|
|
|
}
|
|
|
long indexFP;
|
|
|
try (IndexOutput out = dir.createOutput("bkd", IOContext.DEFAULT)) {
|
|
|
- indexFP = w.finish(out);
|
|
|
+ Runnable finalizer = w.finish(out, out, out);
|
|
|
+ indexFP = out.getFilePointer();
|
|
|
+ finalizer.run();;
|
|
|
}
|
|
|
try (IndexInput in = dir.openInput("bkd", IOContext.DEFAULT)) {
|
|
|
in.seek(indexFP);
|
|
|
- BKDReader r = new BKDReader(in);
|
|
|
- assertFalse(pointsHaveDuplicateData(r, r.getDocCount()/2));
|
|
|
+ BKDReader r = new BKDReader(in, in, in);
|
|
|
+ assertFalse(pointsHaveDuplicateData(r, r.getDocCount() / 2));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -907,7 +911,7 @@ public class QueryPhaseTests extends IndexShardTestCase {
|
|
|
|
|
|
try (IndexReader reader = DirectoryReader.open(dir)) {
|
|
|
TestSearchContext context = new TestSearchContextWithRewriteAndCancellation(
|
|
|
- null, indexShard, newContextSearcher(reader));
|
|
|
+ null, indexShard, newContextSearcher(reader));
|
|
|
PrefixQuery prefixQuery = new PrefixQuery(new Term("foo", "a"));
|
|
|
prefixQuery.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_REWRITE);
|
|
|
context.parsedQuery(new ParsedQuery(prefixQuery));
|
|
@@ -966,7 +970,7 @@ public class QueryPhaseTests extends IndexShardTestCase {
|
|
|
|
|
|
@Override
|
|
|
public void search(List<LeafReaderContext> leaves, Weight weight, CollectorManager manager,
|
|
|
- QuerySearchResult result, DocValueFormat[] formats, TotalHits totalHits) throws IOException {
|
|
|
+ QuerySearchResult result, DocValueFormat[] formats, TotalHits totalHits) throws IOException {
|
|
|
final Query query = weight.getQuery();
|
|
|
assertTrue(query instanceof BooleanQuery);
|
|
|
List<BooleanClause> clauses = ((BooleanQuery) query).clauses();
|
|
@@ -974,7 +978,7 @@ public class QueryPhaseTests extends IndexShardTestCase {
|
|
|
assertTrue(clauses.get(0).getOccur() == Occur.FILTER);
|
|
|
assertTrue(clauses.get(1).getOccur() == Occur.SHOULD);
|
|
|
if (queryType == 0) {
|
|
|
- assertTrue (clauses.get(1).getQuery().getClass() ==
|
|
|
+ assertTrue(clauses.get(1).getQuery().getClass() ==
|
|
|
LongPoint.newDistanceFeatureQuery("random_field", 1, 1, 1).getClass()
|
|
|
);
|
|
|
}
|
|
@@ -984,7 +988,7 @@ public class QueryPhaseTests extends IndexShardTestCase {
|
|
|
|
|
|
@Override
|
|
|
public void search(List<LeafReaderContext> leaves, Weight weight, Collector collector) {
|
|
|
- assert(false); // should not be there, expected to search with CollectorManager
|
|
|
+ assert (false); // should not be there, expected to search with CollectorManager
|
|
|
}
|
|
|
};
|
|
|
}
|
|
@@ -1006,7 +1010,7 @@ public class QueryPhaseTests extends IndexShardTestCase {
|
|
|
@Override
|
|
|
public void collect(int doc) throws IOException {
|
|
|
assert collected <= size : "should not collect more than " + size + " doc per segment, got " + collected;
|
|
|
- ++ collected;
|
|
|
+ ++collected;
|
|
|
super.collect(doc);
|
|
|
}
|
|
|
};
|