Search in sources :

Example 36 with FastHit

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

the class FastHitTestCase method requireThatIgnoreRowBitsIsFalseByDefault.

@Test
public void requireThatIgnoreRowBitsIsFalseByDefault() {
    FastHit hit = new FastHit();
    assertFalse(hit.shouldIgnoreRowBits());
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Test(org.junit.Test)

Example 37 with FastHit

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

the class JuniperSearcherTestCase method addResult.

private void addResult(Query query, String sdName, String content, DocumentSourceSearcher docsource) {
    Result r = new Result(query);
    FastHit hit = new FastHit();
    hit.setId("http://abc.html");
    hit.setRelevance(new Relevance(1));
    hit.setField(Hit.SDDOCNAME_FIELD, sdName);
    hit.setField("dynteaser", content);
    r.hits().add(hit);
    docsource.addResult(query, r);
}
Also used : Relevance(com.yahoo.search.result.Relevance) FastHit(com.yahoo.prelude.fastsearch.FastHit) Result(com.yahoo.search.Result)

Example 38 with FastHit

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

the class FillTestCase method createHit.

private FastHit createHit(int sourceNodeId, int hitId) {
    FastHit hit = new FastHit("hit:" + hitId, 1.0);
    hit.setPartId(sourceNodeId, 0);
    hit.setDistributionKey(sourceNodeId);
    hit.setGlobalId(client.globalIdFrom(hitId));
    return hit;
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit)

Example 39 with FastHit

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

the class MockClient method getDocsums.

@Override
public void getDocsums(List<FastHit> hitsContext, NodeConnection node, CompressionType compression, int uncompressedSize, byte[] compressedSlime, Dispatcher.GetDocsumsResponseReceiver responseReceiver, double timeoutSeconds) {
    if (malfunctioning) {
        responseReceiver.receive(GetDocsumsResponseOrError.fromError("Malfunctioning"));
        return;
    }
    Inspector request = BinaryFormat.decode(compressor.decompress(compressedSlime, compression, uncompressedSize)).get();
    String docsumClass = request.field("class").asString();
    List<Map<String, Object>> docsumsToReturn = new ArrayList<>();
    request.field("gids").traverse((ArrayTraverser) (index, gid) -> {
        GlobalId docId = new GlobalId(gid.asData());
        docsumsToReturn.add(docsums.get(new DocsumKey(node.toString(), docId, docsumClass)));
    });
    Slime responseSlime = new Slime();
    Cursor root = responseSlime.setObject();
    Cursor docsums = root.setArray("docsums");
    for (Map<String, Object> docsumFields : docsumsToReturn) {
        Cursor docsumItem = docsums.addObject();
        Cursor docsum = docsumItem.setObject("docsum");
        for (Map.Entry<String, Object> field : docsumFields.entrySet()) {
            if (field.getValue() instanceof Integer)
                docsum.setLong(field.getKey(), (Integer) field.getValue());
            else if (field.getValue() instanceof String)
                docsum.setString(field.getKey(), (String) field.getValue());
            else
                throw new RuntimeException();
        }
    }
    byte[] slimeBytes = BinaryFormat.encode(responseSlime);
    Compressor.Compression compressionResult = compressor.compress(compression, slimeBytes);
    GetDocsumsResponse response = new GetDocsumsResponse(compressionResult.type().getCode(), slimeBytes.length, compressionResult.data(), hitsContext);
    responseReceiver.receive(GetDocsumsResponseOrError.fromResponse(response));
}
Also used : Cursor(com.yahoo.slime.Cursor) BinaryFormat(com.yahoo.slime.BinaryFormat) Inspector(com.yahoo.slime.Inspector) ArrayTraverser(com.yahoo.slime.ArrayTraverser) IdIdString(com.yahoo.document.idstring.IdIdString) Slime(com.yahoo.slime.Slime) HashMap(java.util.HashMap) Compressor(com.yahoo.compress.Compressor) FastHit(com.yahoo.prelude.fastsearch.FastHit) ArrayList(java.util.ArrayList) List(java.util.List) CompressionType(com.yahoo.compress.CompressionType) Map(java.util.Map) GlobalId(com.yahoo.document.GlobalId) ArrayList(java.util.ArrayList) Compressor(com.yahoo.compress.Compressor) IdIdString(com.yahoo.document.idstring.IdIdString) Slime(com.yahoo.slime.Slime) Cursor(com.yahoo.slime.Cursor) GlobalId(com.yahoo.document.GlobalId) Inspector(com.yahoo.slime.Inspector) HashMap(java.util.HashMap) Map(java.util.Map)

Example 40 with FastHit

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

the class JsonRendererTestCase method testLazyDecoding.

@Test
public void testLazyDecoding() throws IOException {
    FastHit f = new FastHit("http://a.b/c", 0.5);
    String checkWeCanDecode = "bamse";
    String dontCare = "don't care";
    final String fieldName = "checkWeCanDecode";
    f.setLazyStringField(fieldName, Utf8.toBytes(checkWeCanDecode));
    final String fieldName2 = "dontCare";
    f.setLazyStringField(fieldName2, Utf8.toBytes(dontCare));
    assertEquals(checkWeCanDecode, f.getField(fieldName));
    JsonGenerator mock = Mockito.mock(JsonGenerator.class);
    renderer.setGenerator(mock);
    assertTrue(renderer.tryDirectRendering(fieldName2, f));
    byte[] expectedBytes = Utf8.toBytes(dontCare);
    Mockito.verify(mock, times(1)).writeUTF8String(expectedBytes, 0, expectedBytes.length);
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) JSONString(com.yahoo.prelude.hitfield.JSONString) Test(org.junit.Test)

Aggregations

FastHit (com.yahoo.prelude.fastsearch.FastHit)51 Result (com.yahoo.search.Result)21 Query (com.yahoo.search.Query)20 Test (org.junit.Test)20 Hit (com.yahoo.search.result.Hit)19 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)9 Relevance (com.yahoo.search.result.Relevance)8 Searcher (com.yahoo.search.Searcher)7 DocumentSourceSearcher (com.yahoo.prelude.searcher.DocumentSourceSearcher)6 Execution (com.yahoo.search.searchchain.Execution)5 FS4Hit (com.yahoo.searchlib.aggregation.FS4Hit)5 VdsHit (com.yahoo.searchlib.aggregation.VdsHit)5 JSONString (com.yahoo.prelude.hitfield.JSONString)4 QuotingSearcher (com.yahoo.prelude.searcher.QuotingSearcher)4 Utf8String (com.yahoo.text.Utf8String)4 HashMap (java.util.HashMap)4 ByteWriter (com.yahoo.io.ByteWriter)3 DocsumDefinitionSet (com.yahoo.prelude.fastsearch.DocsumDefinitionSet)3 Coverage (com.yahoo.search.result.Coverage)3 HitGroup (com.yahoo.search.result.HitGroup)3