igorbernstein2 commented on code in PR #24015:
URL: https://github.com/apache/beam/pull/24015#discussion_r1112286695
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java:
##########
@@ -764,35 +894,119 @@ public Write withoutValidation() {
}
/**
- * Returns a new {@link BigtableIO.Write} that will write using the given
Cloud Bigtable service
- * implementation.
+ * Returns a new {@link BigtableIO.Write} that will use an official
Bigtable emulator.
*
* <p>This is used for testing.
+ */
+ @VisibleForTesting
+ public Write withEmulator(String emulatorHost) {
+ BigtableConfig config = getBigtableConfig();
+ return
toBuilder().setBigtableConfig(config.withEmulator(emulatorHost)).build();
+ }
+
+ /**
+ * Returns a new {@link BigtableIO.Write} with the attempt timeout in
milliseconds for writes.
*
* <p>Does not modify this object.
*/
- Write withBigtableService(BigtableService bigtableService) {
- BigtableConfig config = getBigtableConfig();
- return
toBuilder().setBigtableConfig(config.withBigtableService(bigtableService)).build();
+ public Write withAttemptTimeout(long timeoutMs) {
+ checkArgument(timeoutMs > 0, "attempt timeout must be positive");
+ BigtableWriteOptions options = getBigtableWriteOptions();
+ return toBuilder()
+
.setBigtableWriteOptions(options.toBuilder().setAttemptTimeout(timeoutMs).build())
+ .build();
}
/**
- * Returns a new {@link BigtableIO.Write} that will use an official
Bigtable emulator.
+ * Returns a new {@link BigtableIO.Write} with the operation timeout in
milliseconds for writes.
*
- * <p>This is used for testing.
+ * <p>Does not modify this object.
+ */
+ public Write withOperationTimeout(long timeoutMs) {
+ checkArgument(timeoutMs > 0, "operation timeout must be positive");
+ BigtableWriteOptions options = getBigtableWriteOptions();
+ return toBuilder()
+
.setBigtableWriteOptions(options.toBuilder().setOperationTimeout(timeoutMs).build())
+ .build();
+ }
+
+ /**
+ * Returns a new {@link BigtableIO.Write} with the retry delay in
milliseconds.
+ *
+ * <p>Does not modify this object.
+ */
+ public Write withRetryInitialDelay(long delayMs) {
+ checkArgument(delayMs > 0, "delay must be positive");
+ BigtableWriteOptions options = getBigtableWriteOptions();
+ return toBuilder()
+
.setBigtableWriteOptions(options.toBuilder().setRetryInitialDelay(delayMs).build())
+ .build();
+ }
+
+ /**
+ * Returns a new {@link BigtableIO.Write} with retry multiplier.
+ *
+ * <p>Does not modify this object.
+ */
+ public Write withRetryDelayMultiplier(double multiplier) {
+ checkArgument(multiplier > 0, "multiplier must be positive");
+ BigtableWriteOptions options = getBigtableWriteOptions();
+ return toBuilder()
+
.setBigtableWriteOptions(options.toBuilder().setRetryDelayMultiplier(multiplier).build())
+ .build();
+ }
+
+ /**
+ * Returns a new {@link BigtableIO.Write} with the number of elements in a
batch.
+ *
+ * <p>Does not modify this object.
+ */
+ public Write withBatchElements(long size) {
+ checkArgument(size > 0, "batch element size must be positive");
+ BigtableWriteOptions options = getBigtableWriteOptions();
+ return toBuilder()
+
.setBigtableWriteOptions(options.toBuilder().setBatchElements(size).build())
+ .build();
+ }
+
+ /**
+ * Returns a new {@link BigtableIO.Write} with the number of bytes in a
batch.
+ *
+ * <p>Does not modify this object.
+ */
+ public Write withBatchBytes(long size) {
+ checkArgument(size > 0, "batch byte size must be positive");
+ BigtableWriteOptions options = getBigtableWriteOptions();
+ return toBuilder()
+
.setBigtableWriteOptions(options.toBuilder().setBatchBytes(size).build())
+ .build();
+ }
+
+ /**
+ * Returns a new {@link BigtableIO.Write} with the max number of
concurrent requests.
+ *
+ * <p>Does not modify this object.
*/
+ public Write withMaxRequests(long requests) {
Review Comment:
Im not sure why this would confuse people. The calculation is a rough
estimate and not quite correct (ie when there are partial batches and retries).
If we had previously exposed maxRequests on the public surface then I can see
this calculation making sense. But since this is green field, why not stay
consistent with veneer?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]