@Override public Long2ObjectMap<Aggregator[]> makeDimExtractionAggregateStore() { return new Long2ObjectOpenHashMap<>(); }
@Override public void record(long key) { policyStats.recordOperation(); Node node = data.get(key); if (node == null) { node = new Node(key); data.put(key,node); onMiss(node); } else if (node.status == Status.FILTER) { onFilterHit(node); } else if (node.status == Status.MAIN) { onMainHit(node); } else if (node.status == Status.NON_RESIDENT) { onNonResidentHit(node); } else { throw new IllegalStateException(); } }
private void adaptFilterToMain(Node node) { /** * Cache miss and history hit with adaptation: * Evict from filter stack. Then insert to main stack. */ policyStats.recordEviction(); policyStats.recordMiss(); Node victim = headFilter.prevFilter; victim.removeFrom(StackType.FILTER); if (victim.isInMain) { victim.status = Status.NON_RESIDENT; } else { data.remove(victim.key); } residentFilter--; node.moveToTop(StackType.MAIN); node.status = Status.MAIN; data.put(node.key, node); residentMain++; }
Preconditions.checkNotNull(user, "item set"); Long2ObjectOpenHashMap<SortedListAccumulator<Neighbor>> heaps = new Long2ObjectOpenHashMap<>(items.size()); for (LongIterator iter = items.iterator(); iter.hasNext();) { long item = iter.nextLong(); heaps.put(item, SortedListAccumulator.decreasing(neighborhoodSize, Neighbor.SIMILARITY_COMPARATOR)); SortedListAccumulator<Neighbor> heap = heaps.get(item); if (heap != null) { heap.add(nbr); Long2ObjectMap<List<Neighbor>> neighbors = new Long2ObjectOpenHashMap<>(); Iterator<Long2ObjectMap.Entry<SortedListAccumulator<Neighbor>>> hiter = heaps.long2ObjectEntrySet().fastIterator(); while (hiter.hasNext()) { Long2ObjectMap.Entry<SortedListAccumulator<Neighbor>> me = hiter.next();
public Object get(long id) { Object result; if (id >= 0 && id <= 0x00000000FFFFFFFFL) { result = this.ints.get((int) id); } else { result = this.longs.get(id); } return result; }
public Object put(long id, Object v) { Object result; if (id == 0) { throw new IllegalArgumentException(); } else if (id > 0 && id <= 0x00000000FFFFFFFFL) { result = this.ints.put((int) id, v); } else { result = this.longs.put(id, v); } return result; }
public void addInstance(InstanceTuple tuple, ISubgraphInstance instance) { Collection<? extends ISubgraphObjectProperties> propertyValues = tuple.IsVertexProperty ? instance.getPropertiesForVertices() : instance.getPropertiesForEdges(); Long2ObjectOpenHashMap<Object> values = new Long2ObjectOpenHashMap<>(128, 1f); for (ISubgraphObjectProperties objectProperties : propertyValues) { if (!objectProperties.hasSpecifiedProperty(tuple.Property)) { continue; } values.put(objectProperties.getId(), objectProperties.getValue(tuple.Property)); } _instancesValues.put(tuple, values); }
/** * Open an order book. * * <p>If the order book for the instrument is already open, do nothing.</p> * * @param instrument an instrument */ public void open(long instrument) { if (books.containsKey(instrument)) return; books.put(instrument, new OrderBook(instrument)); }
private HashMap<String, GroupedValue> convert(MapResult mapResult) { HashMap<String, GroupedValue> ret = new HashMap<String, GroupedValue>(mapResult.results.size()); String[] temp = new String[mapResult.dictionaries.length]; int[] numBits = new int[columns.length]; for (int i = 0; i < columns.length; i++) { numBits[i] = BitHacks.findLogBase2(mapResult.dictionaries[i].size()) + 1; } for (long key : mapResult.results.keySet()) { ret.put(decodeKey(temp, mapResult.dictionaries, numBits, key), mapResult.results.get(key)); } return ret; }
private void pruneStack() { for (;;) { Node bottom = headMain.prevMain; if ((bottom == headMain) || (bottom.status == Status.MAIN)) { break; } else if (bottom.status == Status.FILTER) { policyStats.recordOperation(); bottom.removeFrom(StackType.MAIN); } else if (bottom.status == Status.NON_RESIDENT) { policyStats.recordOperation(); bottom.removeFrom(StackType.MAIN); data.remove(bottom.key); } } }
/** * Auxiliary method to be used by getTarget * * @param vertexId vertexId * @return return byte value of target */ public byte getByteTarget(LongWritable vertexId) { long key = vertexId.get() >>> lowerOrder; int suffix = (int) (vertexId.get() & lowerBitMask); if (!idToBytes.containsKey(key)) { return -1; } return idToBytes.get(key)[suffix]; }
private boolean sanityCheck() { // kmer lookup is correct assert(byKmer.long2ObjectEntrySet().stream().allMatch(kvp -> kvp.getLongKey() == kvp.getValue().kmer)); // empty aggregators have been removed assert(byKmer.values().stream().allMatch(ag -> !ag.active.isEmpty())); // could have many start position entries, but only one position is valid (and even that could have duplicate entries) assert(byEnd.size() >= byKmer.size()); assert(byEnd.stream().allMatch(snapshot -> !snapshot.isValid() || byKmer.containsKey(snapshot.aggregator().kmer))); assert(byKmer.values().stream().allMatch(ag -> ag.end() >= inputPosition)); if (outputSortBuffer.isEmpty()) { assert(byKmer.isEmpty()); assert(byEnd.isEmpty()); assert(!underlying.hasNext()); } return true; } public int tracking_processedSize() {
public int size() { return this.ints.size() + this.longs.size(); }
@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 Iterable<LongWritable> getPartitionDestinationVertices( int partitionId) { Long2ObjectOpenHashMap<T> partitionMap = map.get(partitionId); List<LongWritable> vertices = Lists.newArrayListWithCapacity(partitionMap.size()); LongIterator iterator = partitionMap.keySet().iterator(); while (iterator.hasNext()) { vertices.add(new LongWritable(iterator.nextLong())); } return vertices; } }
@Override public void putAll(Map<? extends Long, ? extends V> m) { if (f <= .5) ensureCapacity(m.size()); // The resulting map will be sized for m.size() elements else tryCapacity(size() + m.size()); // The resulting map will be tentatively sized for size() + m.size() // elements super.putAll(m); }
@Override public boolean containsKey(LongWritable key) { return map.containsKey(key.get()); }