prodriguezdefino commented on code in PR #17550:
URL: https://github.com/apache/beam/pull/17550#discussion_r868563175
##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/StorageApiWriteUnshardedRecords.java:
##########
@@ -213,22 +229,38 @@ String createStreamIfNeeded() {
return this.streamName;
}
+ List<StreamAppendClient> generateClients() {
+ return IntStream.range(0, streamAppendClientCount)
+ .mapToObj(
+ i -> {
+ try {
+ StreamAppendClient client =
+ datasetService.getStreamAppendClient(
+ streamName, descriptorWrapper.descriptor);
+ return client;
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ })
+ .collect(Collectors.toList());
+ }
+
StreamAppendClient getStreamAppendClient(boolean lookupCache) {
try {
if (streamAppendClient == null) {
createStreamIfNeeded();
synchronized (APPEND_CLIENTS) {
if (lookupCache) {
this.streamAppendClient =
- APPEND_CLIENTS.get(
- streamName,
- () ->
- datasetService.getStreamAppendClient(
- streamName, descriptorWrapper.descriptor));
+ APPEND_CLIENTS.get(streamName, () ->
generateClients()).get(clientNumber);
Review Comment:
Instead of making the client creation lazy, I reverted the cache structure
back to have a single client per entry. But now, the cache key is the stream
name + the assigned client number.
--
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]