Search in sources :

Example 6 with GlobalId

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));
}
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 7 with GlobalId

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);
}
Also used : GlobalId(com.yahoo.document.GlobalId)

Aggregations

GlobalId (com.yahoo.document.GlobalId)7 DocumentId (com.yahoo.document.DocumentId)2 FastHit (com.yahoo.prelude.fastsearch.FastHit)2 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)2 Query (com.yahoo.search.Query)2 GroupingRequest (com.yahoo.search.grouping.GroupingRequest)2 Group (com.yahoo.search.grouping.result.Group)2 Execution (com.yahoo.search.searchchain.Execution)2 Grouping (com.yahoo.searchlib.aggregation.Grouping)2 HitsAggregationResult (com.yahoo.searchlib.aggregation.HitsAggregationResult)2 StringResultNode (com.yahoo.searchlib.expression.StringResultNode)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 CompressionType (com.yahoo.compress.CompressionType)1 Compressor (com.yahoo.compress.Compressor)1 IdIdString (com.yahoo.document.idstring.IdIdString)1 IdString (com.yahoo.document.idstring.IdString)1 Hit (com.yahoo.search.result.Hit)1 ArrayTraverser (com.yahoo.slime.ArrayTraverser)1 BinaryFormat (com.yahoo.slime.BinaryFormat)1