[
https://issues.apache.org/jira/browse/BEAM-11151?focusedWorklogId=513147&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-513147
]
ASF GitHub Bot logged work on BEAM-11151:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 17/Nov/20 20:18
Start Date: 17/Nov/20 20:18
Worklog Time Spent: 10m
Work Description: rohdesamuel commented on a change in pull request
#13215:
URL: https://github.com/apache/beam/pull/13215#discussion_r525486839
##########
File path:
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/ToStringFnRunner.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.fn.harness;
+
+import com.google.auto.service.AutoService;
+import java.util.Map;
+import org.apache.beam.model.pipeline.v1.RunnerApi.PTransform;
+import org.apache.beam.runners.core.construction.PTransformTranslation;
+import org.apache.beam.sdk.function.ThrowingFunction;
+import org.apache.beam.sdk.values.KV;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap;
+
+/**
+ * Translates from elements to human-readable string.
+ *
+ * <p>Translation function:
+ *
+ * <ul>
+ * <li>Input: {@code KV<nonce, element>}
+ * <li>Output: {@code KV<nonce, string>}
+ * </ul>
+ *
+ * <p>For each element, the human-readable string is returned. The nonce is
used by a runner to
+ * associate each input with its output. The nonce is represented as an opaque
set of bytes.
+ */
+@SuppressWarnings({
Review comment:
Done, scoped down to the offending method.
##########
File path:
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/ToStringFnRunner.java
##########
@@ -0,0 +1,76 @@
+/*
+ * 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.fn.harness;
+
+import com.google.auto.service.AutoService;
+import java.util.Map;
+import org.apache.beam.model.pipeline.v1.RunnerApi.PTransform;
+import org.apache.beam.runners.core.construction.PTransformTranslation;
+import org.apache.beam.sdk.function.ThrowingFunction;
+import org.apache.beam.sdk.values.KV;
+import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableMap;
+
+/**
+ * Translates from elements to human-readable string.
+ *
+ * <p>Translation function:
+ *
+ * <ul>
+ * <li>Input: {@code KV<nonce, element>}
+ * <li>Output: {@code KV<nonce, string>}
+ * </ul>
+ *
+ * <p>For each element, the human-readable string is returned. The nonce is
used by a runner to
+ * associate each input with its output. The nonce is represented as an opaque
set of bytes.
+ */
+@SuppressWarnings({
+ "rawtypes" // TODO(https://issues.apache.org/jira/browse/BEAM-10556)
+})
+public class ToStringFnRunner {
+ static final String URN = PTransformTranslation.TO_STRING_TRANSFORM_URN;
+
+ /**
+ * A registrar which provides a factory to handle translating elements to a
human readable string.
+ */
+ @AutoService(PTransformRunnerFactory.Registrar.class)
+ public static class Registrar implements PTransformRunnerFactory.Registrar {
+
+ @Override
+ public Map<String, PTransformRunnerFactory> getPTransformRunnerFactories()
{
+ return ImmutableMap.of(
+ URN,
+
MapFnRunners.forValueMapFnFactory(ToStringFnRunner::createToStringFunctionForPTransform));
+ }
+ }
+
+ static <T, V> ThrowingFunction<KV<T, V>, KV<T, String>>
createToStringFunctionForPTransform(
+ String ptransformId, PTransform pTransform) {
+ return (KV<T, V> input) -> {
+ String val = "null";
Review comment:
Done.
----------------------------------------------------------------
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: 513147)
Time Spent: 2h 10m (was: 2h)
> Add ToString support
> --------------------
>
> Key: BEAM-11151
> URL: https://issues.apache.org/jira/browse/BEAM-11151
> Project: Beam
> Issue Type: New Feature
> Components: beam-model
> Reporter: Sam Rohde
> Assignee: Sam Rohde
> Priority: P2
> Time Spent: 2h 10m
> Remaining Estimate: 0h
>
> This tracks work on adding the ToString to Beam. This new transform takes an
> element and returns a human-readable string back.
> design-doc:
> https://docs.google.com/document/d/1v7iWj0LIum04mYwRM_Cvze915tATwmEzLrqj_uVBkCE/edit#
--
This message was sent by Atlassian Jira
(v8.3.4#803005)