@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()); } }
while (hiter.hasNext()) { Long2ObjectMap.Entry<SortedListAccumulator<Neighbor>> me = hiter.next(); neighbors.put(me.getLongKey(), me.getValue().finish());
@Override public BinaryOperator<Long2ObjectMap<List<E>>> combiner() { return (m1, m2) -> { for (Long2ObjectMap.Entry<List<E>> e2: m2.long2ObjectEntrySet()) { List<E> l2 = e2.getValue(); List<E> l1 = m1.get(e2.getLongKey()); if (l1 == null) { m1.put(e2.getLongKey(), l2); } else { l1.addAll(l2); } } return m1; }; }
@Override public void writePartition(DataOutput out, int partitionId) throws IOException { Long2ObjectOpenHashMap<DataInputOutput> partitionMap = map.get(partitionId); out.writeInt(partitionMap.size()); ObjectIterator<Long2ObjectMap.Entry<DataInputOutput>> iterator = partitionMap.long2ObjectEntrySet().fastIterator(); while (iterator.hasNext()) { Long2ObjectMap.Entry<DataInputOutput> entry = iterator.next(); out.writeLong(entry.getLongKey()); entry.getValue().write(out); } }
@Override public PackIndex build() { Long2ObjectMap<IntList> map = new Long2ObjectOpenHashMap<>(); for (Long2ObjectMap.Entry<IntArrayList> e: index.long2ObjectEntrySet()) { e.getValue().trim(); map.put(e.getLongKey(), e.getValue()); } index.clear(); return new PackIndex(map); } }
boolean fillInstance(InstanceTuple tuple, SliceInstance instance) { Long2ObjectOpenHashMap<Object> propertyValues = _instancesValues.get(new InstanceTuple(tuple.SubgraphId, tuple.Property, tuple.IsVertexProperty, tuple.InstanceId)); if (propertyValues == null) { return false; } ObjectIterator<Long2ObjectMap.Entry<Object>> it = propertyValues.long2ObjectEntrySet().fastIterator(); while (it.hasNext()) { Long2ObjectMap.Entry<Object> entry = it.next(); InstancePropertyMap propertyMap = tuple.IsVertexProperty ? instance.getPropertiesForVertexForAdd(entry.getLongKey()) : instance.getPropertiesForEdgeForAdd(entry.getLongKey()); propertyMap.setProperty(tuple.Property, entry.getValue()); } return true; }
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default Long getKey() { return Long.valueOf(getLongKey()); } }
private void mergeSpawnedEntities() { if ( !this.spawnedInThisTick.isEmpty() ) { for ( Long2ObjectMap.Entry<Entity> entry : this.spawnedInThisTick.long2ObjectEntrySet() ) { this.entitiesById.put( entry.getLongKey(), entry.getValue() ); } this.spawnedInThisTick.clear(); } }
@Override public long previousLong() { return i.previous().getLongKey(); }; @Override
@Override public boolean containsKey(final long k) { final ObjectIterator<Long2ObjectMap.Entry<V>> i = long2ObjectEntrySet().iterator(); while (i.hasNext()) if (i.next().getLongKey() == k) return true; return false; } @Override
@Override protected LongWritable getVertexId( Long2ObjectMap.Entry<OutEdges<LongWritable, E>> entry, LongWritable representativeVertexId) { representativeVertexId.set(entry.getLongKey()); return representativeVertexId; }
@Override protected LongWritable createVertexId( Long2ObjectMap.Entry<OutEdges<LongWritable, E>> entry) { return new LongWritable(entry.getLongKey()); }
private Long2ObjectMap<Long2DoubleMap> finishRows(Long2ObjectMap<Long2DoubleAccumulator> rows) { Long2ObjectMap<Long2DoubleMap> results = new Long2ObjectOpenHashMap<>(rows.size()); for (Long2ObjectMap.Entry<Long2DoubleAccumulator> e: rows.long2ObjectEntrySet()) { results.put(e.getLongKey(), e.getValue().finishMap()); } return results; }
@Override public void write(DataOutput out) throws IOException { out.writeInt(map.size()); ObjectIterator<Long2ObjectMap.Entry<V>> iterator = map.long2ObjectEntrySet().fastIterator(); while (iterator.hasNext()) { Long2ObjectMap.Entry<V> entry = iterator.next(); out.writeLong(entry.getLongKey()); valueWriter.write(out, entry.getValue()); } }
@Override public long nextLong() { return i.next().getLongKey(); }; @Override
itemUserSets.put(entry.getLongKey(), LongUtils.packedSet(entry.getValue()));
@Override public BinaryOperator<Long2ObjectMap<Long2DoubleAccumulator>> combiner() { return (am1, am2) -> { for (Long2ObjectMap.Entry<Long2DoubleAccumulator> e: Long2ObjectMaps.fastIterable(am2)) { long item = e.getLongKey(); Long2DoubleAccumulator a2 = e.getValue(); Long2DoubleAccumulator a1 = am1.get(item); if (a1 == null) { am1.put(item, a2); } else { for (Long2DoubleMap.Entry ae: Long2DoubleMaps.fastIterable(a2.finishMap())) { a1.put(ae.getLongKey(), ae.getDoubleValue()); } } } return am1; }; }
/** * Construct the mock item scorer. This will empty the builder. * @return A mock item scorer that will return the configured scores. */ public PrecomputedItemScorer build() { Long2ObjectMap<KeyedObjectMap<Result>> vectors = new Long2ObjectOpenHashMap<>(userData.size()); for (Long2ObjectMap.Entry<List<Result>> entry: userData.long2ObjectEntrySet()) { vectors.put(entry.getLongKey(), KeyedObjectMap.create(entry.getValue(), Results.keyExtractor())); } userData.clear(); return new PrecomputedItemScorer(vectors); } }
private Long2ObjectMap<Long2DoubleMap> finishRows(Long2ObjectMap<Long2DoubleAccumulator> rows) { Long2ObjectMap<Long2DoubleMap> results = new Long2ObjectOpenHashMap<>(rows.size()); for (Long2ObjectMap.Entry<Long2DoubleAccumulator> e: rows.long2ObjectEntrySet()) { results.put(e.getLongKey(), e.getValue().finishMap()); } return results; }
@Override public PackIndex build() { Long2ObjectMap<IntList> map = new Long2ObjectOpenHashMap<>(); for (Long2ObjectMap.Entry<IntArrayList> e: index.long2ObjectEntrySet()) { e.getValue().trim(); map.put(e.getLongKey(), e.getValue()); } index.clear(); return new PackIndex(map); } }