Github user thvasilo commented on a diff in the pull request:
https://github.com/apache/flink/pull/949#discussion_r36950634
--- Diff:
flink-scala/src/main/scala/org/apache/flink/api/scala/DataSet.scala ---
@@ -1182,6 +1184,60 @@ class DataSet[T: ClassTag](set: JavaDataSet[T]) {
getCallLocationName()))
//
--------------------------------------------------------------------------------------------
+ // Sample
+ //
--------------------------------------------------------------------------------------------
+ /**
+ * Generate a sample of DataSet by the probability fraction of each
element.
+ *
+ * @param withReplacement Whether element can be selected more than once.
+ * @param fraction Probability that each element is chosen,
should be [0,1] without
+ * replacement, and [0, â) with replacement.
While fraction is larger
+ * than 1, the elements are expected to be
selected multi times into
+ * sample on average.
+ * @param seed Random number generator seed.
+ * @return The sampled DataSet
+ */
+ def sample(
+ withReplacement: Boolean,
+ fraction: Double,
+ seed: Long = Utils.RNG.nextLong()): DataSet[T] = {
+
+ wrap(new MapPartitionOperator[T, T](javaSet,
+ getType(),
+ new SampleWithFraction(withReplacement, fraction, seed),
+ getCallLocationName()))
+ }
+
+ /**
+ * Generate a sample of DataSet by the probability fraction of each
element.
--- End diff --
Javadoc is from the fraction function.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---