[
https://issues.apache.org/jira/browse/BEAM-3061?focusedWorklogId=275938&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-275938
]
ASF GitHub Bot logged work on BEAM-3061:
----------------------------------------
Author: ASF GitHub Bot
Created on: 12/Jul/19 13:54
Start Date: 12/Jul/19 13:54
Worklog Time Spent: 10m
Work Description: steveniemitz commented on pull request #7805:
[BEAM-3061] Done notifications for BigtableIO.Write
URL: https://github.com/apache/beam/pull/7805#discussion_r302991594
##########
File path:
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableIO.java
##########
@@ -683,95 +724,149 @@ public void populateDisplayData(DisplayData.Builder
builder) {
public String toString() {
return MoreObjects.toStringHelper(Write.class).add("config",
getBigtableConfig()).toString();
}
+ }
- private class BigtableWriterFn extends DoFn<KV<ByteString,
Iterable<Mutation>>, Void> {
+ /**
+ * A {@link PTransform} that writes to Google Cloud Bigtable and emits a
{@link
+ * BigtableWriteResult} for each batch written. See the class-level Javadoc
on {@link BigtableIO}
+ * for more information.
+ *
+ * @see BigtableIO
+ */
+ @Experimental(Experimental.Kind.SOURCE_SINK)
+ public static class WriteWithResults
+ extends PTransform<
+ PCollection<KV<ByteString, Iterable<Mutation>>>,
PCollection<BigtableWriteResult>> {
- public BigtableWriterFn(BigtableConfig bigtableConfig) {
- this.config = bigtableConfig;
- this.failures = new ConcurrentLinkedQueue<>();
- }
+ private final BigtableConfig bigtableConfig;
- @StartBundle
- public void startBundle(StartBundleContext c) throws IOException {
- if (bigtableWriter == null) {
- bigtableWriter =
- config
- .getBigtableService(c.getPipelineOptions())
- .openForWriting(config.getTableId().get());
- }
- recordsWritten = 0;
- }
+ WriteWithResults(BigtableConfig bigtableConfig) {
+ this.bigtableConfig = bigtableConfig;
+ }
- @ProcessElement
- public void processElement(ProcessContext c) throws Exception {
- checkForFailures();
- bigtableWriter
- .writeRecord(c.element())
- .whenComplete(
- (mutationResult, exception) -> {
- if (exception != null) {
- failures.add(new BigtableWriteException(c.element(),
exception));
- }
- });
- ++recordsWritten;
- }
+ @Override
+ public PCollection<BigtableWriteResult> expand(
Review comment:
I changed everything except for toString to delegate to withWriteResults()
----------------------------------------------------------------
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: 275938)
Time Spent: 16h (was: 15h 50m)
> BigtableIO should support emitting a sentinel "done" value when a bundle
> completes
> ----------------------------------------------------------------------------------
>
> Key: BEAM-3061
> URL: https://issues.apache.org/jira/browse/BEAM-3061
> Project: Beam
> Issue Type: Improvement
> Components: io-java-gcp
> Reporter: Steve Niemitz
> Assignee: Steve Niemitz
> Priority: Major
> Time Spent: 16h
> Remaining Estimate: 0h
>
> There was some discussion of this on the dev@ mailing list [1]. This
> approach was taken based on discussion there.
> [1]
> https://lists.apache.org/thread.html/949b33782f722a9000c9bf9e37042739c6fd0927589b99752b78d7bd@%3Cdev.beam.apache.org%3E
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)