[
https://issues.apache.org/jira/browse/BEAM-7386?focusedWorklogId=664862&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-664862
]
ASF GitHub Bot logged work on BEAM-7386:
----------------------------------------
Author: ASF GitHub Bot
Created on: 13/Oct/21 18:22
Start Date: 13/Oct/21 18:22
Worklog Time Spent: 10m
Work Description: laraschmidt commented on a change in pull request
#15275:
URL: https://github.com/apache/beam/pull/15275#discussion_r727405900
##########
File path:
sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/join/PairCoder.java
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.transforms.join;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.coders.CoderException;
+import org.apache.beam.sdk.coders.StructuredCoder;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+
+/** A {@link Coder} for {@link Pair}s that defers to underlying coders. */
+public class PairCoder<V1, V2> extends StructuredCoder<Pair<V1, V2>> {
+ private final Coder<V1> firstCoder;
+ private final Coder<V2> secondCoder;
+
+ private PairCoder(Coder<V1> firstCoder, Coder<V2> secondCoder) {
+ this.firstCoder = firstCoder;
+ this.secondCoder = secondCoder;
+ }
+
+ /** Returns a {@link PairCoder} for the given underlying value coders. */
+ public static <V1, V2> PairCoder<V1, V2> of(Coder<V1> firstCoder, Coder<V2>
secondCoder) {
+ return new PairCoder<>(firstCoder, secondCoder);
+ }
+
+ @Override
+ public void encode(Pair<V1, V2> value, OutputStream outStream)
+ throws CoderException, IOException {
+ firstCoder.encode(value.getFirst(), outStream);
Review comment:
Not familiar with the deprecated context thing but I copied it over from
KVCoder. What exactly is it used for? I assume that in my case I want context
on both (whereas the KV coder only put it on the value).
##########
File path:
sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/join/PairCoder.java
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.transforms.join;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.coders.CoderException;
+import org.apache.beam.sdk.coders.StructuredCoder;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+
+/** A {@link Coder} for {@link Pair}s that defers to underlying coders. */
+public class PairCoder<V1, V2> extends StructuredCoder<Pair<V1, V2>> {
+ private final Coder<V1> firstCoder;
+ private final Coder<V2> secondCoder;
+
+ private PairCoder(Coder<V1> firstCoder, Coder<V2> secondCoder) {
+ this.firstCoder = firstCoder;
+ this.secondCoder = secondCoder;
+ }
+
+ /** Returns a {@link PairCoder} for the given underlying value coders. */
+ public static <V1, V2> PairCoder<V1, V2> of(Coder<V1> firstCoder, Coder<V2>
secondCoder) {
+ return new PairCoder<>(firstCoder, secondCoder);
+ }
+
+ @Override
+ public void encode(Pair<V1, V2> value, OutputStream outStream)
+ throws CoderException, IOException {
+ firstCoder.encode(value.getFirst(), outStream);
Review comment:
Hrm, having both failed so I swapped it to just be on the second element.
--
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 664862)
Time Spent: 16h 50m (was: 16h 40m)
> Add Utility BiTemporalStreamJoin
> --------------------------------
>
> Key: BEAM-7386
> URL: https://issues.apache.org/jira/browse/BEAM-7386
> Project: Beam
> Issue Type: Improvement
> Components: sdk-ideas
> Affects Versions: 2.12.0
> Reporter: Reza ardeshir rokni
> Assignee: Lara Schmidt
> Priority: P3
> Time Spent: 16h 50m
> Remaining Estimate: 0h
>
> Add utility class that enables a temporal join between two streams where
> Stream A is matched to Stream B where
> A.timestamp = (max(b.timestamp) where b.timestamp <= a.timestamp)
> This will use the following overall flow:
> KV(key, Timestamped<V>)
> | Window
> | GBK
> | Statefull DoFn
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)