Search in sources :

Example 21 with HitGroup

use of com.yahoo.search.result.HitGroup in project vespa by vespa-engine.

the class DeepHitIteratorTestCase method testSecondHitIsGroup.

public void testSecondHitIsGroup() {
    HitGroup root = new HitGroup();
    root.add(new Hit("foo"));
    HitGroup group = new HitGroup();
    group.add(new Hit("bar"));
    root.add(group);
    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());
}
Also used : Hit(com.yahoo.search.result.Hit) HitGroup(com.yahoo.search.result.HitGroup)

Example 22 with HitGroup

use of com.yahoo.search.result.HitGroup in project vespa by vespa-engine.

the class DeepHitIteratorTestCase method testDeep.

public void testDeep() {
    HitGroup grandParent = new HitGroup();
    grandParent.add(new Hit("a"));
    HitGroup parent = new HitGroup();
    parent.add(new Hit("b"));
    HitGroup child = new HitGroup();
    child.add(new Hit("c"));
    HitGroup grandChild = new HitGroup();
    grandChild.add(new Hit("d"));
    child.add(grandChild);
    child.add(new Hit("e"));
    parent.add(child);
    parent.add(new Hit("f"));
    grandParent.add(parent);
    grandParent.add(new Hit("g"));
    Iterator<Hit> it = grandParent.deepIterator();
    assertTrue(it.hasNext());
    assertEquals("a", it.next().getId().toString());
    assertTrue(it.hasNext());
    assertEquals("b", it.next().getId().toString());
    assertTrue(it.hasNext());
    assertEquals("c", it.next().getId().toString());
    assertTrue(it.hasNext());
    assertEquals("d", it.next().getId().toString());
    assertTrue(it.hasNext());
    assertEquals("e", it.next().getId().toString());
    assertTrue(it.hasNext());
    assertEquals("f", it.next().getId().toString());
    assertTrue(it.hasNext());
    assertEquals("g", it.next().getId().toString());
    assertFalse(it.hasNext());
}
Also used : Hit(com.yahoo.search.result.Hit) HitGroup(com.yahoo.search.result.HitGroup)

Example 23 with HitGroup

use of com.yahoo.search.result.HitGroup 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());
}
Also used : Hit(com.yahoo.search.result.Hit) HitGroup(com.yahoo.search.result.HitGroup)

Example 24 with HitGroup

use of com.yahoo.search.result.HitGroup 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
    }
}
Also used : Hit(com.yahoo.search.result.Hit) NoSuchElementException(java.util.NoSuchElementException) HitGroup(com.yahoo.search.result.HitGroup)

Example 25 with HitGroup

use of com.yahoo.search.result.HitGroup 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());
}
Also used : Hit(com.yahoo.search.result.Hit) HitGroup(com.yahoo.search.result.HitGroup)

Aggregations

HitGroup (com.yahoo.search.result.HitGroup)48 Test (org.junit.Test)28 Result (com.yahoo.search.Result)27 Query (com.yahoo.search.Query)24 Hit (com.yahoo.search.result.Hit)21 Execution (com.yahoo.search.searchchain.Execution)11 Searcher (com.yahoo.search.Searcher)8 Organizer (com.yahoo.search.pagetemplates.engine.Organizer)8 Choice (com.yahoo.search.pagetemplates.model.Choice)8 DeterministicResolver (com.yahoo.search.pagetemplates.engine.resolvers.DeterministicResolver)7 DefaultErrorHit (com.yahoo.search.result.DefaultErrorHit)6 Chain (com.yahoo.component.chain.Chain)5 ErrorHit (com.yahoo.search.result.ErrorHit)4 ComponentId (com.yahoo.component.ComponentId)3 FastHit (com.yahoo.prelude.fastsearch.FastHit)3 FederationSearcher (com.yahoo.search.federation.FederationSearcher)3 Resolution (com.yahoo.search.pagetemplates.engine.Resolution)3 Resolver (com.yahoo.search.pagetemplates.engine.Resolver)3 Coverage (com.yahoo.search.result.Coverage)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3