beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From echauc...@apache.org
Subject [beam] 18/37: Fix generated code: uniform exceptions catching, fix parenthesis and variable declarations
Date Thu, 24 Oct 2019 10:15:27 GMT
This is an automated email from the ASF dual-hosted git repository.

echauchot pushed a commit to branch spark-runner_structured-streaming
in repository https://gitbox.apache.org/repos/asf/beam.git

commit 34e8aa8c31a561684eea2e2496757f9f3cae35d0
Author: Etienne Chauchot <echauchot@apache.org>
AuthorDate: Thu Sep 5 15:14:32 2019 +0200

    Fix generated code: uniform exceptions catching, fix parenthesis and variable declarations
---
 .../translation/helpers/EncoderHelpers.java            | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/runners/spark/src/main/java/org/apache/beam/runners/spark/structuredstreaming/translation/helpers/EncoderHelpers.java
b/runners/spark/src/main/java/org/apache/beam/runners/spark/structuredstreaming/translation/helpers/EncoderHelpers.java
index 91aaaf9..c9ab435 100644
--- a/runners/spark/src/main/java/org/apache/beam/runners/spark/structuredstreaming/translation/helpers/EncoderHelpers.java
+++ b/runners/spark/src/main/java/org/apache/beam/runners/spark/structuredstreaming/translation/helpers/EncoderHelpers.java
@@ -227,32 +227,34 @@ public class EncoderHelpers {
 
 /*
      CODE GENERATED:
+     final $javaType ${ev.value}
      try {
-      final $javaType ${ev.value} =
+      ${ev.value} =
       ${input.isNull} ?
       ${CodeGenerator.defaultValue(dataType)} :
       ($javaType) $beamCoder.decode(new java.io.ByteArrayInputStream(${input.value}));
-     } catch (IOException e) {
+     } catch (Exception e) {
       throw new RuntimeException(org.apache.beam.sdk.util.UserCodeException.wrap(e));
      }
 */
 
       List<String> parts = new ArrayList<>();
-      parts.add("try { final ");
+      parts.add("final ");
       parts.add(" ");
-      parts.add(" =");
-      parts.add("?");
-      parts.add(":");
-      parts.add("(");
+      parts.add(";try { ");
+      parts.add(" = ");
+      parts.add("? ");
+      parts.add(": (");
       parts.add(") ");
       parts.add(".decode(new java.io.ByteArrayInputStream(");
-      parts.add("));  } catch (IOException e) {throw new RuntimeException(org.apache.beam.sdk.util.UserCodeException.wrap(e));}");
+      parts.add("));  } catch (Exception e) {throw new RuntimeException(org.apache.beam.sdk.util.UserCodeException.wrap(e));}");
 
       StringContext sc = new StringContext(JavaConversions.collectionAsScalaIterable(parts).toSeq());
 
       List<Object> args = new ArrayList<>();
       args.add(javaType);
       args.add(ev.value());
+      args.add(ev.value());
       args.add(input.isNull());
       args.add(CodeGenerator.defaultValue(dataType(), false));
       args.add(javaType);


Mime
View raw message