TopNScoredItemAccumulator accumulator = new TopNScoredItemAccumulator(n);
for (VectorEntry e : v.view(VectorEntry.State.SET)) {
accumulator.put(e.getKey(), e.getValue());
}
MutableSparseVector truncated = accumulator.finishVector();
// retain only the truncated keys
v.keySet().retainAll(truncated.keySet());
}
}