/** * Build a sparse vector directly from the list of IDs. This allows a scored ID list builder to be * used to efficiently accumulate a sparse vector. If the same ID is added multiple times, the * first instance is used. * * @return A sparse vector containing the data accumulated. */ public ImmutableSparseVector buildVector() { MutableSparseVector msv = MutableSparseVector.create(ids); final int size = size(); for (int i = 0; i < size; i++) { msv.set(ids.get(i), scores.get(i)); } for (ChannelStorage chan : channels.values()) { MutableSparseVector vchan = msv.getOrAddChannelVector(chan.symbol); for (int i = 0; i < size; i++) { vchan.set(ids.get(i), chan.values.get(i)); } } for (TypedChannelStorage<?> chan : typedChannels.values()) { Long2ObjectMap vchan = msv.getOrAddChannel(chan.symbol); for (int i = 0; i < size; i++) { vchan.put(ids.get(i), chan.values.get(i)); } } return msv.freeze(); }