beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From al...@apache.org
Subject [2/3] beam-site git commit: Regenerate website
Date Sat, 29 Apr 2017 00:39:49 GMT
Regenerate website


Project: http://git-wip-us.apache.org/repos/asf/beam-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam-site/commit/1b931625
Tree: http://git-wip-us.apache.org/repos/asf/beam-site/tree/1b931625
Diff: http://git-wip-us.apache.org/repos/asf/beam-site/diff/1b931625

Branch: refs/heads/asf-site
Commit: 1b931625fc692dd81ead8ab4ce8e315d96d5dea6
Parents: faa12ff
Author: Ahmet Altay <altay@altay-macbookpro2.roam.corp.google.com>
Authored: Fri Apr 28 17:39:13 2017 -0700
Committer: Ahmet Altay <altay@altay-macbookpro2.roam.corp.google.com>
Committed: Fri Apr 28 17:39:13 2017 -0700

----------------------------------------------------------------------
 content/documentation/programming-guide/index.html | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam-site/blob/1b931625/content/documentation/programming-guide/index.html
----------------------------------------------------------------------
diff --git a/content/documentation/programming-guide/index.html b/content/documentation/programming-guide/index.html
index 439d48b..b57f89c 100644
--- a/content/documentation/programming-guide/index.html
+++ b/content/documentation/programming-guide/index.html
@@ -774,6 +774,19 @@ guest, [[], [order4]]
 </div>
 
 <div class="language-py highlighter-rouge"><pre class="highlight"><code><span
class="n">pc</span> <span class="o">=</span> <span class="o">...</span>
+<span class="k">class</span> <span class="nc">AverageFn</span><span
class="p">(</span><span class="n">beam</span><span class="o">.</span><span
class="n">CombineFn</span><span class="p">):</span>
+  <span class="k">def</span> <span class="nf">create_accumulator</span><span
class="p">(</span><span class="bp">self</span><span class="p">):</span>
+    <span class="k">return</span> <span class="p">(</span><span
class="mf">0.0</span><span class="p">,</span> <span class="mi">0</span><span
class="p">)</span>
+
+  <span class="k">def</span> <span class="nf">add_input</span><span
class="p">(</span><span class="bp">self</span><span class="p">,</span>
<span class="p">(</span><span class="nb">sum</span><span class="p">,</span>
<span class="n">count</span><span class="p">),</span> <span class="nb">input</span><span
class="p">):</span>
+    <span class="k">return</span> <span class="nb">sum</span> <span
class="o">+</span> <span class="nb">input</span><span class="p">,</span>
<span class="n">count</span> <span class="o">+</span> <span class="mi">1</span>
+
+  <span class="k">def</span> <span class="nf">merge_accumulators</span><span
class="p">(</span><span class="bp">self</span><span class="p">,</span>
<span class="n">accumulators</span><span class="p">):</span>
+    <span class="n">sums</span><span class="p">,</span> <span
class="n">counts</span> <span class="o">=</span> <span class="nb">zip</span><span
class="p">(</span><span class="o">*</span><span class="n">accumulators</span><span
class="p">)</span>
+    <span class="k">return</span> <span class="nb">sum</span><span
class="p">(</span><span class="n">sums</span><span class="p">),</span>
<span class="nb">sum</span><span class="p">(</span><span class="n">counts</span><span
class="p">)</span>
+
+  <span class="k">def</span> <span class="nf">extract_output</span><span
class="p">(</span><span class="bp">self</span><span class="p">,</span>
<span class="p">(</span><span class="nb">sum</span><span class="p">,</span>
<span class="n">count</span><span class="p">)):</span>
+    <span class="k">return</span> <span class="nb">sum</span> <span
class="o">/</span> <span class="n">count</span> <span class="k">if</span>
<span class="n">count</span> <span class="k">else</span> <span
class="nb">float</span><span class="p">(</span><span class="s">'NaN'</span><span
class="p">)</span>
 </code></pre>
 </div>
 
@@ -794,6 +807,7 @@ guest, [[], [order4]]
 <div class="language-py highlighter-rouge"><pre class="highlight"><code><span
class="c"># sum combines the elements in the input PCollection.</span>
 <span class="c"># The resulting PCollection, called result, contains one value: the
sum of all the elements in the input PCollection.</span>
 <span class="n">pc</span> <span class="o">=</span> <span class="o">...</span>
+<span class="n">average</span> <span class="o">=</span> <span
class="n">pc</span> <span class="o">|</span> <span class="n">beam</span><span
class="o">.</span><span class="n">CombineGlobally</span><span class="p">(</span><span
class="n">AverageFn</span><span class="p">())</span>
 </code></pre>
 </div>
 
@@ -927,6 +941,7 @@ guest, [[], [order4]]
 
 <div class="language-py highlighter-rouge"><pre class="highlight"><code><span
class="c"># Provide an int value with the desired number of result partitions, and a partitioning
function (partition_fn in this example).</span>
 <span class="c"># Returns a tuple of PCollection objects containing each of the resulting
partitions as individual PCollection objects.</span>
+<span class="n">students</span> <span class="o">=</span> <span
class="o">...</span>
 <span class="k">def</span> <span class="nf">partition_fn</span><span
class="p">(</span><span class="n">student</span><span class="p">,</span>
<span class="n">num_partitions</span><span class="p">):</span>
   <span class="k">return</span> <span class="nb">int</span><span
class="p">(</span><span class="n">get_percentile</span><span class="p">(</span><span
class="n">student</span><span class="p">)</span> <span class="o">*</span>
<span class="n">num_partitions</span> <span class="o">/</span> <span
class="mi">100</span><span class="p">)</span>
 
@@ -1019,7 +1034,7 @@ guest, [[], [order4]]
 <span class="c"># Optional, positional, and keyword arguments are all supported. Deferred
arguments are unwrapped into their actual values.</span>
 <span class="c"># For example, using pvalue.AsIter(pcoll) at pipeline construction
time results in an iterable of the actual elements of pcoll being passed into each process
invocation.</span>
 <span class="c"># In this example, side inputs are passed to a FlatMap transform as
extra arguments and consumed by filter_using_length.</span>
-
+<span class="n">words</span> <span class="o">=</span> <span class="o">...</span>
 <span class="c"># Callable takes additional arguments.</span>
 <span class="k">def</span> <span class="nf">filter_using_length</span><span
class="p">(</span><span class="n">word</span><span class="p">,</span>
<span class="n">lower_bound</span><span class="p">,</span> <span
class="n">upper_bound</span><span class="o">=</span><span class="nb">float</span><span
class="p">(</span><span class="s">'inf'</span><span class="p">)):</span>
   <span class="k">if</span> <span class="n">lower_bound</span> <span
class="o">&lt;=</span> <span class="nb">len</span><span class="p">(</span><span
class="n">word</span><span class="p">)</span> <span class="o">&lt;=</span>
<span class="n">upper_bound</span><span class="p">:</span>


Mime
View raw message