Class SampleWithFraction<T>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    Serializable, org.apache.flink.api.common.functions.Function, org.apache.flink.api.common.functions.MapPartitionFunction<T,​T>, org.apache.flink.api.common.functions.RichFunction

    @Internal
    public class SampleWithFraction<T>
    extends org.apache.flink.api.common.functions.RichMapPartitionFunction<T,​T>
    A map partition function wrapper for sampling algorithms with fraction, the sample algorithm takes the partition iterator as input.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      SampleWithFraction​(boolean withReplacement, double fraction, long seed)
      Create a function instance of SampleWithFraction.
    • Constructor Detail

      • SampleWithFraction

        public SampleWithFraction​(boolean withReplacement,
                                  double fraction,
                                  long seed)
        Create a function instance of SampleWithFraction.
        Parameters:
        withReplacement - Whether element can be selected more than once.
        fraction - Probability that each element is selected.
        seed - random number generator seed.
    • Method Detail

      • mapPartition

        public void mapPartition​(Iterable<T> values,
                                 org.apache.flink.util.Collector<T> out)
                          throws Exception
        Specified by:
        mapPartition in interface org.apache.flink.api.common.functions.MapPartitionFunction<T,​T>
        Specified by:
        mapPartition in class org.apache.flink.api.common.functions.RichMapPartitionFunction<T,​T>
        Throws:
        Exception