public class DatastoreWordCount
extends java.lang.Object
This example shows how to use DatastoreIO to read from Datastore and write the results to Cloud Storage. Note that this example will write data to Datastore, which may incur charge for Datastore operations.
To run this example, users need to set up the environment and use gcloud to get credential for Datastore:
$ export CLOUDSDK_EXTRA_SCOPES=https://www.googleapis.com/auth/datastore $ gcloud auth login
Note that the environment variable CLOUDSDK_EXTRA_SCOPES must be set to the same value when executing a Datastore pipeline, as the local auth cache is keyed by the requested scopes.
To run this pipeline locally, the following options must be provided:
--project=<PROJECT ID>
--dataset=<DATASET ID>
--output=[<LOCAL FILE> | gs://<OUTPUT PATH>]
To run this example using Dataflow service, you must additionally provide either --stagingLocation or --tempLocation, and select one of the Dataflow pipeline runners, eg --runner=BlockingDataflowPipelineRunner.
| Modifier and Type | Class and Description |
|---|---|
static interface |
DatastoreWordCount.Options
Options supported by
DatastoreWordCount. |
| Constructor and Description |
|---|
DatastoreWordCount() |
| Modifier and Type | Method and Description |
|---|---|
static void |
main(java.lang.String[] args)
Main function.
|
static void |
readDataFromDatastore(DatastoreWordCount.Options options)
An example which creates a pipeline to do DatastoreIO.Read from Datastore.
|
static void |
writeDataToDatastore(DatastoreWordCount.Options options)
An example which creates a pipeline to populate DatastoreIO from a
text input.
|
public static void writeDataToDatastore(DatastoreWordCount.Options options)
public static void readDataFromDatastore(DatastoreWordCount.Options options)
public static void main(java.lang.String[] args)