Search in sources :

Example 81 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class TraceTestCase method testTraceInvocationsFillableHits.

@Test
public void testTraceInvocationsFillableHits() {
    final int traceLevel = 5;
    Query query = new Query("?tracelevel=" + traceLevel);
    Chain<Searcher> forkingChain = new Chain<>(new Tracer("tracer1"), new Tracer("tracer2"), new Backend("backend1", true));
    Execution execution = new Execution(forkingChain, Execution.Context.createContextStub());
    Result result = execution.search(query);
    execution.fill(result, "mySummary");
    Iterator<String> trace = collectTrace(query).iterator();
    assertEquals("(level start)", trace.next());
    assertEquals("  No query profile is used", trace.next());
    // (properties trace: not checked)
    trace.next();
    assertEquals("  (level start)", trace.next());
    assertEquals("    Invoke searcher 'tracer1'", trace.next());
    assertEquals("    During tracer1: 0", trace.next());
    assertEquals("    Invoke searcher 'tracer2'", trace.next());
    assertEquals("    During tracer2: 0", trace.next());
    assertEquals("    Invoke searcher 'backend1'", trace.next());
    assertEquals("    Return searcher 'backend1'", trace.next());
    assertEquals("    Return searcher 'tracer2'", trace.next());
    assertEquals("    Return searcher 'tracer1'", trace.next());
    assertEquals("    Invoke fill(mySummary) on searcher 'tracer1'", trace.next());
    assertEquals("    Invoke fill(mySummary) on searcher 'tracer2'", trace.next());
    assertEquals("    Invoke fill(mySummary) on searcher 'backend1'", trace.next());
    assertEquals("    Return fill(mySummary) on searcher 'backend1'", trace.next());
    assertEquals("    Return fill(mySummary) on searcher 'tracer2'", trace.next());
    assertEquals("    Return fill(mySummary) on searcher 'tracer1'", trace.next());
    assertEquals("  (level end)", trace.next());
    assertEquals("(level end)", trace.next());
    assertFalse(trace.hasNext());
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 82 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class TraceTestCase method testTraceInvocationsUnfillableHits.

@Test
public void testTraceInvocationsUnfillableHits() {
    final int traceLevel = 5;
    Query query = new Query("?tracelevel=" + traceLevel);
    Chain<Searcher> forkingChain = new Chain<>(new Tracer("tracer1"), new Tracer("tracer2"), new Backend("backend1", false));
    Execution execution = new Execution(forkingChain, Execution.Context.createContextStub());
    Result result = execution.search(query);
    execution.fill(result, "mySummary");
    Iterator<String> trace = collectTrace(query).iterator();
    assertEquals("(level start)", trace.next());
    assertEquals("  No query profile is used", trace.next());
    // (properties trace: not checked)
    trace.next();
    assertEquals("  (level start)", trace.next());
    assertEquals("    Invoke searcher 'tracer1'", trace.next());
    assertEquals("    During tracer1: 0", trace.next());
    assertEquals("    Invoke searcher 'tracer2'", trace.next());
    assertEquals("    During tracer2: 0", trace.next());
    assertEquals("    Invoke searcher 'backend1'", trace.next());
    assertEquals("    Return searcher 'backend1'", trace.next());
    assertEquals("    Return searcher 'tracer2'", trace.next());
    assertEquals("    Return searcher 'tracer1'", trace.next());
    assertEquals("    Invoke fill(mySummary) on searcher 'tracer1'", trace.next());
    assertEquals("    Ignoring fill(mySummary): Hits are unfillable: result.hits().getFilled()=null", trace.next());
    assertEquals("    Return fill(mySummary) on searcher 'tracer1'", trace.next());
    assertEquals("  (level end)", trace.next());
    assertEquals("(level end)", trace.next());
    assertFalse(trace.hasNext());
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 83 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class TraceTestCase method assertTracing.

private void assertTracing(boolean carryOverContext, boolean parallel) {
    Query query = new Query("?tracelevel=1");
    query.trace("Before execution", 1);
    Chain<Searcher> forkingChain = new Chain<>(new Tracer("forker"), new Forker(carryOverContext, parallel, new Tracer("branch 1"), new Tracer("branch 2")));
    new Execution(forkingChain, Execution.Context.createContextStub()).search(query);
    if (carryOverContext)
        assertTraceWithChildExecutionMessages(query);
    else if (parallel)
        assertTrace(query);
    else
        assertIncorrectlyNestedTrace(query);
    assertCorrectRendering(query);
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher)

Example 84 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class ExecutionTestCase method testLinearExecutions.

public void testLinearExecutions() {
    // Make a chain
    List<Searcher> searchers1 = new ArrayList<>();
    searchers1.add(new TestSearcher("searcher1"));
    searchers1.add(new TestSearcher("searcher2"));
    searchers1.add(new TestSearcher("searcher3"));
    searchers1.add(new TestSearcher("searcher4"));
    Chain<Searcher> chain1 = new Chain<>(new ComponentId("chain1"), searchers1);
    // Make another chain containing two of the same searcher instances and two new
    List<Searcher> searchers2 = new ArrayList<>(searchers1);
    searchers2.set(1, new TestSearcher("searcher5"));
    searchers2.set(3, new TestSearcher("searcher6"));
    Chain<Searcher> chain2 = new Chain<>(new ComponentId("chain2"), searchers2);
    // Execute both
    Query query = new Query("test");
    Result result1 = new Execution(chain1, Execution.Context.createContextStub()).search(query);
    Result result2 = new Execution(chain2, Execution.Context.createContextStub()).search(query);
    // Verify results
    assertEquals(4, result1.getConcreteHitCount());
    assertNotNull(result1.hits().get("searcher1-1"));
    assertNotNull(result1.hits().get("searcher2-1"));
    assertNotNull(result1.hits().get("searcher3-1"));
    assertNotNull(result1.hits().get("searcher4-1"));
    assertEquals(4, result2.getConcreteHitCount());
    assertNotNull(result2.hits().get("searcher1-2"));
    assertNotNull(result2.hits().get("searcher5-1"));
    assertNotNull(result2.hits().get("searcher3-2"));
    assertNotNull(result2.hits().get("searcher6-1"));
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) ArrayList(java.util.ArrayList) ComponentId(com.yahoo.component.ComponentId) Result(com.yahoo.search.Result)

Example 85 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class ExecutionTestCase method testContextCacheMoreSearchers.

public void testContextCacheMoreSearchers() {
    IndexFacts[] contextsBefore = new IndexFacts[7];
    IndexFacts[] contextsAfter = new IndexFacts[7];
    List<Searcher> l = new ArrayList<>(7);
    l.add(new ContextCacheSearcher(0, contextsBefore, contextsAfter));
    l.add(new ContextCacheSearcher(1, contextsBefore, contextsAfter));
    l.add(new ContextCacheSearcher(2, contextsBefore, contextsAfter));
    l.add(new ContextCacheSearcher(3, contextsBefore, contextsAfter));
    l.add(new ContextCacheSearcher(4, contextsBefore, contextsAfter));
    l.add(new ContextCacheSearcher(5, contextsBefore, contextsAfter));
    l.add(new ContextCacheSearcher(6, contextsBefore, contextsAfter));
    Chain<Searcher> chain = new Chain<>(l);
    Query query = new Query("?mutatecontext=2,4");
    new Execution(chain, Execution.Context.createContextStub()).search(query);
    assertSame(contextsBefore[0], contextsAfter[0]);
    assertSame(contextsBefore[1], contextsAfter[1]);
    assertSame(contextsBefore[2], contextsAfter[2]);
    assertSame(contextsBefore[3], contextsAfter[3]);
    assertSame(contextsBefore[4], contextsAfter[4]);
    assertSame(contextsBefore[5], contextsAfter[5]);
    assertSame(contextsBefore[6], contextsAfter[6]);
    assertSame(contextsBefore[0], contextsBefore[1]);
    assertNotSame(contextsBefore[1], contextsBefore[2]);
    assertSame(contextsBefore[2], contextsBefore[3]);
    assertNotSame(contextsBefore[3], contextsBefore[4]);
    assertSame(contextsBefore[4], contextsBefore[5]);
    assertSame(contextsBefore[5], contextsBefore[6]);
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) IndexFacts(com.yahoo.prelude.IndexFacts) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) ArrayList(java.util.ArrayList)

Aggregations

Chain (com.yahoo.component.chain.Chain)92 Execution (com.yahoo.search.searchchain.Execution)59 Searcher (com.yahoo.search.Searcher)57 Test (org.junit.Test)56 Result (com.yahoo.search.Result)48 Query (com.yahoo.search.Query)47 FeedContext (com.yahoo.feedapi.FeedContext)21 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)21 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)21 ClusterList (com.yahoo.vespaclient.ClusterList)21 Processor (com.yahoo.processing.Processor)17 Request (com.yahoo.processing.Request)10 Response (com.yahoo.processing.Response)10 ComponentId (com.yahoo.component.ComponentId)8 FederationSearcher (com.yahoo.search.federation.FederationSearcher)8 ArrayList (java.util.ArrayList)8 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)7 Message (com.yahoo.messagebus.Message)7 Hit (com.yahoo.search.result.Hit)7 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)6