[
https://issues.apache.org/jira/browse/BEAM-9856?focusedWorklogId=435501&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-435501
]
ASF GitHub Bot logged work on BEAM-9856:
----------------------------------------
Author: ASF GitHub Bot
Created on: 20/May/20 15:33
Start Date: 20/May/20 15:33
Worklog Time Spent: 10m
Work Description: lukecwik commented on a change in pull request #11596:
URL: https://github.com/apache/beam/pull/11596#discussion_r428107636
##########
File path:
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2IO.java
##########
@@ -427,39 +458,59 @@ private Message fetchMessage(HealthcareApiClient client,
String msgId)
* @param filter the filter
*/
ListHL7v2Messages(ValueProvider<List<String>> hl7v2Stores,
ValueProvider<String> filter) {
- this.hl7v2Stores = hl7v2Stores.get();
- this.filter = filter.get();
+ this.hl7v2Stores = hl7v2Stores;
+ this.filter = filter;
+ this.initialSplitDuration = null;
}
- ListHL7v2Messages(ValueProvider<List<String>> hl7v2Stores) {
- this.hl7v2Stores = hl7v2Stores.get();
- this.filter = null;
+ public ListHL7v2Messages withInitialSplitDuration(Duration
initialSplitDuration) {
+ this.initialSplitDuration = initialSplitDuration;
+ return this;
}
@Override
public PCollection<HL7v2Message> expand(PBegin input) {
return input
- .apply(Create.of(this.hl7v2Stores))
- .apply(ParDo.of(new ListHL7v2MessagesFn(this.filter)))
- .setCoder(new HL7v2MessageCoder())
+ .apply(Create.ofProvider(this.hl7v2Stores,
ListCoder.of(StringUtf8Coder.of())))
+ .apply(FlatMapElements.into(TypeDescriptors.strings()).via((x) -> x))
+ .apply(ParDo.of(new ListHL7v2MessagesFn(filter,
initialSplitDuration)))
+ .setCoder(HL7v2MessageCoder.of())
// Break fusion to encourage parallelization of downstream
processing.
.apply(Reshuffle.viaRandomKey());
}
}
+ /**
+ * Implemented as Splitable DoFn that claims millisecond resolutions of
offset restrictions in the
+ * Message.sendTime dimension.
+ */
+ @BoundedPerElement
+ @VisibleForTesting
static class ListHL7v2MessagesFn extends DoFn<String, HL7v2Message> {
-
- private final String filter;
+ // These control the initial restriction split which means that the list
of integer pairs
+ // must comfortably fit in memory.
+ private static final Duration DEFAULT_DESIRED_SPLIT_DURATION =
Duration.standardDays(1);
+ private static final Duration DEFAULT_MIN_SPLIT_DURATION =
Duration.standardHours(1);
+
+ private static final Logger LOG =
LoggerFactory.getLogger(ListHL7v2MessagesFn.class);
+ private ValueProvider<String> filter;
+ private Duration initialSplitDuration;
+ private Instant from;
+ private Instant to;
Review comment:
`from` and `to` seem to only be used within `@GetInitialRestriction`,
can we make them local variables there?
##########
File path:
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2IO.java
##########
@@ -415,10 +424,32 @@ private Message fetchMessage(HealthcareApiClient client,
String msgId)
}
}
- /** List HL7v2 messages in HL7v2 Stores with optional filter. */
+ /**
+ * List HL7v2 messages in HL7v2 Stores with optional filter.
+ *
+ * <p>This transform is optimized for splitting of message.list calls for
large batches of
+ * historical data and assumes rather continuous stream of sendTimes.
+ *
+ * <p>Note on Benchmarking By default, this will make more queries than
necessary when used with
Review comment:
`Benchmarking By`?
Awkward sentence and capitalization.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 435501)
Time Spent: 9.5h (was: 9h 20m)
> HL7v2IO.ListHL7v2Messages should be refactored to support more parallelization
> ------------------------------------------------------------------------------
>
> Key: BEAM-9856
> URL: https://issues.apache.org/jira/browse/BEAM-9856
> Project: Beam
> Issue Type: Improvement
> Components: io-java-gcp
> Reporter: Jacob Ferriero
> Assignee: Jacob Ferriero
> Priority: P3
> Time Spent: 9.5h
> Remaining Estimate: 0h
>
> Currently the List Messages API paginates through in a single ProcessElement
> Call.
> However we could get a restriction based on createTime using Messages.List
> filter and orderby.
>
> This is inline with the future roadmap of HL7v2 bulk export API becomes
> available that should allow splitting on (e.g. create time dimension).
> Leveraging this bulk export might be a future optimization to explore.
>
> This could take one of two forms:
> 1. dyanmically splitable via splitable DoFn (sexy, beam idiomatic: make
> optimization the runner's problem, potentially unnecessarily complex for this
> use case )
> 2. static splitting on some time partition e.g. finding the earliest
> createTime and emitting a PCollection of 1 hour partitions and paginating
> through each hour of data w/ in the time frame that the store spans, in a
> separate ProcessElement. (easy to implement but will likely have hot keys /
> stragglers based on "busy hours")
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)