This is an automated email from the ASF dual-hosted git repository. echauchot pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push: new 3d8123f [BEAM-6679] Clean up GroupIntoBatches Javadoc new a7abdac Merge pull request #7852 from jklukas/group-into-batches-docs 3d8123f is described below commit 3d8123f5b47c11b2ea60603c5a7fa33b78ed8ee0 Author: Jeff Klukas <j...@klukas.net> AuthorDate: Fri Feb 15 10:02:53 2019 -0500 [BEAM-6679] Clean up GroupIntoBatches Javadoc This modifies the documented code example for GroupIntoBatches to better match the style of examples in other transforms (MapElements, for example). It also applies whitespace to make the example more readable. --- .../beam/sdk/transforms/GroupIntoBatches.java | 31 +++++++++++----------- .../beam/sdk/transforms/GroupIntoBatchesTest.java | 2 +- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/GroupIntoBatches.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/GroupIntoBatches.java index 8c2a11b..dbc54e4 100644 --- a/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/GroupIntoBatches.java +++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/GroupIntoBatches.java @@ -48,25 +48,24 @@ import org.slf4j.LoggerFactory; * are output to the output {@link PCollection}. * * <p>Windows are preserved (batches contain elements from the same window). Batches may contain - * elements from more than one bundle + * elements from more than one bundle. * - * <p>Example (batch call a webservice and get return codes) + * <p>Example (batch call a webservice and get return codes): * * <pre>{@code - * Pipeline pipeline = Pipeline.create(...); - * ... // KV collection - * long batchSize = 100L; - * pipeline.apply(GroupIntoBatches.<String, String>ofSize(batchSize)) - * .setCoder(KvCoder.of(StringUtf8Coder.of(), IterableCoder.of(StringUtf8Coder.of()))) - * .apply(ParDo.of(new DoFn<KV<String, Iterable<String>>, KV<String, String>>() { - * {@literal @}ProcessElement - * public void processElement({@literal @}Element KV<String, Iterable<String>> element, - * OutputReceiver<KV<String, String>> r) { - * r.output(KV.of(element.getKey(), callWebService(element.getValue()))); - * } - * })); - * pipeline.run(); - * }</pre> + * PCollection<KV<String, String>> input = ...; + * long batchSize = 100L; + * PCollection<KV<String, Iterable<String>>> batched = input + * .apply(GroupIntoBatches.<String, String>ofSize(batchSize)) + * .setCoder(KvCoder.of(StringUtf8Coder.of(), IterableCoder.of(StringUtf8Coder.of()))) + * .apply(ParDo.of(new DoFn<KV<String, Iterable<String>>, KV<String, String>>() }{ + * {@code @ProcessElement + * public void processElement(@Element KV<String, Iterable<String>> element, + * OutputReceiver<KV<String, String>> r) { + * r.output(KV.of(element.getKey(), callWebService(element.getValue()))); + * } + * }})); + * </pre> */ public class GroupIntoBatches<K, InputT> extends PTransform<PCollection<KV<K, InputT>>, PCollection<KV<K, Iterable<InputT>>>> { diff --git a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/GroupIntoBatchesTest.java b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/GroupIntoBatchesTest.java index fadb4e2..a54ab0d 100644 --- a/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/GroupIntoBatchesTest.java +++ b/sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/GroupIntoBatchesTest.java @@ -91,7 +91,7 @@ public class GroupIntoBatchesTest implements Serializable { .apply(GroupIntoBatches.ofSize(BATCH_SIZE)) // set output coder .setCoder(KvCoder.of(StringUtf8Coder.of(), IterableCoder.of(StringUtf8Coder.of()))); - PAssert.that("Incorrect batch size in one ore more elements", collection) + PAssert.that("Incorrect batch size in one or more elements", collection) .satisfies( new SerializableFunction<Iterable<KV<String, Iterable<String>>>, Void>() {