Skip to content

Commit

Permalink
Add "DoFn Additional Parameters" Java kata
Browse files Browse the repository at this point in the history
  • Loading branch information
henryken committed Jun 16, 2019
1 parent e2f6a5d commit 8e6f5cc
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 0 deletions.
65 changes: 65 additions & 0 deletions learning/katas/java/.idea/study_project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.beam.learning.katas.coretransforms.dofnadditionalparams;

import org.apache.beam.sdk.Pipeline;
import org.apache.beam.sdk.options.PipelineOptions;
import org.apache.beam.sdk.options.PipelineOptionsFactory;

public class Task {

public static void main(String[] args) {
PipelineOptions options = PipelineOptionsFactory.fromArgs(args).create();
Pipeline pipeline = Pipeline.create(options);



pipeline.run();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http:https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<html>
<h2>DoFn Additional Parameters</h2>
<p>
In addition to the element and the OutputReceiver, Beam will populate other parameters to your
DoFn’s @ProcessElement method. Any combination of these parameters can be added to your process
method in any order.
</p>
<div>
<ul>
<li>
<b>Timestamp</b>: To access the timestamp of an input element, add a parameter annotated with
@Timestamp of type Instant
</li>
<li>
<b>Window</b>: To access the window an input element falls into, add a parameter of the type of the
window used for the input PCollection.
</li>
<li>
<b>PaneInfo</b>: When triggers are used, Beam provides a PaneInfo object that contains information
about the current firing. Using PaneInfo you can determine whether this is an early or a
late firing, and how many times this window has already fired for this key.
</li>
<li>
<b>PipelineOptions</b>: The PipelineOptions for the current pipeline can always be accessed in a
process method by adding it as a parameter.
</li>
</ul>
</div>
<p>
Refer to the Beam Programming Guide
<a href="https://beam.apache.org/documentation/programming-guide/#other-dofn-parameters">
"Accessing additional parameters in your DoFn"</a> section for more information.
</p>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.beam.learning.katas.coretransforms.dofnadditionalparams;

public class TaskTest {
}

0 comments on commit 8e6f5cc

Please sign in to comment.