Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpannerIO - Do not use .get() on ValueProvider during pipeline creation #23294

Merged
merged 1 commit into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

* Support for X source added (Java/Python) ([#X](https://github.com/apache/beam/issues/X)).
* Decreased TextSource CPU utilization by 2.3x (Java) ([#23193](https://github.com/apache/beam/issues/23193)).
* Fixed bug when using SpannerIO with RuntimeValueProvider options (Java) ([#22146](https://github.com/apache/beam/issues/22146)).

## New Features / Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.apache.beam.sdk.io.gcp.spanner;

import static org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkNotNull;

import com.google.auto.value.AutoValue;
import com.google.cloud.spanner.BatchReadOnlyTransaction;
import com.google.cloud.spanner.Options;
Expand All @@ -37,7 +39,6 @@
import org.apache.beam.sdk.values.PCollection;
import org.apache.beam.sdk.values.PCollectionView;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.cache.CacheBuilder;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.cache.CacheLoader;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.cache.LoadingCache;
Expand Down Expand Up @@ -118,8 +119,7 @@ public GeneratePartitionsFn(
SpannerConfig config, PCollectionView<? extends Transaction> txView) {
this.config = config;
this.txView = txView;
Preconditions.checkNotNull(config.getRpcPriority());
Preconditions.checkNotNull(config.getRpcPriority().get());
checkNotNull(config.getRpcPriority());
}

@Setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.apache.beam.sdk.options.ValueProvider;
import org.apache.beam.sdk.transforms.display.DisplayData;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.annotations.VisibleForTesting;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableSet;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.joda.time.Duration;
Expand Down Expand Up @@ -161,8 +160,7 @@ public SpannerConfig withProjectId(String projectId) {

/** Specifies the Cloud Spanner instance ID. */
public SpannerConfig withInstanceId(ValueProvider<String> instanceId) {
Preconditions.checkNotNull(instanceId);
Preconditions.checkNotNull(instanceId.get());
checkNotNull(instanceId, "withInstanceId(instanceId) called with null input.");
return toBuilder().setInstanceId(instanceId).build();
}

Expand All @@ -173,8 +171,7 @@ public SpannerConfig withInstanceId(String instanceId) {

/** Specifies the Cloud Spanner database ID. */
public SpannerConfig withDatabaseId(ValueProvider<String> databaseId) {
Preconditions.checkNotNull(databaseId);
Preconditions.checkNotNull(databaseId.get());
checkNotNull(databaseId, "withDatabaseId(databaseId) called with null input.");
return toBuilder().setDatabaseId(databaseId).build();
}

Expand All @@ -185,8 +182,7 @@ public SpannerConfig withDatabaseId(String databaseId) {

/** Specifies the Cloud Spanner host. */
public SpannerConfig withHost(ValueProvider<String> host) {
Preconditions.checkNotNull(host);
Preconditions.checkNotNull(host.get());
checkNotNull(host, "withHost(host) called with null input.");
return toBuilder().setHost(host).build();
}

Expand Down Expand Up @@ -257,8 +253,7 @@ public SpannerConfig withRpcPriority(RpcPriority rpcPriority) {

/** Specifies the RPC priority. */
public SpannerConfig withRpcPriority(ValueProvider<RpcPriority> rpcPriority) {
Preconditions.checkNotNull(rpcPriority);
Preconditions.checkNotNull(rpcPriority.get());
checkNotNull(rpcPriority, "withRpcPriority(rpcPriority) called with null input.");
return toBuilder().setRpcPriority(rpcPriority).build();
}
}