use of com.yahoo.search.result.Hit in project vespa by vespa-engine.
the class DeepHitIteratorTestCase method testRemove.
public void testRemove() {
HitGroup hits = new HitGroup();
hits.add(new Hit("foo"));
hits.add(new Hit("bar"));
Iterator<Hit> it = hits.deepIterator();
try {
it.remove();
fail();
} catch (IllegalStateException e) {
// need to call next() first
}
assertTrue(it.hasNext());
assertEquals("foo", it.next().getId().toString());
assertTrue(it.hasNext());
try {
it.remove();
fail();
} catch (IllegalStateException e) {
// prefetch done
}
assertEquals("bar", it.next().getId().toString());
// no prefetch done
it.remove();
assertFalse(it.hasNext());
}
use of com.yahoo.search.result.Hit in project vespa by vespa-engine.
the class DeepHitIteratorTestCase method testEmpty.
public void testEmpty() {
HitGroup hits = new HitGroup();
Iterator<Hit> it = hits.deepIterator();
assertFalse(it.hasNext());
try {
it.next();
fail();
} catch (NoSuchElementException e) {
// regular iterator behavior
}
}
use of com.yahoo.search.result.Hit in project vespa by vespa-engine.
the class DeepHitIteratorTestCase method testFirstHitIsGroup.
public void testFirstHitIsGroup() {
HitGroup root = new HitGroup();
HitGroup group = new HitGroup();
group.add(new Hit("foo"));
root.add(group);
root.add(new Hit("bar"));
Iterator<Hit> it = root.deepIterator();
assertTrue(it.hasNext());
assertEquals("foo", it.next().getId().toString());
assertTrue(it.hasNext());
assertEquals("bar", it.next().getId().toString());
assertFalse(it.hasNext());
}
use of com.yahoo.search.result.Hit in project vespa by vespa-engine.
the class YqlFieldAndSourceTestCase method setUp.
@Before
public void setUp() throws Exception {
Query query = new Query("?query=test");
Result result = new Result(query);
Hit hit = createHit("lastHit", .1d, FIELD1, FIELD2, FIELD3);
result.hits().add(hit);
DocumentSourceSearcher mockBackend = new DocumentSourceSearcher();
mockBackend.addResult(query, result);
mockBackend.addSummaryClassByCopy(DEFAULT_SUMMARY_CLASS, Arrays.asList(FIELD1, FIELD2));
mockBackend.addSummaryClassByCopy(Execution.ATTRIBUTEPREFETCH, Arrays.asList(FIELD2));
mockBackend.addSummaryClassByCopy(THIRD_OPTION, Arrays.asList(FIELD3));
DocumentdbInfoConfig config = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(buildDocumentdbArray()));
searchChain = new Chain<>(new FieldFiller(config), mockBackend);
context = Execution.Context.createContextStub(null);
execution = new Execution(searchChain, context);
}
use of com.yahoo.search.result.Hit in project vespa by vespa-engine.
the class PeakQpsTestCase method checkSearch.
@Test
public void checkSearch() {
MeasureQpsConfig config = new MeasureQpsConfig(new MeasureQpsConfig.Builder().outputmethod(MeasureQpsConfig.Outputmethod.METAHIT).queryproperty("qpsprobe"));
Searcher s = new PeakQpsSearcher(config, Statistics.nullImplementation);
Chain<Searcher> c = new Chain<>(s);
Execution e = new Execution(c, Execution.Context.createContextStub());
e.search(new Query("/?query=a"));
new Execution(c, Execution.Context.createContextStub());
Result r = e.search(new Query("/?query=a&qpsprobe=true"));
final Hit hit = r.hits().get(0);
assertTrue(hit instanceof PeakQpsSearcher.QpsHit);
assertNotNull(hit.fields().get(PeakQpsSearcher.QpsHit.MEAN_QPS));
assertNotNull(hit.fields().get(PeakQpsSearcher.QpsHit.PEAK_QPS));
}
Aggregations