use of com.yahoo.document.GlobalId 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.document.GlobalId in project vespa by vespa-engine.
the class FS4Hit method onDeserialize.
@Override
protected void onDeserialize(Deserializer buf) {
super.onDeserialize(buf);
path = buf.getInt(null);
globalId = new GlobalId(buf.getBytes(null, GlobalId.LENGTH));
distributionKey = buf.getInt(null);
}
Aggregations