/** * Creates an uninitialized instance of {@link Write}. Before use, the {@link Write} must be * configured with a {@link Write#withInstanceId} and {@link Write#withDatabaseId} that identify * the Cloud Spanner database being written. */ @Experimental public static Write write() { return new AutoValue_SpannerIO_Write.Builder() .setSpannerConfig(SpannerConfig.create()) .setBatchSizeBytes(DEFAULT_BATCH_SIZE_BYTES) .setMaxNumMutations(DEFAULT_MAX_NUM_MUTATIONS) .setGroupingFactor(DEFAULT_GROUPING_FACTOR) .setFailureMode(FailureMode.FAIL_FAST) .build(); }
/** * 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. */ public Write withGroupingFactor(int groupingFactor) { return toBuilder().setGroupingFactor(groupingFactor).build(); }
/** Specifies failure mode. {@link FailureMode#FAIL_FAST} mode is selected by default. */ public Write withFailureMode(FailureMode failureMode) { return toBuilder().setFailureMode(failureMode).build(); }
/** * Specifies an optional input PCollection that can be used as the signal for {@link * Wait.OnSignal} to indicate when the database schema is ready to be read. * * <p>To be used when the database schema is created by another section of the pipeline, this * causes this transform to wait until the {@code signal PCollection} has been closed before * reading the schema from the database. * * @see Wait.OnSignal */ public Write withSchemaReadySignal(PCollection signal) { return toBuilder().setSchemaReadySignal(signal).build(); }
/** Specifies the Cloud Spanner configuration. */ public Write withSpannerConfig(SpannerConfig spannerConfig) { return toBuilder().setSpannerConfig(spannerConfig).build(); }
/** * Specifies the batch size limit (max number of bytes mutated per batch). Default value is 1MB */ public Write withBatchSizeBytes(long batchSizeBytes) { return toBuilder().setBatchSizeBytes(batchSizeBytes).build(); }
/** * Specifies the cell mutation limit (maximum number of mutated cells per batch). Default value * is 5000 */ public Write withMaxNumMutations(long maxNumMutations) { return toBuilder().setMaxNumMutations(maxNumMutations).build(); }