use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class ExecutionTestCase method testContextCacheSingleLengthSearchChain.
public void testContextCacheSingleLengthSearchChain() {
IndexFacts[] contextsBefore = new IndexFacts[1];
IndexFacts[] contextsAfter = new IndexFacts[1];
List<Searcher> l = new ArrayList<>(1);
l.add(new ContextCacheSearcher(0, contextsBefore, contextsAfter));
Chain<Searcher> chain = new Chain<>(l);
Query query = new Query("?mutatecontext=0");
new Execution(chain, Execution.Context.createContextStub()).search(query);
assertEquals(contextsBefore[0], contextsAfter[0]);
assertSame(contextsBefore[0], contextsAfter[0]);
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class SearchChainDispatcherSearcherTestCase method testChainContinuation.
/**
* Searchers down the chain after SearchChainDispatcher
* should be executed
*/
@SuppressWarnings("deprecation")
public void testChainContinuation() {
// Instantiate Name Rewriter
RewritesConfig config = QueryRewriteSearcherTestUtils.createConfigObj(NAME_REWRITER_CONFIG_PATH);
HashMap<String, File> fileList = new HashMap<>();
fileList.put(NameRewriter.NAME_ENTITY_EXPAND_DICT, new File(NAME_ENTITY_EXPAND_DICT_PATH));
NameRewriter nameRewriter = new NameRewriter(config, fileList);
// Instantiate Misspell Rewriter
MisspellRewriter misspellRewriter = new MisspellRewriter();
// Create market search chain of only misspell rewriter
Chain<Searcher> marketSearchChain = new Chain<>(US_MARKET_SEARCH_CHAIN, misspellRewriter);
// Add market search chain to the registry
SearchChainRegistry registry = new SearchChainRegistry();
registry.register(marketSearchChain);
// Instantiate Search Chain Dispatcher Searcher
SearchChainDispatcherSearcher searchChainDispatcher = new SearchChainDispatcherSearcher();
// Create a chain containing the dispatcher and the name rewriter
ArrayList<Searcher> searchers = new ArrayList<>();
searchers.add(searchChainDispatcher);
searchers.add(nameRewriter);
// Create a chain containing only the dispatcher
Chain<Searcher> mainSearchChain = new Chain<>(searchers);
Execution execution = new Execution(mainSearchChain, Execution.Context.createContextStub(registry, null));
new QueryRewriteSearcherTestUtils(execution);
IntentModel intentModel = new IntentModel(utils.createInterpretation("wills smith", 0.9, true, false), utils.createInterpretation("will smith", 1.0, false, true));
utils.assertRewrittenQuery("?query=willl+smith&QRWChain=" + US_MARKET_SEARCH_CHAIN + "&" + MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_RW + "=true&" + MISSPELL_REWRITER_NAME + "." + RewriterConstants.QSS_SUGG + "=true&" + NAME_REWRITER_NAME + "." + RewriterConstants.REWRITES_AS_UNIT_EQUIV + "=true&" + NAME_REWRITER_NAME + "." + RewriterConstants.ORIGINAL_AS_UNIT_EQUIV + "=true", "query 'OR (AND willl smith) (AND will smith) " + "\"will smith\" \"will smith movies\" " + "\"will smith news\" \"will smith imdb\" " + "\"will smith lyrics\" \"will smith dead\" " + "\"will smith nfl\" \"will smith new movie hancock\" " + "\"will smith biography\"'", intentModel);
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class ElapsedTimeTestCase method testReportGeneration.
public void testReportGeneration() {
TimeTracker t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
runSomeTraffic(t);
ElapsedTime elapsed = new ElapsedTime();
elapsed.add(t);
t = new TimeTracker(new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third")));
runSomeTraffic(t);
elapsed.add(t);
assertEquals(true, elapsed.hasDetailedData());
assertEquals("Time use per searcher:" + " first(QueryProcessing(SEARCH: 2 ms), ResultProcessing(SEARCH: 4 ms, FILL: 4 ms)),\n" + " second(QueryProcessing(SEARCH: 4 ms, FILL: 4 ms), ResultProcessing(SEARCH: 4 ms, FILL: 4 ms)),\n" + " third(QueryProcessing(SEARCH: 4 ms, FILL: 4 ms), ResultProcessing()).", elapsed.detailedReport());
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class ElapsedTimeTestCase method testBasicBreakdownFullyWiredIn.
// This test is to make sure the other tests correctly simulate the call
// order into the TimeTracker
public void testBasicBreakdownFullyWiredIn() {
Chain<? extends Searcher> chain = new Chain<Searcher>(new UselessSearcher("first"), new UselessSearcher("second"), new UselessSearcher("third"));
Execution exec = new Execution(chain, Execution.Context.createContextStub());
exec.timer().injectTimeSource(new CreativeTimeSource(SEARCH_TIMESEQUENCE));
exec.context().setDetailedDiagnostics(true);
exec.search(new Query());
SearcherTimer[] searchers = exec.timer().searcherTracking();
checkTiming(searchers);
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class ElapsedTimeTestCase method testBasicBreakdownWithFillFullyWiredInFirstSearcherNotFirstInChain.
public void testBasicBreakdownWithFillFullyWiredInFirstSearcherNotFirstInChain() {
Chain<? extends Searcher> chain = new Chain<>(new SecondTestingSearcher(), new UselessSearcher("first"), new UselessSearcher("second"), new AlmostUselessSearcher("third"));
Execution exec = new Execution(chain, Execution.Context.createContextStub());
exec.search(new Query());
}
Aggregations