jaketf commented on a change in pull request #11596: URL: https://github.com/apache/beam/pull/11596#discussion_r427686974
########## File path: sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2IO.java ########## @@ -427,29 +454,75 @@ 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; + } + + /** + * Instantiates a new List hl 7 v 2 messages. + * + * @param hl7v2Stores the hl 7 v 2 stores + * @param filter the filter + * @param initialSplitDuration the initial split duration for sendTime dimension splits + */ + ListHL7v2Messages( + ValueProvider<List<String>> hl7v2Stores, + ValueProvider<String> filter, + Duration initialSplitDuration) { + this.hl7v2Stores = hl7v2Stores; + this.filter = filter; + this.initialSplitDuration = initialSplitDuration; } + /** + * Instantiates a new List hl7v2 messages. + * + * @param hl7v2Stores the hl7v2 stores + */ ListHL7v2Messages(ValueProvider<List<String>> hl7v2Stores) { - this.hl7v2Stores = hl7v2Stores.get(); + this.hl7v2Stores = hl7v2Stores; this.filter = null; } + /** + * Instantiates a new List hl7v2 messages. + * + * @param hl7v2Stores the hl7v2 stores + * @param initialSplitDuration the initial split duration + */ + ListHL7v2Messages(ValueProvider<List<String>> hl7v2Stores, Duration initialSplitDuration) { + this.hl7v2Stores = hl7v2Stores; + this.initialSplitDuration = initialSplitDuration; + } + @Override public PCollection<HL7v2Message> expand(PBegin input) { return input - .apply(Create.of(this.hl7v2Stores)) - .apply(ParDo.of(new ListHL7v2MessagesFn(this.filter))) + .apply(Create.ofProvider(this.hl7v2Stores, ListCoder.of(StringUtf8Coder.of()))) + .apply(FlatMapElements.into(TypeDescriptors.strings()).via((x) -> x)) + .apply(ParDo.of(new ListHL7v2MessagesFn(this.filter, initialSplitDuration))) .setCoder(new HL7v2MessageCoder()) // 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 static class ListHL7v2MessagesFn extends DoFn<String, HL7v2Message> { - private final String filter; + private static final Logger LOG = LoggerFactory.getLogger(ListHL7v2MessagesFn.class); + private ValueProvider<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 Duration initialSplitDuration; + private Instant from; + private Instant to; Review comment: I don't think so they don't get set until we make the earliest / lastest sendTime query in @GetInitialRestriction ---------------------------------------------------------------- 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: us...@infra.apache.org