use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.
the class DefaultRenderer 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);
}
use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.
the class JsonRenderer method tryDirectRendering.
/**
* Really a private method, but package access for testability.
*/
boolean tryDirectRendering(String fieldName, Hit hit) throws IOException {
boolean renderedAsUtf8 = false;
if (hit instanceof FastHit) {
FastHit f = (FastHit) hit;
if (f.fieldIsNotDecoded(fieldName)) {
FastHit.RawField r = f.fetchFieldAsUtf8(fieldName);
if (r != null) {
byte[] utf8 = r.getUtf8();
generator.writeUTF8String(utf8, 0, utf8.length);
renderedAsUtf8 = true;
}
}
}
return renderedAsUtf8;
}
use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.
the class VdsStreamingSearcher method buildSummaryHit.
private FastHit buildSummaryHit(Query query, SearchResult.Hit hit) {
FastHit fastHit = new FastHit();
fastHit.setQuery(query);
fastHit.setSource(getName());
fastHit.setId(hit.getDocId());
fastHit.setRelevance(new Relevance(hit.getRank()));
fastHit.setFillable();
return fastHit;
}
use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.
the class GetDocSumsPacketTestCase method requireThatSessionIdIsEncodedAsPropertyWhenUsingSearchSession.
@Test
public void requireThatSessionIdIsEncodedAsPropertyWhenUsingSearchSession() throws BufferTooSmallException {
Result result = new Result(new Query("?query=foo"));
// create session id.
SessionId sessionId = result.getQuery().getSessionId(true);
result.getQuery().getRanking().setQueryCache(true);
FastHit hit = new FastHit();
result.hits().add(hit);
ByteBuffer answer = ByteBuffer.allocate(1024);
// assertEquals(0, sessionId.asUtf8String().getByteLength());
answer.put(new byte[] { 0, 0, 0, (byte) (107 + sessionId.asUtf8String().getByteLength()), 0, 0, 0, -37, 0, 0, 56, 17, 0, 0, 0, 0, // query timeout
IGNORE, IGNORE, IGNORE, IGNORE, // "default" - rank profile
7, 'd', 'e', 'f', 'a', 'u', 'l', 't', 0, 0, 0, 0x03, // "default" - summaryclass
0, 0, 0, 7, 'd', 'e', 'f', 'a', 'u', 'l', 't', // 2 property entries
0, 0, 0, 2, // rank: sessionId => qrserver.0.XXXXXXXXXXXXX.0
0, 0, 0, 4, 'r', 'a', 'n', 'k', 0, 0, 0, 1, 0, 0, 0, 9, 's', 'e', 's', 's', 'i', 'o', 'n', 'I', 'd' });
answer.putInt(sessionId.asUtf8String().getByteLength());
answer.put(sessionId.asUtf8String().getBytes());
answer.put(new byte[] { // caches: features => true
0, 0, 0, 6, 'c', 'a', 'c', 'h', 'e', 's', 0, 0, 0, 1, 0, 0, 0, 5, 'q', 'u', 'e', 'r', 'y', 0, 0, 0, 4, 't', 'r', 'u', 'e', // flags
0, 0, 0, 2 });
byte[] expected = new byte[answer.position()];
answer.flip();
answer.get(expected);
assertPacket(false, result, expected);
}
use of com.yahoo.prelude.fastsearch.FastHit in project vespa by vespa-engine.
the class FastHitTestCase method requireThatIgnoreRowBitsCanBeSet.
@Test
public void requireThatIgnoreRowBitsCanBeSet() {
FastHit hit = new FastHit();
hit.setIgnoreRowBits(true);
assertTrue(hit.shouldIgnoreRowBits());
}
Aggregations