@VisibleForTesting CreateTransaction withServiceFactory(ServiceFactory<Spanner, SpannerOptions> serviceFactory) { SpannerConfig config = getSpannerConfig(); return withSpannerConfig(config.withServiceFactory(serviceFactory)); }
@DoFn.Setup public void setup() throws Exception { spannerAccessor = config.getSpannerConfig().connectToSpanner(); }
/** Specifies the Cloud Spanner database. */ public CreateTransaction withDatabaseId(ValueProvider<String> databaseId) { SpannerConfig config = getSpannerConfig(); return withSpannerConfig(config.withDatabaseId(databaseId)); }
/** Specifies the Cloud Spanner project. */ public CreateTransaction withProjectId(ValueProvider<String> projectId) { SpannerConfig config = getSpannerConfig(); return withSpannerConfig(config.withProjectId(projectId)); }
/** Specifies the Cloud Spanner host. */ public CreateTransaction withHost(ValueProvider<String> host) { SpannerConfig config = getSpannerConfig(); return withSpannerConfig(config.withHost(host)); }
@Override public PCollectionView<Transaction> expand(PBegin input) { getSpannerConfig().validate(); return input .apply(Create.of(1)) .apply("Create transaction", ParDo.of(new CreateTransactionFn(this))) .apply("As PCollectionView", View.asSingleton()); }
/** Specifies the Cloud Spanner instance. */ public CreateTransaction withInstanceId(ValueProvider<String> instanceId) { SpannerConfig config = getSpannerConfig(); return withSpannerConfig(config.withInstanceId(instanceId)); }