use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class ProcessingTestCase method testChainedProcessing2.
/**
* Execute the same processors in a different order
*/
@Test
public void testChainedProcessing2() {
// Create a chain
Chain<Processor> chain = new Chain<>(new Get6DataItems(), new CombineData(), new DataSource());
// Execute it
Request request = new Request();
request.properties().set("appendage", 1);
Response response = Execution.createRoot(chain, 0, Execution.Environment.createEmpty()).process(request);
// Check the result
assertEquals(6, response.data().asList().size());
assertEquals("first.2, third.2", response.data().get(0).toString());
assertEquals("second.2", response.data().get(1).toString());
assertEquals("first.4, third.4", response.data().get(2).toString());
assertEquals("second.4", response.data().get(3).toString());
assertEquals("first.6, third.6", response.data().get(4).toString());
assertEquals("second.6", response.data().get(5).toString());
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class AsyncExecutionTestCase method testAsyncExecution.
/**
* Execute a processing chain which forks off into multiple threads
*/
@Test
public void testAsyncExecution() {
// Create a chain
Chain<Processor> chain = new Chain<>(new CombineData(), new BlockingSplitter(2), new Get6DataItems(), new DataSource());
// Execute it
Request request = new Request();
request.properties().set("appendage", 1);
Response response = Execution.createRoot(chain, 0, Execution.Environment.createEmpty()).process(request);
// Verify the result
assertEquals(6 * 2 - 1, response.data().asList().size());
assertEquals("first.2, third.2", response.data().get(0).toString());
assertEquals("second.2", response.data().get(1).toString());
assertEquals("first.3", response.data().get(2).toString());
assertEquals("second.3", response.data().get(3).toString());
assertEquals("third.3", response.data().get(4).toString());
// from the parallel execution
assertEquals("first.2", response.data().get(5).toString());
assertEquals("second.2", response.data().get(6).toString());
assertEquals("third.2", response.data().get(7).toString());
assertEquals("first.3", response.data().get(8).toString());
assertEquals("second.3", response.data().get(9).toString());
assertEquals("third.3", response.data().get(10).toString());
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class AsyncExecutionOfOneChainTestCase method testParallelExecutionOfOneChain.
/**
* Tests having a result with some slow source data which should pass directly to rendering
*/
public void testParallelExecutionOfOneChain() {
// Setup
Chain<Searcher> mainChain = new Chain<>(new ParallelExecutor(), new ResultProcessor(), new RegularProvider());
// Execute
Result result = new Execution(mainChain, Execution.Context.createContextStub()).search(new Query());
// Verify
assertEquals("Received 2 hits from 3 threads", 3 * 2, result.hits().size());
assertEquals(1.0, result.hits().get("thread-0:hit-0").getRelevance().getScore());
assertEquals(1.0, result.hits().get("thread-1:hit-0").getRelevance().getScore());
assertEquals(1.0, result.hits().get("thread-2:hit-0").getRelevance().getScore());
assertEquals(0.5, result.hits().get("thread-0:hit-1").getRelevance().getScore());
assertEquals(0.5, result.hits().get("thread-1:hit-1").getRelevance().getScore());
assertEquals(0.5, result.hits().get("thread-2:hit-1").getRelevance().getScore());
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class ExecutionTestCase method testNestedExecution.
public void testNestedExecution() {
// Make a chain
List<Searcher> searchers1 = new ArrayList<>();
searchers1.add(new FillableTestSearcher("searcher1"));
searchers1.add(new WorkflowSearcher());
searchers1.add(new TestSearcher("searcher2"));
searchers1.add(new FillingSearcher());
searchers1.add(new FillableTestSearcherAtTheEnd("searcher3"));
Chain<Searcher> chain1 = new Chain<>(new ComponentId("chain1"), searchers1);
// Execute it
Query query = new Query("test");
Result result1 = new Execution(chain1, Execution.Context.createContextStub()).search(query);
// Verify results
assertEquals(7, result1.getConcreteHitCount());
assertNotNull(result1.hits().get("searcher1-1"));
assertNotNull(result1.hits().get("searcher2-1"));
assertNotNull(result1.hits().get("searcher3-1"));
assertNotNull(result1.hits().get("searcher3-1-filled"));
assertNotNull(result1.hits().get("searcher2-2"));
assertNotNull(result1.hits().get("searcher3-2"));
assertNotNull(result1.hits().get("searcher3-2-filled"));
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class ExecutionTestCase method testBasicFill.
@Test
public void testBasicFill() {
Chain<Searcher> chain = new Chain<Searcher>(new FillableResultSearcher());
Execution execution = new Execution(chain, Execution.Context.createContextStub(null));
Result result = execution.search(new Query(com.yahoo.search.test.QueryTestCase.httpEncode("?presentation.summary=all")));
assertNotNull(result.hits().get("a"));
assertNull(result.hits().get("a").getField("filled"));
execution.fill(result);
assertTrue((Boolean) result.hits().get("a").getField("filled"));
}
Aggregations