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());
}
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);
}
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;
}
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));
}
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);
}
Aggregations