@Override public Object2LongOpenHashMap<String> remainingSegmentSizeBytes() { final Object2LongOpenHashMap<String> resultMap = new Object2LongOpenHashMap<>(); resultMap.defaultReturnValue(UNKNOWN_REMAINING_SEGMENT_SIZE); for (QueueEntry entry : queue) { final VersionedIntervalTimeline<String, DataSegment> timeline = dataSources.get(entry.getDataSource()); final Interval interval = new Interval(timeline.first().getInterval().getStart(), entry.interval.getEnd()); final List<TimelineObjectHolder<String, DataSegment>> holders = timeline.lookup(interval); resultMap.put( entry.getDataSource(), holders.stream() .flatMap(holder -> StreamSupport.stream(holder.getObject().spliterator(), false)) .mapToLong(chunk -> chunk.getObject().getSize()) .sum() ); } return resultMap; }
private List<LocalRegion> getAllSortedRegionList() { List<LocalRegion> allRegionList = getAllRegionList(); // Capture the sizes so that they do not change while sorting final Object2LongOpenHashMap<LocalRegion> sizes = new Object2LongOpenHashMap<>(allRegionList.size()); for (LocalRegion region : allRegionList) { long size = region instanceof BucketRegion ? ((BucketRegion) region).getSizeForEviction() : region.size(); sizes.put(region, size); } // Sort with respect to other PR buckets also in case of multiple PRs allRegionList.sort((region1, region2) -> { long numEntries1 = sizes.get(region1); long numEntries2 = sizes.get(region2); if (numEntries1 > numEntries2) { return -1; } else if (numEntries1 < numEntries2) { return 1; } return 0; }); return allRegionList; }
@Override public long set(K k, long v) { long rv = counts.put(k, v); sumOfCounts = sumOfCounts - rv + v; return rv; }
/** * Creates a new hash map using the elements of two parallel arrays. * * @param k * the array of keys of the new hash map. * @param v * the array of corresponding values in the new hash map. * @param f * the load factor. * @throws IllegalArgumentException * if {@code k} and {@code v} have different lengths. */ public Object2LongOpenHashMap(final K[] k, final long[] v, final float f) { this(k.length, f); if (k.length != v.length) throw new IllegalArgumentException( "The key array and the value array have different lengths (" + k.length + " and " + v.length + ")"); for (int i = 0; i < k.length; i++) this.put(k[i], v[i]); } /**
/** * Increases the count for a given <code>sample</code>. * * @param sample * the sample to increase the count for * @param number * the number to increase by */ public void addSample(T sample, long number) { this.n = this.n + number; long sampleFreq = number; if (freqDist.containsKey(sample)) { sampleFreq = freqDist.get(sample) + number; } freqDist.put(sample, sampleFreq); if (sampleFreq > maxFreq) { maxFreq = sampleFreq; maxSample = sample; } }
AbstractDynamicTransaction tx = dynamicTransaction.newInstance(); tx.args.putAll(a.args); entityTypes.forEach(c -> tx.ids.put(c, b.id(c)));
private List<LocalRegion> getAllSortedRegionList(){ List<LocalRegion> allRegionList = getAllRegionList(); //Capture the sizes so that they do not change while sorting final Object2LongOpenHashMap sizes = new Object2LongOpenHashMap(allRegionList.size()); for(LocalRegion r : allRegionList) { long size = r instanceof BucketRegion ?((BucketRegion)r).getSizeForEviction() : r.size(); sizes.put(r, size); } //Sort with respect to other PR buckets also in case of multiple PRs Collections.sort(allRegionList, new Comparator<LocalRegion>() { public int compare(LocalRegion r1, LocalRegion r2) { long numEntries1 = sizes.get(r1); long numEntries2 = sizes.get(r2); if (numEntries1 > numEntries2) { return -1; } else if (numEntries1 < numEntries2) { return 1; } return 0; } }); return allRegionList; }
userIdMap.put(s[0], counter.incrementAndGet());
@Override public Object2LongOpenHashMap<String> remainingSegmentSizeBytes() { final Object2LongOpenHashMap<String> resultMap = new Object2LongOpenHashMap<>(); resultMap.defaultReturnValue(UNKNOWN_REMAINING_SEGMENT_SIZE); for (QueueEntry entry : queue) { final VersionedIntervalTimeline<String, DataSegment> timeline = dataSources.get(entry.getDataSource()); final Interval interval = new Interval(timeline.first().getInterval().getStart(), entry.interval.getEnd()); final List<TimelineObjectHolder<String, DataSegment>> holders = timeline.lookup(interval); resultMap.put( entry.getDataSource(), holders.stream() .flatMap(holder -> StreamSupport.stream(holder.getObject().spliterator(), false)) .mapToLong(chunk -> chunk.getObject().getSize()) .sum() ); } return resultMap; }
hm = new Object2LongOpenHashMap(); for (int j = 0; j < keySize; j++) { if (isKeyValue) ((Object2LongOpenHashMap) hm).put(keysArrayList.getString(j), Long.parseLong(valuesArrayList.getString(j))); else { String key = keysList.getString(j); ((Object2LongOpenHashMap) hm).put(key, Long.parseLong(values.getString(keysList.getString(j))));