Search in sources :

Example 6 with CacheKey

use of com.yahoo.prelude.fastsearch.CacheKey in project vespa by vespa-engine.

the class PacketWrapperTestCase method testPacketTrimming3.

@Test
public void testPacketTrimming3() {
    CacheKey key = new CacheKey(QueryPacket.create(new Query("/?query=key")));
    PacketWrapper w = createResult(key, 0, 10, 100);
    QueryResultPacket q = createQueryResultPacket(20, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(25, 10, 100);
    w.addResultPacket(q);
    assertEquals(3, w.getResultPackets().size());
    List<?> l = w.getResultPackets();
    assertEquals(0, ((QueryResultPacket) l.get(0)).getOffset());
    assertEquals(20, ((QueryResultPacket) l.get(1)).getOffset());
    assertEquals(25, ((QueryResultPacket) l.get(2)).getOffset());
}
Also used : QueryResultPacket(com.yahoo.fs4.QueryResultPacket) Query(com.yahoo.search.Query) PacketWrapper(com.yahoo.prelude.fastsearch.PacketWrapper) CacheKey(com.yahoo.prelude.fastsearch.CacheKey) Test(org.junit.Test)

Example 7 with CacheKey

use of com.yahoo.prelude.fastsearch.CacheKey in project vespa by vespa-engine.

the class PacketWrapperTestCase method testPacketTrimming8.

@Test
public void testPacketTrimming8() {
    CacheKey key = new CacheKey(QueryPacket.create(new Query("/?query=key")));
    PacketWrapper w = createResult(key, 0, 10, 100);
    QueryResultPacket q = createQueryResultPacket(50, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(90, 10, 100);
    w.addResultPacket(q);
    assertEquals(3, w.getResultPackets().size());
    List<?> l = w.getResultPackets();
    assertEquals(0, ((QueryResultPacket) l.get(0)).getOffset());
    assertEquals(50, ((QueryResultPacket) l.get(1)).getOffset());
    assertEquals(90, ((QueryResultPacket) l.get(2)).getOffset());
}
Also used : QueryResultPacket(com.yahoo.fs4.QueryResultPacket) Query(com.yahoo.search.Query) PacketWrapper(com.yahoo.prelude.fastsearch.PacketWrapper) CacheKey(com.yahoo.prelude.fastsearch.CacheKey) Test(org.junit.Test)

Example 8 with CacheKey

use of com.yahoo.prelude.fastsearch.CacheKey in project vespa by vespa-engine.

the class PacketWrapperTestCase method testPacketTrimming9.

@Test
public void testPacketTrimming9() {
    CacheKey key = new CacheKey(QueryPacket.create(new Query("/?query=key")));
    PacketWrapper w = createResult(key, 0, 10, 100);
    QueryResultPacket q = createQueryResultPacket(10, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(11, 9, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(20, 10, 100);
    w.addResultPacket(q);
    assertEquals(3, w.getResultPackets().size());
    List<?> l = w.getResultPackets();
    assertEquals(0, ((QueryResultPacket) l.get(0)).getOffset());
    assertEquals(10, ((QueryResultPacket) l.get(1)).getOffset());
    assertEquals(20, ((QueryResultPacket) l.get(2)).getOffset());
}
Also used : QueryResultPacket(com.yahoo.fs4.QueryResultPacket) Query(com.yahoo.search.Query) PacketWrapper(com.yahoo.prelude.fastsearch.PacketWrapper) CacheKey(com.yahoo.prelude.fastsearch.CacheKey) Test(org.junit.Test)

Example 9 with CacheKey

use of com.yahoo.prelude.fastsearch.CacheKey in project vespa by vespa-engine.

the class PacketWrapperTestCase method testPacketTrimming12.

@Test
public void testPacketTrimming12() {
    CacheKey key = new CacheKey(QueryPacket.create(new Query("/?query=key")));
    PacketWrapper w = createResult(key, 0, 10, 100);
    QueryResultPacket q = createQueryResultPacket(4, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(12, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(16, 10, 100);
    w.addResultPacket(q);
    assertEquals(4, w.getResultPackets().size());
    q = createQueryResultPacket(8, 10, 100);
    w.addResultPacket(q);
    assertEquals(3, w.getResultPackets().size());
    List<?> l = w.getResultPackets();
    assertEquals(0, ((QueryResultPacket) l.get(0)).getOffset());
    assertEquals(8, ((QueryResultPacket) l.get(1)).getOffset());
    assertEquals(16, ((QueryResultPacket) l.get(2)).getOffset());
}
Also used : QueryResultPacket(com.yahoo.fs4.QueryResultPacket) Query(com.yahoo.search.Query) PacketWrapper(com.yahoo.prelude.fastsearch.PacketWrapper) CacheKey(com.yahoo.prelude.fastsearch.CacheKey) Test(org.junit.Test)

Example 10 with CacheKey

use of com.yahoo.prelude.fastsearch.CacheKey in project vespa by vespa-engine.

the class PacketWrapperTestCase method testPacketTrimming6.

@Test
public void testPacketTrimming6() {
    CacheKey key = new CacheKey(QueryPacket.create(new Query("/?query=key")));
    PacketWrapper w = createResult(key, 0, 10, 100);
    QueryResultPacket q = createQueryResultPacket(5, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(10, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(60, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(65, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(70, 10, 100);
    w.addResultPacket(q);
    assertEquals(4, w.getResultPackets().size());
    List<?> l = w.getResultPackets();
    assertEquals(0, ((QueryResultPacket) l.get(0)).getOffset());
    assertEquals(10, ((QueryResultPacket) l.get(1)).getOffset());
    assertEquals(60, ((QueryResultPacket) l.get(2)).getOffset());
    assertEquals(70, ((QueryResultPacket) l.get(3)).getOffset());
}
Also used : QueryResultPacket(com.yahoo.fs4.QueryResultPacket) Query(com.yahoo.search.Query) PacketWrapper(com.yahoo.prelude.fastsearch.PacketWrapper) CacheKey(com.yahoo.prelude.fastsearch.CacheKey) Test(org.junit.Test)

Aggregations

CacheKey (com.yahoo.prelude.fastsearch.CacheKey)18 Query (com.yahoo.search.Query)18 Test (org.junit.Test)18 QueryResultPacket (com.yahoo.fs4.QueryResultPacket)16 PacketWrapper (com.yahoo.prelude.fastsearch.PacketWrapper)16 QueryPacket (com.yahoo.fs4.QueryPacket)2 DocumentInfo (com.yahoo.fs4.DocumentInfo)1