Class DistinctSampler<K>

java.lang.Object
com.apple.foundationdb.relational.util.DistinctSampler<K>
Type Parameters:
K - the type of item to sample.
All Implemented Interfaces:
Predicate<K>

@API(EXPERIMENTAL) public class DistinctSampler<K> extends Object implements Predicate<K>
A sampler which tests individual elements according to a fixed-throughput adaptive strategy.

Essentially, this logger ensures that the given item is only logged as often as a specified rate requires. It does this by maintaining a cache of items. Upon request, if the element is not in the cache, it is logged. Otherwise, it is logged according to the configured TokenBucketSampler for that item, which maintains a (mostly) constant rate of log sampling.

  • Constructor Details

    • DistinctSampler

      public DistinctSampler(int maxSize, int maxLogsPerSecond)
    • DistinctSampler

      public DistinctSampler(int maxCacheSize, Supplier<Sampler> samplerFactory)
  • Method Details

    • test

      public boolean test(K item)
      Specified by:
      test in interface Predicate<K>