Search in sources :

Example 11 with PacketWrapper

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

the class PacketWrapperTestCase method testPacketTrimming13.

@Test
public void testPacketTrimming13() {
    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(11, 10, 100);
    w.addResultPacket(q);
    assertEquals(4, w.getResultPackets().size());
    List<?> l = w.getResultPackets();
    assertEquals(0, ((QueryResultPacket) l.get(0)).getOffset());
    assertEquals(4, ((QueryResultPacket) l.get(1)).getOffset());
    assertEquals(12, ((QueryResultPacket) l.get(2)).getOffset());
    assertEquals(16, ((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)

Example 12 with PacketWrapper

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

the class PacketWrapperTestCase method testPacketTrimming7.

@Test
public void testPacketTrimming7() {
    final Query query = new Query("/?query=key");
    query.setWindow(50, 10);
    CacheKey key = new CacheKey(QueryPacket.create(query));
    PacketWrapper w = createResult(key, 50, 10, 100);
    QueryResultPacket q = createQueryResultPacket(10, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(40, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(30, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(20, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(0, 10, 100);
    w.addResultPacket(q);
    assertEquals(6, 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());
    assertEquals(30, ((QueryResultPacket) l.get(3)).getOffset());
    assertEquals(40, ((QueryResultPacket) l.get(4)).getOffset());
    assertEquals(50, ((QueryResultPacket) l.get(5)).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 13 with PacketWrapper

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

the class PacketWrapperTestCase method testPacketTrimming14.

@Test
public void testPacketTrimming14() {
    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(5, 6, 100);
    w.addResultPacket(q);
    assertEquals(4, w.getResultPackets().size());
    List<?> l = w.getResultPackets();
    assertEquals(0, ((QueryResultPacket) l.get(0)).getOffset());
    assertEquals(4, ((QueryResultPacket) l.get(1)).getOffset());
    assertEquals(12, ((QueryResultPacket) l.get(2)).getOffset());
    assertEquals(16, ((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)

Example 14 with PacketWrapper

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

the class PacketWrapperTestCase method testPacketTrimming5.

@Test
public void testPacketTrimming5() {
    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(15, 10, 100);
    w.addResultPacket(q);
    q = createQueryResultPacket(15, 85, 100);
    w.addResultPacket(q);
    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(10, ((QueryResultPacket) l.get(1)).getOffset());
    assertEquals(15, ((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 15 with PacketWrapper

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

the class PacketWrapperTestCase method testPacketTrimming1.

@Test
public void testPacketTrimming1() {
    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);
    assertEquals(2, w.getResultPackets().size());
    List<?> l = w.getResultPackets();
    assertEquals(0, ((QueryResultPacket) l.get(0)).getOffset());
    assertEquals(10, ((QueryResultPacket) l.get(1)).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

PacketWrapper (com.yahoo.prelude.fastsearch.PacketWrapper)17 QueryResultPacket (com.yahoo.fs4.QueryResultPacket)16 CacheKey (com.yahoo.prelude.fastsearch.CacheKey)16 Query (com.yahoo.search.Query)16 Test (org.junit.Test)16 BasicPacket (com.yahoo.fs4.BasicPacket)1 DocumentInfo (com.yahoo.fs4.DocumentInfo)1 ByteBuffer (java.nio.ByteBuffer)1