Search in sources :

Example 16 with FastHit

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

the class SyncDefaultRenderer method renderFieldContentPossiblyNotDecoded.

private void renderFieldContentPossiblyNotDecoded(XMLWriter writer, Hit hit, boolean probablyNotDecoded, String fieldName) throws IOException {
    boolean dumpedRaw = false;
    if (probablyNotDecoded && (hit instanceof FastHit)) {
        writer.closeStartTag();
        if ((writer.getWriter() instanceof ByteWriter) && context.isUtf8Output()) {
            dumpedRaw = UserTemplate.dumpBytes((ByteWriter) writer.getWriter(), (FastHit) hit, fieldName);
        }
        if (dumpedRaw) {
            // let the xml writer note that this tag had content
            writer.content("", false);
        }
    }
    if (!dumpedRaw) {
        String xmlval = hit.getFieldXML(fieldName);
        if (xmlval == null) {
            xmlval = "(null)";
        }
        writer.escapedContent(xmlval, false);
    }
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) ByteWriter(com.yahoo.io.ByteWriter) Utf8String(com.yahoo.text.Utf8String)

Example 17 with FastHit

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

the class SyncDefaultRenderer method renderField.

private void renderField(XMLWriter writer, Hit hit, Iterator<Map.Entry<String, Object>> it) throws IOException {
    Map.Entry<String, Object> entry = it.next();
    boolean isProbablyNotDecoded = false;
    if (hit instanceof FastHit) {
        FastHit f = (FastHit) hit;
        isProbablyNotDecoded = f.fieldIsNotDecoded(entry.getKey());
    }
    renderGenericFieldPossiblyNotDecoded(writer, hit, entry, isProbablyNotDecoded);
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Utf8String(com.yahoo.text.Utf8String) Map(java.util.Map) CopyOnWriteHashMap(com.yahoo.concurrent.CopyOnWriteHashMap)

Example 18 with FastHit

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

the class DefaultRenderer method renderFieldContentPossiblyNotDecoded.

private void renderFieldContentPossiblyNotDecoded(XMLWriter writer, Hit hit, boolean probablyNotDecoded, String fieldName) throws IOException {
    boolean dumpedRaw = false;
    if (probablyNotDecoded && (hit instanceof FastHit)) {
        writer.closeStartTag();
        if ((writer.getWriter() instanceof ByteWriter) && utf8Output) {
            dumpedRaw = UserTemplate.dumpBytes((ByteWriter) writer.getWriter(), (FastHit) hit, fieldName);
        }
        if (dumpedRaw) {
            // let the xml writer note that this tag had content
            writer.content("", false);
        }
    }
    if (!dumpedRaw) {
        String xmlval = hit.getFieldXML(fieldName);
        if (xmlval == null) {
            xmlval = "(null)";
        }
        writer.escapedContent(xmlval, false);
    }
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) ByteWriter(com.yahoo.io.ByteWriter) Utf8String(com.yahoo.text.Utf8String)

Example 19 with FastHit

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

the class HitConverter method convertVdsHit.

private Hit convertVdsHit(String summaryClass, VdsHit grpHit) {
    FastHit ret = new FastHit();
    ret.setRelevance(grpHit.getRank());
    if (grpHit.getSummary().getData().length > 0) {
        GroupingListHit ctxHit = (GroupingListHit) grpHit.getContext();
        if (ctxHit == null) {
            throw new NullPointerException("Hit has no context.");
        }
        DocsumDefinitionSet defs = ctxHit.getDocsumDefinitionSet();
        defs.lazyDecode(summaryClass, grpHit.getSummary().getData(), ret);
        ret.setFilled(summaryClass);
        ret.setFilled(query.getPresentation().getSummary());
    }
    return ret;
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) DocsumDefinitionSet(com.yahoo.prelude.fastsearch.DocsumDefinitionSet) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit)

Example 20 with FastHit

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

the class GetDocSumsPacketTestCase method testEncodingWithQuery.

@Test
public void testEncodingWithQuery() throws BufferTooSmallException {
    FastHit hit = new FastHit();
    hit.setIgnoreRowBits(true);
    assertPacket(true, hit, new byte[] { 0, 0, 0, 57, 0, 0, 0, -37, 0, 0, 40, 21, 0, 0, 0, 0, IGNORE, IGNORE, IGNORE, IGNORE, 7, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 0x03, 0, 0, 0, 7, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 1, 0, 0, 0, 6, 4, 0, 3, 102, 111, 111, 0, 0, 0, 3 });
    hit = new FastHit();
    hit.setIgnoreRowBits(false);
    assertPacket(true, hit, new byte[] { 0, 0, 0, 57, 0, 0, 0, -37, 0, 0, 40, 21, 0, 0, 0, 0, IGNORE, IGNORE, IGNORE, IGNORE, 7, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 0x03, 0, 0, 0, 7, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 1, 0, 0, 0, 6, 4, 0, 3, 102, 111, 111, 0, 0, 0, 2 });
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) 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