Search in sources :

Example 6 with QueryResultPacket

use of com.yahoo.fs4.QueryResultPacket in project vespa by vespa-engine.

the class PacketWrapperTestCase method testPacketTrimming4.

@Test
public void testPacketTrimming4() {
    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(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 7 with QueryResultPacket

use of com.yahoo.fs4.QueryResultPacket in project vespa by vespa-engine.

the class PacketWrapperTestCase method testZeroHits.

@Test
public void testZeroHits() {
    CacheKey key = new CacheKey(QueryPacket.create(new Query("/?query=key")));
    PacketWrapper w = createResult(key, 0, 10, 0);
    final Query query = new Query("/?query=key");
    query.setWindow(5, 10);
    key = new CacheKey(QueryPacket.create(query));
    QueryResultPacket q = createQueryResultPacket(5, 10, 0);
    w.addResultPacket(q);
    assertEquals(1, w.getResultPackets().size());
    List<?> l = w.getDocuments(3, 12);
    assertNotNull(l);
    assertEquals(0, l.size());
    l = w.getDocuments(0, 12);
    assertNotNull(l);
    assertEquals(0, l.size());
    l = w.getDocuments(0, 0);
    assertNotNull(l);
    assertEquals(0, l.size());
}
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 QueryResultPacket

use of com.yahoo.fs4.QueryResultPacket in project vespa by vespa-engine.

the class PacketWrapperTestCase method testPacketTrimming2.

@Test
public void testPacketTrimming2() {
    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(50, 10, 100);
    w.addResultPacket(q);
    assertEquals(3, w.getResultPackets().size());
    List<?> l = w.getResultPackets();
    assertEquals(0, ((QueryResultPacket) l.get(0)).getOffset());
    assertEquals(5, ((QueryResultPacket) l.get(1)).getOffset());
    assertEquals(50, ((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 QueryResultPacket

use of com.yahoo.fs4.QueryResultPacket 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 10 with QueryResultPacket

use of com.yahoo.fs4.QueryResultPacket 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)

Aggregations

QueryResultPacket (com.yahoo.fs4.QueryResultPacket)28 Test (org.junit.Test)20 CacheKey (com.yahoo.prelude.fastsearch.CacheKey)16 PacketWrapper (com.yahoo.prelude.fastsearch.PacketWrapper)16 Query (com.yahoo.search.Query)16 BasicPacket (com.yahoo.fs4.BasicPacket)7 DocumentInfo (com.yahoo.fs4.DocumentInfo)7 ByteBuffer (java.nio.ByteBuffer)4 GetDocSumsPacket (com.yahoo.fs4.GetDocSumsPacket)2 PacketDecoder (com.yahoo.fs4.PacketDecoder)2 DecodedPacket (com.yahoo.fs4.PacketDecoder.DecodedPacket)2 PingPacket (com.yahoo.fs4.PingPacket)2 PongPacket (com.yahoo.fs4.PongPacket)2 QueryPacket (com.yahoo.fs4.QueryPacket)2 Result (com.yahoo.search.Result)2 ChannelTimeoutException (com.yahoo.fs4.ChannelTimeoutException)1 Packet (com.yahoo.fs4.Packet)1 InvalidChannelException (com.yahoo.fs4.mplex.InvalidChannelException)1