public abstract static class DatastoreV1.Read extends PTransform<PBegin,PCollection<com.google.datastore.v1.Entity>>
PTransform
that reads the result rows of a Cloud Datastore query as Entity
objects.DatastoreIO
,
Serialized FormModifier and Type | Field and Description |
---|---|
static int |
NUM_QUERY_SPLITS_MAX
An upper bound on the number of splits for a query.
|
name
Constructor and Description |
---|
Read() |
Modifier and Type | Method and Description |
---|---|
PCollection<com.google.datastore.v1.Entity> |
expand(PBegin input)
Applies this
PTransform on the given InputT , and returns its
Output . |
abstract ValueProvider<java.lang.String> |
getLiteralGqlQuery() |
abstract java.lang.String |
getLocalhost() |
abstract ValueProvider<java.lang.String> |
getNamespace() |
abstract int |
getNumQuerySplits() |
abstract ValueProvider<java.lang.String> |
getProjectId() |
abstract com.google.datastore.v1.Query |
getQuery() |
void |
populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.
|
abstract java.lang.String |
toString() |
void |
validate(PipelineOptions options)
Called before running the Pipeline to verify this transform is fully and correctly
specified.
|
DatastoreV1.Read |
withLiteralGqlQuery(java.lang.String gqlQuery)
Returns a new
DatastoreV1.Read that reads the results of the specified GQL query. |
DatastoreV1.Read |
withLiteralGqlQuery(ValueProvider<java.lang.String> gqlQuery)
Same as
withLiteralGqlQuery(String) but with a ValueProvider . |
DatastoreV1.Read |
withLocalhost(java.lang.String localhost)
Returns a new
DatastoreV1.Read that reads from a Datastore Emulator running at the
given localhost address. |
DatastoreV1.Read |
withNamespace(java.lang.String namespace)
Returns a new
DatastoreV1.Read that reads from the given namespace. |
DatastoreV1.Read |
withNamespace(ValueProvider<java.lang.String> namespace)
Same as
withNamespace(String) but with a ValueProvider . |
DatastoreV1.Read |
withNumQuerySplits(int numQuerySplits)
|
DatastoreV1.Read |
withProjectId(java.lang.String projectId)
Returns a new
DatastoreV1.Read that reads from the Cloud Datastore for the specified
project. |
DatastoreV1.Read |
withProjectId(ValueProvider<java.lang.String> projectId)
Same as
withProjectId(String) but with a ValueProvider . |
DatastoreV1.Read |
withQuery(com.google.datastore.v1.Query query)
Returns a new
DatastoreV1.Read that reads the results of the specified query. |
getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName
public static final int NUM_QUERY_SPLITS_MAX
@Nullable public abstract ValueProvider<java.lang.String> getProjectId()
@Nullable public abstract com.google.datastore.v1.Query getQuery()
@Nullable public abstract ValueProvider<java.lang.String> getLiteralGqlQuery()
@Nullable public abstract ValueProvider<java.lang.String> getNamespace()
public abstract int getNumQuerySplits()
@Nullable public abstract java.lang.String getLocalhost()
public abstract java.lang.String toString()
toString
in class PTransform<PBegin,PCollection<com.google.datastore.v1.Entity>>
public DatastoreV1.Read withProjectId(java.lang.String projectId)
DatastoreV1.Read
that reads from the Cloud Datastore for the specified
project.public DatastoreV1.Read withProjectId(ValueProvider<java.lang.String> projectId)
withProjectId(String)
but with a ValueProvider
.public DatastoreV1.Read withQuery(com.google.datastore.v1.Query query)
DatastoreV1.Read
that reads the results of the specified query.
Note: Normally, DatastoreIO
will read from Cloud Datastore in parallel
across many workers. However, when the Query
is configured with a limit using
Query.Builder#setLimit
, then all results will be read by a single worker in order
to ensure correct results.
@Experimental(value=SOURCE_SINK) public DatastoreV1.Read withLiteralGqlQuery(java.lang.String gqlQuery)
DatastoreV1.Read
that reads the results of the specified GQL query.
See GQL Reference
to know more about GQL grammar.
Note: This query is executed with literals allowed, so the users should ensure that the query is originated from trusted sources to avoid any security vulnerabilities via SQL Injection.
Experimental: Cloud Datastore does not a provide a clean way to translate
a gql query string to Query
, so we end up making a query to the service for
translation but this may read the actual data, although it will be a small amount.
It needs more validation through production use cases before marking it as stable.
@Experimental(value=SOURCE_SINK) public DatastoreV1.Read withLiteralGqlQuery(ValueProvider<java.lang.String> gqlQuery)
withLiteralGqlQuery(String)
but with a ValueProvider
.public DatastoreV1.Read withNamespace(java.lang.String namespace)
DatastoreV1.Read
that reads from the given namespace.public DatastoreV1.Read withNamespace(ValueProvider<java.lang.String> namespace)
withNamespace(String)
but with a ValueProvider
.public DatastoreV1.Read withNumQuerySplits(int numQuerySplits)
DatastoreV1.Read
that reads by splitting the given query
into
numQuerySplits
.
The semantics for the query splitting is defined below:
NUM_QUERY_SPLITS_MAX
will be capped at
NUM_QUERY_SPLITS_MAX
.
query
has a user limit set, then numQuerySplits
will be
ignored and no split will be performed.
public DatastoreV1.Read withLocalhost(java.lang.String localhost)
DatastoreV1.Read
that reads from a Datastore Emulator running at the
given localhost address.public PCollection<com.google.datastore.v1.Entity> expand(PBegin input)
PTransform
PTransform
on the given InputT
, and returns its
Output
.
Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
expand
in class PTransform<PBegin,PCollection<com.google.datastore.v1.Entity>>
public void validate(PipelineOptions options)
PTransform
By default, does nothing.
validate
in class PTransform<PBegin,PCollection<com.google.datastore.v1.Entity>>
public void populateDisplayData(DisplayData.Builder builder)
PTransform
populateDisplayData(DisplayData.Builder)
is invoked by Pipeline runners to collect
display data via DisplayData.from(HasDisplayData)
. Implementations may call
super.populateDisplayData(builder)
in order to register display data in the current
namespace, but should otherwise use subcomponent.populateDisplayData(builder)
to use
the namespace of the subcomponent.
By default, does not register any display data. Implementors may override this method to provide their own display data.
populateDisplayData
in interface HasDisplayData
populateDisplayData
in class PTransform<PBegin,PCollection<com.google.datastore.v1.Entity>>
builder
- The builder to populate with display data.HasDisplayData