You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by al...@apache.org on 2020/07/27 22:21:33 UTC

[beam] branch master updated: [BEAM-7390] Add groupintobatches code snippets

This is an automated email from the ASF dual-hosted git repository.

altay 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 8930694  [BEAM-7390] Add groupintobatches code snippets
     new d252745  Merge pull request #12377 from davidcavazos/groupintobatches-docs
8930694 is described below

commit 89306946df3bb46f9643c137ea587fbc40381463
Author: David Cavazos <dc...@google.com>
AuthorDate: Mon Jul 27 08:53:46 2020 -0700

    [BEAM-7390] Add groupintobatches code snippets
---
 .../python/aggregation/groupintobatches.md         | 32 ++++++++++++++++++++--
 .../en/documentation/transforms/python/overview.md |  2 +-
 .../partials/section-menu/en/documentation.html    |  1 +
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/website/www/site/content/en/documentation/transforms/python/aggregation/groupintobatches.md b/website/www/site/content/en/documentation/transforms/python/aggregation/groupintobatches.md
index c13c369..1058249 100644
--- a/website/www/site/content/en/documentation/transforms/python/aggregation/groupintobatches.md
+++ b/website/www/site/content/en/documentation/transforms/python/aggregation/groupintobatches.md
@@ -17,7 +17,35 @@ limitations under the License.
 
 # GroupIntoBatches
 
+{{< localstorage language language-py >}}
+
+{{< button-pydoc path="apache_beam.transforms.util" class="GroupIntoBatches" >}}
+
+Batches the input into desired batch size.
+
 ## Examples
-See [BEAM-7390](https://issues.apache.org/jira/browse/BEAM-7390) for updates. 
 
-## Related transforms
\ No newline at end of file
+In the following example, we create a pipeline with a `PCollection` of produce by season.
+
+We use `GroupIntoBatches` to get fixed-sized batches for every key, which outputs a list of elements for every key.
+
+{{< highlight py >}}
+{{< code_sample "sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches.py" groupintobatches >}}
+{{< /highlight >}}
+
+{{< paragraph class="notebook-skip" >}}
+Output:
+{{< /paragraph >}}
+
+{{< highlight class="notebook-skip" >}}
+{{< code_sample "sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches_test.py" batches_with_keys >}}
+{{< /highlight >}}
+
+{{< buttons-code-snippet
+  py="sdks/python/apache_beam/examples/snippets/transforms/aggregation/groupintobatches.py" >}}
+
+## Related transforms
+
+N/A
+
+{{< button-pydoc path="apache_beam.transforms.util" class="GroupIntoBatches" >}}
diff --git a/website/www/site/content/en/documentation/transforms/python/overview.md b/website/www/site/content/en/documentation/transforms/python/overview.md
index ac815b6..71ed708 100644
--- a/website/www/site/content/en/documentation/transforms/python/overview.md
+++ b/website/www/site/content/en/documentation/transforms/python/overview.md
@@ -54,7 +54,7 @@ limitations under the License.
   <tr><td><a href="/documentation/transforms/python/aggregation/count">Count</a></td><td>Counts the number of elements within each aggregation.</td></tr>
   <tr><td><a href="/documentation/transforms/python/aggregation/distinct">Distinct</a></td><td>Produces a collection containing distinct elements from the input collection.</td></tr>  
   <tr><td><a href="/documentation/transforms/python/aggregation/groupbykey">GroupByKey</a></td><td>Takes a keyed collection of elements and produces a collection where each element consists of a key and all values associated with that key.</td></tr>
-  <tr><td>GroupIntoBatches</td><td>Not available. See <a href="https://issues.apache.org/jira/browse/BEAM-6696">BEAM-6696</a> for updates.</td></tr>
+  <tr><td><a href="/documentation/transforms/python/aggregation/groupintobatches">GroupIntoBatches</a></td><td>Batches the input into desired batch size.</td></tr>
   <tr><td>Latest</td><td>Not available. See <a href="https://issues.apache.org/jira/browse/BEAM-6695">BEAM-6695</a> for updates.</td></tr>
   <tr><td>Max</td><td>Not available.</td></tr>  
   <tr><td><a href="/documentation/transforms/python/aggregation/mean">Mean</a></td><td>Computes the average within each aggregation.</td></tr>
diff --git a/website/www/site/layouts/partials/section-menu/en/documentation.html b/website/www/site/layouts/partials/section-menu/en/documentation.html
index 223a590..db3b522 100644
--- a/website/www/site/layouts/partials/section-menu/en/documentation.html
+++ b/website/www/site/layouts/partials/section-menu/en/documentation.html
@@ -198,6 +198,7 @@
           <li><a href="/documentation/transforms/python/aggregation/count/">Count</a></li>
           <li><a href="/documentation/transforms/python/aggregation/distinct/">Distinct</a></li>
           <li><a href="/documentation/transforms/python/aggregation/groupbykey/">GroupByKey</a></li>
+          <li><a href="/documentation/transforms/python/aggregation/groupintobatches/">GroupIntoBatches</a></li>
           <li><a href="/documentation/transforms/python/aggregation/mean/">Mean</a></li>
           <li><a href="/documentation/transforms/python/aggregation/sample/">Sample</a></li>
           <li><a href="/documentation/transforms/python/aggregation/top/">Top</a></li>