Class Histogram
- java.lang.Object
-
- org.apache.beam.sdk.extensions.combiners.Histogram
-
public class Histogram extends java.lang.ObjectA histogram transform with a combiner that efficiently constructs linear, exponential or explicit histograms from large datasets of input data. Bucket bounds can be specified using theHistogram.BucketBoundsclass.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHistogram.BoundsInclusivityEnum for setting whether the lower (and upper) bounds of bucket intervals are inclusive or exclusive.static classHistogram.BucketBoundsDefines the bounds for histogram buckets.static classHistogram.HistogramCombineFn<T>Combiner for calculating histograms.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends java.lang.Number>
org.apache.beam.sdk.transforms.Combine.Globally<T,java.util.List<java.lang.Long>>globally(Histogram.BucketBounds bucketBounds)Returns aPTransformthat takes aPCollection<T>and returns aPCollection<List<Long>>with a single element per window.static <K,V extends java.lang.Number>
org.apache.beam.sdk.transforms.Combine.PerKey<K,V,java.util.List<java.lang.Long>>perKey(Histogram.BucketBounds bucketBounds)Returns aPTransformthat takes aPCollection<KV<K, V>>and returns aPCollection<KV<K, List<Long>>>that contains an output element mapping each distinct key in the inputPCollectionto aList.
-
-
-
Method Detail
-
globally
public static <T extends java.lang.Number> org.apache.beam.sdk.transforms.Combine.Globally<T,java.util.List<java.lang.Long>> globally(Histogram.BucketBounds bucketBounds)
Returns aPTransformthat takes aPCollection<T>and returns aPCollection<List<Long>>with a single element per window. The values of this list represent the number of elements within each bucket of a histogram, as defined byHistogram.BucketBounds. The first and the last elements of the list are numbers of elements in underflow and overflow buckets.Example of use:
PCollection<Double> pc = ...; PCollection<List<Long>> bucketCounts = pc.apply(Histogram.globally(BucketBounds.linear(1.0, 2.0, 100)));- Type Parameters:
T- the type of the elements in the inputPCollection- Parameters:
bucketBounds- the instance of theHistogram.BucketBoundsclass with desired parameters of the histogram.
-
perKey
public static <K,V extends java.lang.Number> org.apache.beam.sdk.transforms.Combine.PerKey<K,V,java.util.List<java.lang.Long>> perKey(Histogram.BucketBounds bucketBounds)
Returns aPTransformthat takes aPCollection<KV<K, V>>and returns aPCollection<KV<K, List<Long>>>that contains an output element mapping each distinct key in the inputPCollectionto aList. The values of this list represent the number of elements within each bucket of a histogram, as defined byHistogram.BucketBounds. The first and the last elements of the list are numbers of elements in underflow and overflow buckets.Example of use:
PCollection<KV<String, Integer>> pc = ...; PCollection<KV<String, List<Long>>> bucketCounts = pc.apply(Histogram.perKey(BucketBounds.linear(1.0, 2.0, 100)));- Type Parameters:
K- the type of the keys in the input and outputPCollectionsV- the type of the values in the inputPCollection- Parameters:
bucketBounds- the instance of theHistogram.BucketBoundsclass with desired parameters of the histogram.
-
-