@Override public EntityIndex build() { Preconditions.checkState(entityLists != null, "build() already called"); // arrange compact storage of the index KeyedObjectMapBuilder<IdBox<ImmutableList<Entity>>> bld = KeyedObjectMap.newBuilder(); for (Long2ObjectMap.Entry<ImmutableList.Builder<Entity>> entry: entityLists.long2ObjectEntrySet()) { long value = entry.getLongKey(); bld.add(IdBox.create(value, entry.getValue().build())); entry.setValue(null); } entityLists = null; return new LongEntityIndex(bld.build()); } }
@Override public EntityIndex build() { Preconditions.checkState(entityLists != null, "build() already called"); // arrange compact storage of the index KeyedObjectMapBuilder<IdBox<ImmutableList<Entity>>> bld = KeyedObjectMap.newBuilder(); for (Long2ObjectMap.Entry<ImmutableList.Builder<Entity>> entry: entityLists.long2ObjectEntrySet()) { long value = entry.getLongKey(); bld.add(IdBox.create(value, entry.getValue().build())); entry.setValue(null); } entityLists = null; return new LongEntityIndex(bld.build()); } }
private void pruneItems(Long2ObjectMap<Long2DoubleMap> itemRatingData, Long2ObjectMap<LongSortedSet> userItems) { if (minCommonUsers <= 0) { return; } // copy items to array to all long[] items = itemRatingData.keySet().toLongArray(); for (long item: items) { Long2DoubleMap iv = itemRatingData.get(item); if (iv.size() < minCommonUsers) { itemRatingData.remove(item); } } for (Long2ObjectMap.Entry<LongSortedSet> e: userItems.long2ObjectEntrySet()) { e.setValue(LongUtils.setIntersect(e.getValue(), itemRatingData.keySet())); } } }
private void pruneItems(Long2ObjectMap<Long2DoubleMap> itemRatingData, Long2ObjectMap<LongSortedSet> userItems) { if (minCommonUsers <= 0) { return; } // copy items to array to all long[] items = itemRatingData.keySet().toLongArray(); for (long item: items) { Long2DoubleMap iv = itemRatingData.get(item); if (iv.size() < minCommonUsers) { itemRatingData.remove(item); } } for (Long2ObjectMap.Entry<LongSortedSet> e: userItems.long2ObjectEntrySet()) { e.setValue(LongUtils.setIntersect(e.getValue(), itemRatingData.keySet())); } } }