.hasAlternative()))) {
return this.evaluateTriplePatternAfterAdding(keys[0],
triplePattern);
} else {
// asynchronously retrieve the results...
final ResultCollector resultCollector = new ResultCollector();
resultCollector.setNumberOfThreads(keys.length);
final Thread[] threads = new Thread[keys.length];
for (int i = 0; i < keys.length; i++) {
final KeyContainer<T> key = keys[i];
threads[i] = new Thread() {
@SuppressWarnings("unchecked")
@Override
public void run() {
resultCollector.process(TomP2PLocalStorage.this
.evaluateTriplePatternAfterAdding(key,
triplePattern), 0);
if (key instanceof AlternativeKeyContainer
&& ((AlternativeKeyContainer) key)
.hasAlternative()) {
AlternativeKeyContainer alternateKey = (AlternativeKeyContainer) key;
for (KeyContainer kc : alternateKey
.getAlternatives()) {
resultCollector
.process(
TomP2PLocalStorage.this
.evaluateTriplePatternAfterAdding(
kc,
triplePattern),
0);
}
}
resultCollector.incNumberOfThreads();
}
};
threads[i]
.setName(String
.format("Parallel pattern evaluation: key=%s%s, pattern=%s",
key.type, key.key, triplePattern));
threads[i].start();
}
return resultCollector.getResult();
}
} catch (final TriplePatternNotSupportedError e) {
throw new TriplePatternNotSupportedError(this.distribution,
triplePattern);
}