You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/05/01 18:38:00 UTC

[jira] [Work logged] (BEAM-4061) Chaining SpannerIO#write() transforms

     [ https://issues.apache.org/jira/browse/BEAM-4061?focusedWorklogId=97179&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-97179 ]

ASF GitHub Bot logged work on BEAM-4061:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 01/May/18 18:37
            Start Date: 01/May/18 18:37
    Worklog Time Spent: 10m 
      Work Description: mairbek commented on a change in pull request #4264: [BEAM-4061] Introduced SpannerWriteResult
URL: https://github.com/apache/beam/pull/4264#discussion_r185298381
 
 

 ##########
 File path: sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerWriteResult.java
 ##########
 @@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.gcp.spanner;
+
+import com.google.cloud.spanner.Mutation;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.transforms.PTransform;
+import org.apache.beam.sdk.values.PCollection;
+import org.apache.beam.sdk.values.PInput;
+import org.apache.beam.sdk.values.POutput;
+import org.apache.beam.sdk.values.PValue;
+import org.apache.beam.sdk.values.TupleTag;
+
+/**
+ * A result of {@link SpannerIO#write()} transform. Use {@link #getFailedMutations} to access
+ * failed Mutations.
+ */
+public class SpannerWriteResult implements POutput {
+  private final Pipeline pipeline;
+  private final PCollection<Void> output;
+  private final PCollection<MutationGroup> failedMutations;
+
+  public SpannerWriteResult(Pipeline pipeline, PCollection<Void> output,
+      PCollection<MutationGroup> failedMutations) {
+    this.pipeline = pipeline;
+    this.output = output;
+    this.failedMutations = failedMutations;
+  }
+
+  @Override
+  public Pipeline getPipeline() {
+    return pipeline;
+  }
+
+  @Override
+  public Map<TupleTag<?>, PValue> expand() {
+    return ImmutableMap.of(new TupleTag<Mutation>("failedMutation"), failedMutations);
+  }
+
+  public PCollection<MutationGroup> getFailedMutations() {
+    return failedMutations;
+  }
+
+  public PCollection<Void> getOutput() {
+    return output;
+  }
+
+  @Override
+  public void finishSpecifyingOutput(String transformName, PInput input,
 
 Review comment:
   it's defined in `POutput`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 97179)
    Time Spent: 1h  (was: 50m)

> Chaining SpannerIO#write() transforms
> -------------------------------------
>
>                 Key: BEAM-4061
>                 URL: https://issues.apache.org/jira/browse/BEAM-4061
>             Project: Beam
>          Issue Type: Bug
>          Components: io-java-gcp
>            Reporter: Mairbek Khadikov
>            Assignee: Mairbek Khadikov
>            Priority: Major
>             Fix For: 2.5.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> It should be possible to chain several Cloud Spanner writes. In practice, we can leverage Wait.on transform by returning a result object from SpannerIO#write.
> One particular example, when this feature is useful is full database import. When data in parent tables should be injected before interleaved tables. See more about table hierarchies in Spanner here https://cloud.google.com/spanner/docs/schema-and-data-model#creating_a_hierarchy_of_interleaved_tables



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)