TableRateLimiter { int getEntryCredits(Collection<Entry<K, V>> entries, Object ... args) { if (creditFn == null) { return entries.size(); } else { return entries.stream().mapToInt(e -> creditFn.getCredits(e.getKey(), e.getValue(), args)).sum(); } } TableRateLimiter(String tableId, RateLimiter rateLimiter, CreditFunction<K, V> creditFn, String tag); void setTimerMetric(Timer timer); void throttle(K key, Object ... args); void throttle(K key, V value, Object ... args); void throttle(int opId, Object ... args); void throttle(Collection<K> keys, Object ... args); void throttleRecords(Collection<Entry<K, V>> records, Object ... args);  }
@Test public void testCreditEntries() { TableRateLimiter<String, String> rateLimitHelper = getThrottler(); Assert.assertEquals(12, rateLimitHelper.getEntryCredits( Arrays.asList(new Entry<>("abc", "efg"), new Entry<>("hij", "lmn")))); }