Class DatastoreV1.Read
- All Implemented Interfaces:
Serializable,HasDisplayData
- Enclosing class:
DatastoreV1
PTransform that reads the result rows of a Cloud Datastore query as Entity
objects.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAn upper bound on the number of splits for a query.Fields inherited from class org.apache.beam.sdk.transforms.PTransform
annotations, displayData, name, resourceHints -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPCollection<com.google.datastore.v1.Entity> Override this method to specify how thisPTransformshould be expanded on the givenInputT.abstract @Nullable ValueProvider<String> abstract @Nullable ValueProvider<String> abstract @Nullable ValueProvider<String> longgetNumEntities(PipelineOptions options, String ourKind, @Nullable String namespace) Returns Number of entities available for reading.abstract intabstract @Nullable ValueProvider<String> abstract @Nullable com.google.datastore.v1.QuerygetQuery()voidpopulateDisplayData(DisplayData.Builder builder) Register display data for the given transform or component.abstract StringtoString()withDatabaseId(String databaseId) Returns a newDatastoreV1.Readthat reads from the Cloud Datastore for the specified database.withLiteralGqlQuery(String gqlQuery) Returns a newDatastoreV1.Readthat reads the results of the specified GQL query.withLiteralGqlQuery(ValueProvider<String> gqlQuery) Same aswithLiteralGqlQuery(String)but with aValueProvider.withLocalhost(String localhost) Returns a newDatastoreV1.Readthat reads from a Datastore Emulator running at the given localhost address.withNamespace(String namespace) Returns a newDatastoreV1.Readthat reads from the given namespace.withNamespace(ValueProvider<String> namespace) Same aswithNamespace(String)but with aValueProvider.withNumQuerySplits(int numQuerySplits) withProjectId(String projectId) Returns a newDatastoreV1.Readthat reads from the Cloud Datastore for the specified project.withProjectId(ValueProvider<String> projectId) Same aswithProjectId(String)but with aValueProvider.withQuery(com.google.datastore.v1.Query query) Returns a newDatastoreV1.Readthat reads the results of the specified query.withReadTime(Instant readTime) Returns a newDatastoreV1.Readthat reads at the specifiedreadTime.Methods inherited from class org.apache.beam.sdk.transforms.PTransform
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, setDisplayData, setResourceHints, validate, validate
-
Field Details
-
NUM_QUERY_SPLITS_MAX
public static final int NUM_QUERY_SPLITS_MAXAn upper bound on the number of splits for a query.- See Also:
-
-
Constructor Details
-
Read
public Read()
-
-
Method Details
-
getProjectId
-
getDatabaseId
-
getQuery
-
getLiteralGqlQuery
-
getNamespace
-
getNumQuerySplits
public abstract int getNumQuerySplits() -
getLocalhost
-
getReadTime
-
toString
- Overrides:
toStringin classPTransform<PBegin,PCollection<com.google.datastore.v1.Entity>>
-
withDatabaseId
Returns a newDatastoreV1.Readthat reads from the Cloud Datastore for the specified database. -
withProjectId
Returns a newDatastoreV1.Readthat reads from the Cloud Datastore for the specified project. -
withProjectId
Same aswithProjectId(String)but with aValueProvider. -
withQuery
Returns a newDatastoreV1.Readthat reads the results of the specified query.Note: Normally,
DatastoreIOwill read from Cloud Datastore in parallel across many workers. However, when theQueryis configured with a limit usingQuery.Builder.setLimit(com.google.protobuf.Int32Value), then all results will be read by a single worker in order to ensure correct results. -
withLiteralGqlQuery
Returns a newDatastoreV1.Readthat 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.
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. -
withLiteralGqlQuery
Same aswithLiteralGqlQuery(String)but with aValueProvider. -
withNamespace
Returns a newDatastoreV1.Readthat reads from the given namespace. -
withNamespace
Same aswithNamespace(String)but with aValueProvider. -
withNumQuerySplits
Returns a newDatastoreV1.Readthat reads by splitting the givenqueryintonumQuerySplits.The semantics for the query splitting is defined below:
- Any value less than or equal to 0 will be ignored, and the number of splits will be chosen dynamically at runtime based on the query data size.
- Any value greater than
NUM_QUERY_SPLITS_MAXwill be capped atNUM_QUERY_SPLITS_MAX. - If the
queryhas a user limit set, or contains inequality filters, thennumQuerySplitswill be ignored and no split will be performed. - Under certain cases Cloud Datastore is unable to split query to the requested number of splits. In such cases we just use whatever the Cloud Datastore returns.
-
withLocalhost
Returns a newDatastoreV1.Readthat reads from a Datastore Emulator running at the given localhost address. -
withReadTime
Returns a newDatastoreV1.Readthat reads at the specifiedreadTime. -
getNumEntities
Returns Number of entities available for reading. -
expand
Description copied from class:PTransformOverride this method to specify how thisPTransformshould be expanded on the givenInputT.NOTE: This method should not be called directly. Instead apply the
PTransformshould be applied to theInputTusing theapplymethod.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).
- Specified by:
expandin classPTransform<PBegin,PCollection<com.google.datastore.v1.Entity>>
-
populateDisplayData
Description copied from class:PTransformRegister display data for the given transform or component.populateDisplayData(DisplayData.Builder)is invoked by Pipeline runners to collect display data viaDisplayData.from(HasDisplayData). Implementations may callsuper.populateDisplayData(builder)in order to register display data in the current namespace, but should otherwise usesubcomponent.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.
- Specified by:
populateDisplayDatain interfaceHasDisplayData- Overrides:
populateDisplayDatain classPTransform<PBegin,PCollection<com.google.datastore.v1.Entity>> - Parameters:
builder- The builder to populate with display data.- See Also:
-