Search in sources :

Example 1 with GlobalId

use of com.yahoo.document.GlobalId in project vespa by vespa-engine.

the class DocsumPacket method decodeBody.

/**
 * Fills this packet from a byte buffer positioned at the
 * first byte of the packet
 */
public void decodeBody(ByteBuffer buffer) {
    byte[] rawGid = new byte[GlobalId.LENGTH];
    buffer.get(rawGid);
    globalId = new GlobalId(rawGid);
    data = new byte[getLength() - 12 - GlobalId.LENGTH];
    buffer.get(data);
}
Also used : GlobalId(com.yahoo.document.GlobalId)

Example 2 with GlobalId

use of com.yahoo.document.GlobalId in project vespa by vespa-engine.

the class GroupingExecutorTestCase method requireThatHitsAreFilledWithCorrectSummary.

@Test
public void requireThatHitsAreFilledWithCorrectSummary() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar))) as(bar) " + "                    each(output(summary(baz))) as(baz)))"));
    Grouping pass0A = new Grouping(0);
    pass0A.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "bar"))));
    Grouping pass0B = new Grouping(1);
    pass0B.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "baz"))));
    GlobalId gid1 = new GlobalId((new DocumentId("doc:test:1")).getGlobalId());
    GlobalId gid2 = new GlobalId((new DocumentId("doc:test:2")).getGlobalId());
    Grouping pass1A = new Grouping(0);
    pass1A.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit(1, gid1, 3)))));
    Grouping pass1B = new Grouping(1);
    pass1B.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "baz").addHit(new com.yahoo.searchlib.aggregation.FS4Hit(4, gid2, 6)))));
    SummaryMapper sm = new SummaryMapper();
    Execution exec = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(pass0A, pass0B), null), new GroupingListHit(Arrays.asList(pass1A, pass1B), null))), sm);
    exec.fill(exec.search(query), "default");
    assertEquals(2, sm.hitsBySummary.size());
    List<Hit> lst = sm.hitsBySummary.get("bar");
    assertNotNull(lst);
    assertEquals(1, lst.size());
    Hit hit = lst.get(0);
    assertTrue(hit instanceof FastHit);
    assertEquals(1, ((FastHit) hit).getPartId());
    assertEquals(gid1, ((FastHit) hit).getGlobalId());
    assertNotNull(lst = sm.hitsBySummary.get("baz"));
    assertNotNull(lst);
    assertEquals(1, lst.size());
    hit = lst.get(0);
    assertTrue(hit instanceof FastHit);
    assertEquals(4, ((FastHit) hit).getPartId());
    assertEquals(gid2, ((FastHit) hit).getGlobalId());
}
Also used : Group(com.yahoo.search.grouping.result.Group) Query(com.yahoo.search.Query) DocumentId(com.yahoo.document.DocumentId) Grouping(com.yahoo.searchlib.aggregation.Grouping) GlobalId(com.yahoo.document.GlobalId) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) HitsAggregationResult(com.yahoo.searchlib.aggregation.HitsAggregationResult) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) FastHit(com.yahoo.prelude.fastsearch.FastHit) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) StringResultNode(com.yahoo.searchlib.expression.StringResultNode) Test(org.junit.Test)

Example 3 with GlobalId

use of com.yahoo.document.GlobalId in project vespa by vespa-engine.

the class GroupingExecutorTestCase method requireThatHitsAreAttachedToCorrectQuery.

@Test
public void requireThatHitsAreAttachedToCorrectQuery() {
    Query queryA = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(queryA);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar)))))"));
    Grouping grp = new Grouping(0);
    grp.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "bar"))));
    GroupingListHit pass0 = new GroupingListHit(Arrays.asList(grp), null);
    GlobalId gid = new GlobalId((new DocumentId("doc:test:1")).getGlobalId());
    grp = new Grouping(0);
    grp.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit(4, gid, 6)))));
    GroupingListHit pass1 = new GroupingListHit(Arrays.asList(grp), null);
    Query queryB = newQuery();
    /**
     * required by {@link GroupingListHit#getSearchQuery()}
     */
    pass1.setQuery(queryB);
    QueryMapper qm = new QueryMapper();
    Execution exec = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(pass0, pass1)), qm);
    exec.fill(exec.search(queryA));
    assertEquals(1, qm.hitsByQuery.size());
    assertTrue(qm.hitsByQuery.containsKey(queryB));
}
Also used : Group(com.yahoo.search.grouping.result.Group) Query(com.yahoo.search.Query) DocumentId(com.yahoo.document.DocumentId) Grouping(com.yahoo.searchlib.aggregation.Grouping) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) GlobalId(com.yahoo.document.GlobalId) HitsAggregationResult(com.yahoo.searchlib.aggregation.HitsAggregationResult) Execution(com.yahoo.search.searchchain.Execution) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) StringResultNode(com.yahoo.searchlib.expression.StringResultNode) Test(org.junit.Test)

Example 4 with GlobalId

use of com.yahoo.document.GlobalId in project vespa by vespa-engine.

the class VespaSummaryBenchmark method createDocsumRequest.

private static Slime createDocsumRequest(String summaryClass, List<GlobalId> gids) {
    Slime docsumRequest = new Slime();
    Cursor root = docsumRequest.setObject();
    root.setString("class", summaryClass);
    Cursor gidCursor = root.setArray("gids");
    for (GlobalId gid : gids) {
        gidCursor.addData(gid.getRawId());
    }
    return docsumRequest;
}
Also used : GlobalId(com.yahoo.document.GlobalId)

Example 5 with GlobalId

use of com.yahoo.document.GlobalId in project vespa by vespa-engine.

the class VespaSummaryBenchmark method main.

public static void main(String[] args) {
    LogSetup.initVespaLogging("vespasummarybenchmark");
    String docidFileName = args[0];
    String connectionSpec = args[1];
    String summaryClass = args[2];
    int numRuns = Integer.parseInt(args[3]);
    int numTargets = Integer.parseInt(args[4]);
    VespaSummaryBenchmark benchmark = new VespaSummaryBenchmark();
    List<String> docIds = getDocIds(docidFileName);
    List<GlobalId> gids = new ArrayList<>(docIds.size());
    for (String docid : docIds) {
        GlobalId gid = new GlobalId(IdString.createIdString(docid));
        gids.add(gid);
    }
    List<Target> targets = benchmark.getTargets(connectionSpec, numTargets);
    for (int i = 0; i < numRuns; i++) {
        fetchDocIds(summaryClass, targets, gids, i == 0);
    }
}
Also used : ArrayList(java.util.ArrayList) IdString(com.yahoo.document.idstring.IdString) 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