public class DatastoreWordCount extends 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 use gcloud to get credential for 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=YOUR_PROJECT_ID
--dataset=YOUR_DATASET_ID
--output=[YOUR_LOCAL_FILE | gs://YOUR_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(String[] args)
Main function.
|
static void |
readDataFromDatastore(DatastoreWordCount.Options options)
An example that creates a pipeline to do DatastoreIO.Read from Datastore.
|
static void |
writeDataToDatastore(DatastoreWordCount.Options options)
An example that 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(String[] args)