/** * Iterates {@linkplain FastEntrySet#fastForEach(Consumer) quickly}, if * possible, on the {@linkplain Map#entrySet() entry set} of the provided * {@code map}. * * @param map * a map on which we will try to iterate * {@linkplain FastEntrySet#fastForEach(Consumer) quickly}. * @param consumer * the consumer that will be passed to * {@link FastEntrySet#fastForEach(Consumer)}, if possible, or to * {@link Iterable#forEach(Consumer)}. * @since 8.1.0 */ @SuppressWarnings("unchecked") public static <K> void fastForEach(Object2LongMap<K> map, final Consumer<? super Object2LongMap.Entry<K>> consumer) { final ObjectSet<Object2LongMap.Entry<K>> entries = map.object2LongEntrySet(); if (entries instanceof Object2LongMap.FastEntrySet) ((Object2LongMap.FastEntrySet<K>) entries).fastForEach(consumer); else entries.forEach(consumer); } /**
private CoordinatorStats makeStats(int numCompactionTasks, CompactionSegmentIterator iterator) { final CoordinatorStats stats = new CoordinatorStats(); stats.addToGlobalStat(COMPACT_TASK_COUNT, numCompactionTasks); remainingSegmentSizeBytes = iterator.remainingSegmentSizeBytes(); iterator.remainingSegmentSizeBytes().object2LongEntrySet().fastForEach( entry -> { final String dataSource = entry.getKey(); final long numSegmentsWaitCompact = entry.getLongValue(); stats.addToDataSourceStat(SEGMENT_SIZE_WAIT_COMPACT, dataSource, numSegmentsWaitCompact); } ); return stats; }
private CoordinatorStats makeStats(int numCompactionTasks, CompactionSegmentIterator iterator) { final CoordinatorStats stats = new CoordinatorStats(); stats.addToGlobalStat(COMPACT_TASK_COUNT, numCompactionTasks); remainingSegmentSizeBytes = iterator.remainingSegmentSizeBytes(); iterator.remainingSegmentSizeBytes().object2LongEntrySet().fastForEach( entry -> { final String dataSource = entry.getKey(); final long numSegmentsWaitCompact = entry.getLongValue(); stats.addToDataSourceStat(SEGMENT_SIZE_WAIT_COMPACT, dataSource, numSegmentsWaitCompact); } ); return stats; }