MiguelAnzoWizeline commented on a change in pull request #14811:
URL: https://github.com/apache/beam/pull/14811#discussion_r660729746
##########
File path:
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/BatchSpannerRead.java
##########
@@ -133,7 +130,7 @@ public void processElement(ProcessContext c) throws
Exception {
}
}
- private static class ReadFromPartitionFn extends DoFn<Partition, Struct> {
+ private static class ReadFromPartitionFn extends DoFn<List<Partition>,
Struct> {
Review comment:
Added @BoundedPerElement.
About size information, we have a list of partitions to process, so we have
the size of the total elements to process, which I think would be the best
information to have about the size.
##########
File path:
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/BatchSpannerRead.java
##########
@@ -157,19 +154,29 @@ public void teardown() throws Exception {
}
@ProcessElement
- public void processElement(ProcessContext c) throws Exception {
+ public void processElement(ProcessContext c,
RestrictionTracker<OffsetRange, Long> tracker)
+ throws Exception {
Transaction tx = c.sideInput(txView);
BatchReadOnlyTransaction batchTx =
spannerAccessor.getBatchClient().batchReadOnlyTransaction(tx.transactionId());
- Partition p = c.element();
- try (ResultSet resultSet = batchTx.execute(p)) {
- while (resultSet.next()) {
- Struct s = resultSet.getCurrentRowAsStruct();
- c.output(s);
+ List<Partition> partitions = c.element();
+ for (int i = (int) tracker.currentRestriction().getFrom(); i <
partitions.size(); i++) {
Review comment:
Fixed
--
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]