accum.put(pred.getKey(), v);
}
List<ScoredId> results = accum.finish();
if (!scores.getChannelSymbols().isEmpty()) {
ScoredIdListBuilder builder = ScoredIds.newListBuilder(results.size());
List<Pair<Symbol,SparseVector>> cvs = Lists.newArrayList();
List<Pair<TypedSymbol<?>, Long2ObjectMap<?>>> channels = Lists.newArrayList();
for (Symbol sym: scores.getChannelVectorSymbols()) {
builder.addChannel(sym, Double.NaN);
cvs.add(Pair.of(sym, scores.getChannelVector(sym)));
}
for (TypedSymbol<?> sym: scores.getChannelSymbols()) {
if (!sym.getType().equals(Double.class)) {
builder.addChannel(sym);
channels.add((Pair) Pair.of(sym, scores.getChannel(sym)));
}
}
for (ScoredId id: results) {
ScoredIdBuilder copy = ScoredIds.copyBuilder(id);
for (Pair<Symbol,SparseVector> pair: cvs) {
if (pair.getRight().containsKey(id.getId())) {
copy.addChannel(pair.getLeft(), pair.getRight().get(id.getId()));
}
}
for (Pair<TypedSymbol<?>, Long2ObjectMap<?>> pair: channels) {
if (pair.getRight().containsKey(id.getId())) {
copy.addChannel((TypedSymbol) pair.getLeft(), pair.getRight().get(id.getId()));
}
}
builder.add(copy.build());
}
return builder.finish();
} else {
return results;
}
}