}
@Override
public void score(long user, @Nonnull MutableSparseVector output) {
primaryScorer.score(user, output);
LongSet fallbackKeys = LongSets.EMPTY_SET;
if (output.size() != output.keyDomain().size()) {
fallbackKeys = output.unsetKeySet();
MutableSparseVector blpreds = MutableSparseVector.create(fallbackKeys);
baselineScorer.score(user, blpreds);
output.set(blpreds);
}
// FIXME Make this faster
Long2ObjectMap<ScoreSource> chan = output.getOrAddChannel(SCORE_SOURCE_SYMBOL);
for (VectorEntry e: output) {
long key = e.getKey();
ScoreSource source = ScoreSource.PRIMARY;
if (fallbackKeys.contains(key)) {
source = ScoreSource.BASELINE;
}
chan.put(key, source);
}
}