Class SpannerIO.Write
- All Implemented Interfaces:
Serializable
,HasDisplayData
- Enclosing class:
SpannerIO
PTransform
that writes Mutation
objects to Google Cloud Spanner.- See Also:
-
Field Summary
Fields inherited from class org.apache.beam.sdk.transforms.PTransform
annotations, displayData, name, resourceHints
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexpand
(PCollection<Mutation> input) Override this method to specify how thisPTransform
should be expanded on the givenInputT
.grouped()
Same transform but can be applied toPCollection
ofMutationGroup
.void
populateDisplayData
(DisplayData.Builder builder) Register display data for the given transform or component.withBatchSizeBytes
(long batchSizeBytes) Specifies the batch size limit (max number of bytes mutated per batch).withCommitDeadline
(Duration commitDeadline) Specifies the deadline for the Commit API call.withDatabaseId
(String databaseId) Specifies the Cloud Spanner database.withDatabaseId
(ValueProvider<String> databaseId) Specifies the Cloud Spanner database.withDialectView
(PCollectionView<Dialect> dialect) withEmulatorHost
(String emulatorHost) withEmulatorHost
(ValueProvider<String> emulatorHost) Specifies the Cloud Spanner emulator host.withFailureMode
(SpannerIO.FailureMode failureMode) Specifies failure mode.withGroupingFactor
(int groupingFactor) Specifies the multiple of max mutation (in terms of both bytes per batch and cells per batch) that is used to select a set of mutations to sort by key for batching.Specifies the Cloud Spanner host.withHost
(ValueProvider<String> host) Specifies the Cloud Spanner host.withInstanceId
(String instanceId) Specifies the Cloud Spanner instance.withInstanceId
(ValueProvider<String> instanceId) Specifies the Cloud Spanner instance.withMaxCommitDelay
(long millis) Specifies max commit delay for the Commit API call for throughput optimized writes.withMaxCumulativeBackoff
(Duration maxCumulativeBackoff) Specifies the maximum cumulative backoff time when retrying after DEADLINE_EXCEEDED errors.withMaxNumMutations
(long maxNumMutations) Specifies the cell mutation limit (maximum number of mutated cells per batch).withMaxNumRows
(long maxNumRows) Specifies the row mutation limit (maximum number of mutated rows per batch).withProjectId
(String projectId) Specifies the Cloud Spanner project.withProjectId
(ValueProvider<String> projectId) Specifies the Cloud Spanner project.withSchemaReadySignal
(PCollection<?> signal) Specifies an optional input PCollection that can be used as the signal forWait.OnSignal
to indicate when the database schema is ready to be read.withSpannerConfig
(SpannerConfig spannerConfig) Specifies the Cloud Spanner configuration.Methods inherited from class org.apache.beam.sdk.transforms.PTransform
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, setDisplayData, setResourceHints, toString, validate, validate
-
Constructor Details
-
Write
public Write()
-
-
Method Details
-
withSpannerConfig
Specifies the Cloud Spanner configuration. -
withProjectId
Specifies the Cloud Spanner project. -
withProjectId
Specifies the Cloud Spanner project. -
withInstanceId
Specifies the Cloud Spanner instance. -
withInstanceId
Specifies the Cloud Spanner instance. -
withDatabaseId
Specifies the Cloud Spanner database. -
withDatabaseId
Specifies the Cloud Spanner database. -
withHost
Specifies the Cloud Spanner host. -
withHost
Specifies the Cloud Spanner host. -
withEmulatorHost
Specifies the Cloud Spanner emulator host. -
withEmulatorHost
-
withDialectView
-
withCommitDeadline
Specifies the deadline for the Commit API call. Default is 15 secs. DEADLINE_EXCEEDED errors will prompt a backoff/retry until the value ofwithMaxCumulativeBackoff(Duration)
is reached. DEADLINE_EXCEEDED errors are reported with logging and counters. -
withMaxCommitDelay
Specifies max commit delay for the Commit API call for throughput optimized writes. If not set, Spanner might set a small delay if it thinks that will amortize the cost of the writes. For more information about the feature, see documentation -
withMaxCumulativeBackoff
Specifies the maximum cumulative backoff time when retrying after DEADLINE_EXCEEDED errors. Default is 15 mins.If the mutations still have not been written after this time, they are treated as a failure, and handled according to the setting of
withFailureMode(FailureMode)
. -
grouped
Same transform but can be applied toPCollection
ofMutationGroup
. -
withBatchSizeBytes
Specifies the batch size limit (max number of bytes mutated per batch). Default value is 1MB -
withFailureMode
Specifies failure mode.SpannerIO.FailureMode.FAIL_FAST
mode is selected by default. -
withMaxNumMutations
Specifies the cell mutation limit (maximum number of mutated cells per batch). Default value is 5000 -
withMaxNumRows
Specifies the row mutation limit (maximum number of mutated rows per batch). Default value is 1000 -
withSchemaReadySignal
Specifies an optional input PCollection that can be used as the signal forWait.OnSignal
to indicate when the database schema is ready to be read.To be used when the database schema is created by another section of the pipeline, this causes this transform to wait until the
signal PCollection
has been closed before reading the schema from the database.- See Also:
-
withGroupingFactor
Specifies the multiple of max mutation (in terms of both bytes per batch and cells per batch) that is used to select a set of mutations to sort by key for batching. This sort uses local memory on the workers, so using large values can cause out of memory errors. Default value is 1000. -
withLowPriority
-
withHighPriority
-
expand
Description copied from class:PTransform
Override this method to specify how thisPTransform
should be expanded on the givenInputT
.NOTE: This method should not be called directly. Instead apply the
PTransform
should be applied to theInputT
using theapply
method.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:
expand
in classPTransform<PCollection<Mutation>,
SpannerWriteResult>
-
populateDisplayData
Description copied from class:PTransform
Register 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:
populateDisplayData
in interfaceHasDisplayData
- Overrides:
populateDisplayData
in classPTransform<PCollection<Mutation>,
SpannerWriteResult> - Parameters:
builder
- The builder to populate with display data.- See Also:
-