
# "Cookbook" Examples

This directory holds simple "cookbook" examples, which show how to define
commonly-used data analysis patterns that you would likely incorporate into a
larger Dataflow pipeline. They include:

- BigQueryTornadoes (https://github.com/GoogleCloudPlatform/DataflowJavaSDK/blob/master/examples/src/main/java/com/google/cloud/dataflow/examples/cookbook/BigQueryTornadoes.java)
  — An example that reads the public samples of weather data from Google
  BigQuery, counts the number of tornadoes that occur in each month, and
  writes the results to BigQuery. Demonstrates reading/writing BigQuery,
  counting a PCollection, and user-defined PTransforms.
  
- CombinePerKeyExamples (https://github.com/GoogleCloudPlatform/DataflowJavaSDK/blob/master/examples/src/main/java/com/google/cloud/dataflow/examples/cookbook/CombinePerKeyExamples.java)
  — An example that reads the public "Shakespeare" data, and for
  each word in the dataset that exceeds a given length, generates a string
  containing the list of play names in which that word appears.
  Demonstrates the Combine.perKey
  transform, which lets you combine the values in a key-grouped
  PCollection.

- DatastoreWordCount (https://github.com/GoogleCloudPlatform/DataflowJavaSDK/blob/master/examples/src/main/java/com/google/cloud/dataflow/examples/cookbook/DatastoreWordCount.java)
  — An example that shows you how to read from Google Cloud Datastore.
  
- DeDupExample (https://github.com/GoogleCloudPlatform/DataflowJavaSDK/blob/master/examples/src/main/java/com/google/cloud/dataflow/examples/cookbook/DeDupExample.java)
  — An example that uses Shakespeare's plays as plain text files, and
  removes duplicate lines across all the files. Demonstrates the
  RemoveDuplicates, TextIO.Read,
  and TextIO.Write transforms, and how to wire transforms together.

- FilterExamples (https://github.com/GoogleCloudPlatform/DataflowJavaSDK/blob/master/examples/src/main/java/com/google/cloud/dataflow/examples/cookbook/FilterExamples.java)
  — An example that shows different approaches to filtering, including
  selection and projection. It also shows how to dynamically set parameters
  by defining and using new pipeline options, and use how to use a value derived
  by a pipeline. Demonstrates the Mean transform,
  Options configuration, and using pipeline-derived data as a side
  input.

- JoinExamples (https://github.com/GoogleCloudPlatform/DataflowJavaSDK/blob/master/examples/src/main/java/com/google/cloud/dataflow/examples/cookbook/JoinExamples.java)
  — An example that shows how to join two collections. It uses a
  sample of the GDELT "world event"
  data (http://goo.gl/OB6oin), joining the event action country code against a table
  that maps country codes to country names. Demonstrates the Join
  operation, and using multiple input sources.

- MaxPerKeyExamples (https://github.com/GoogleCloudPlatform/DataflowJavaSDK/blob/master/examples/src/main/java/com/google/cloud/dataflow/examples/cookbook/MaxPerKeyExamples.java)
  — An example that reads the public samples of weather data from BigQuery,
  and finds the maximum temperature (mean_temp) for each month.
  Demonstrates the Max statistical combination transform, and how to
  find the max-per-key group.

See the [documentation](https://cloud.google.com/dataflow/getting-started) and the [Examples
README](../../../../../../../../../README.md) for
information about how to run these examples.
