List<OutlierResult> oresults = ResultUtil.getOutlierResults(result);
List<IterableResult<?>> iterables = ResultUtil.getIterableResults(result);
List<OrderingResult> orderings = ResultUtil.getOrderingResults(result);
// Outlier results are the main use case.
for(OutlierResult o : oresults) {
final OrderingResult or = o.getOrdering();
Relation<O> relation = db.getRelation(distanceFunction.getInputTypeRestriction());
db.getHierarchy().add(or, computeSimilarityMatrixImage(relation, or.iter(relation.getDBIDs())));
// Process them only once.
orderings.remove(or);
nonefound = false;
}
// try iterable results first
// FIXME: find the appropriate place to call addDerivedResult
for(IterableResult<?> ir : iterables) {
Iterator<DBID> iter = getDBIDIterator(ir);
if(iter != null) {
Relation<O> relation = db.getRelation(distanceFunction.getInputTypeRestriction());
db.getHierarchy().add(ir, computeSimilarityMatrixImage(relation, iter));
nonefound = false;
}
}
// FIXME: find appropriate place to add the derived result
// otherwise apply an ordering to the database IDs.
for(OrderingResult or : orderings) {
Relation<O> relation = db.getRelation(distanceFunction.getInputTypeRestriction());
Iterator<DBID> iter = or.iter(relation.getDBIDs());
db.getHierarchy().add(or, computeSimilarityMatrixImage(relation, iter));
nonefound = false;
}
if(nonefound) {