this.taxoReader = taxoReader;
this.iParams = iParams;
}
public ExampleResult getResults() {
ExampleResult exampleRes = new ExampleResult();
exampleRes.setFacetResults(results);
return exampleRes;
}
@Override
public void run() {
try {
results = MultiCLSearcher.searchWithFacets(indexReader, taxoReader, iParams);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
// Instantiate threads, but do not start them
Multi[] multis = new Multi[numThreads];
for (int i = 0; i < numThreads - 1; i++) {
multis[i] = new Multi(slowIndexReader, slowTaxoReader, MultiCLIndexer.MULTI_IPARAMS);
}
// The last thread uses ONLY the DefaultFacetIndexingParams so that
// it references a different TFC cache. This will still result
// in valid results, but will only search one of the category lists
// instead of all of them.
multis[numThreads - 1] = new Multi(slowIndexReader, slowTaxoReader, new DefaultFacetIndexingParams());
// Gentleman, start your engines
for (Multi m : multis) {
m.start();
}
// Wait for threads and get results
ExampleResult[] multiResults = new ExampleResult[numThreads];
for (int i = 0; i < numThreads; i++) {
multis[i].join();
multiResults[i] = multis[i].getResults();
}
// Each of the (numThreads-1) should have the same predictable
// results, which we test for here.
for (int i = 0; i < numThreads - 1; i++) {
ExampleResult eResults = multiResults[i];
TestMultiCLExample.assertCorrectMultiResults(eResults);
}
// The last thread, which only searched over the
// DefaultFacetIndexingParams,
// has its own results
ExampleResult eResults = multiResults[numThreads - 1];
List<FacetResult> results = eResults.getFacetResults();
assertEquals(3, results.size());
String[] expLabels = new String[] { "5", "5/5", "6/2" };
double[] expValues = new double[] { 0.0, 0.0, 1.0 };
for (int i = 0; i < 3; i++) {
FacetResult result = results.get(i);