You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by al...@apache.org on 2017/09/15 08:28:09 UTC

[1/2] beam git commit: [BEAM-2807] Fix NPE error on CoderTypeSerializerConfigSnapshot serialization

Repository: beam
Updated Branches:
  refs/heads/master 307b03680 -> c09886a4d


[BEAM-2807] Fix NPE error on CoderTypeSerializerConfigSnapshot serialization


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/81d0c436
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/81d0c436
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/81d0c436

Branch: refs/heads/master
Commit: 81d0c436691d33a7ea1bd808413e1aa08e1c4d10
Parents: 307b036
Author: djhworld <dj...@gmail.com>
Authored: Fri Sep 8 22:09:14 2017 +0100
Committer: Aljoscha Krettek <al...@gmail.com>
Committed: Fri Sep 15 10:26:47 2017 +0200

----------------------------------------------------------------------
 .../translation/types/CoderTypeSerializer.java  |  2 +-
 .../types/CoderTypeSerializerTest.java          | 79 ++++++++++++++++++++
 2 files changed, 80 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/81d0c436/runners/flink/src/main/java/org/apache/beam/runners/flink/translation/types/CoderTypeSerializer.java
----------------------------------------------------------------------
diff --git a/runners/flink/src/main/java/org/apache/beam/runners/flink/translation/types/CoderTypeSerializer.java b/runners/flink/src/main/java/org/apache/beam/runners/flink/translation/types/CoderTypeSerializer.java
index ecfd3fb..c8dbac4 100644
--- a/runners/flink/src/main/java/org/apache/beam/runners/flink/translation/types/CoderTypeSerializer.java
+++ b/runners/flink/src/main/java/org/apache/beam/runners/flink/translation/types/CoderTypeSerializer.java
@@ -161,7 +161,7 @@ public class CoderTypeSerializer<T> extends TypeSerializer<T> {
     }
 
     public CoderTypeSerializerConfigSnapshot(Coder<T> coder) {
-      this.coderName = coder.getClass().getCanonicalName();
+      this.coderName = coder.getClass().getName();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/beam/blob/81d0c436/runners/flink/src/test/java/org/apache/beam/runners/flink/translation/types/CoderTypeSerializerTest.java
----------------------------------------------------------------------
diff --git a/runners/flink/src/test/java/org/apache/beam/runners/flink/translation/types/CoderTypeSerializerTest.java b/runners/flink/src/test/java/org/apache/beam/runners/flink/translation/types/CoderTypeSerializerTest.java
new file mode 100644
index 0000000..b0c40de
--- /dev/null
+++ b/runners/flink/src/test/java/org/apache/beam/runners/flink/translation/types/CoderTypeSerializerTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.runners.flink.translation.types;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.beam.runners.flink.translation.types.CoderTypeSerializer.CoderTypeSerializerConfigSnapshot;
+import org.apache.beam.sdk.coders.AtomicCoder;
+import org.apache.beam.sdk.coders.Coder;
+import org.apache.beam.sdk.coders.CoderException;
+import org.apache.beam.sdk.coders.StringUtf8Coder;
+import org.apache.flink.api.common.typeutils.ComparatorTestBase;
+import org.apache.flink.api.common.typeutils.TypeSerializerConfigSnapshot;
+import org.junit.Test;
+
+/**
+ * Tests {@link CoderTypeSerializer}.
+ */
+public class CoderTypeSerializerTest {
+
+  @Test
+  public void shouldWriteAndReadSnapshotForAnonymousClassCoder() throws Exception {
+    AtomicCoder<String> anonymousClassCoder = new AtomicCoder<String>() {
+
+      @Override
+      public void encode(String value, OutputStream outStream)
+          throws CoderException, IOException {
+
+      }
+
+      @Override
+      public String decode(InputStream inStream) throws CoderException, IOException {
+        return "";
+      }
+    };
+
+    testWriteAndReadConfigSnapshot(anonymousClassCoder);
+  }
+
+  @Test
+  public void shouldWriteAndReadSnapshotForConcreteClassCoder() throws Exception {
+    Coder<String> concreteClassCoder = StringUtf8Coder.of();
+    testWriteAndReadConfigSnapshot(concreteClassCoder);
+  }
+
+  private void testWriteAndReadConfigSnapshot(Coder<String> coder) throws IOException {
+    CoderTypeSerializer<String> serializer = new CoderTypeSerializer<>(coder);
+
+    TypeSerializerConfigSnapshot writtenSnapshot = serializer.snapshotConfiguration();
+    ComparatorTestBase.TestOutputView outView = new ComparatorTestBase.TestOutputView();
+    writtenSnapshot.write(outView);
+
+    TypeSerializerConfigSnapshot readSnapshot = new CoderTypeSerializerConfigSnapshot<>();
+    readSnapshot.read(outView.getInputView());
+
+    assertThat(readSnapshot, is(writtenSnapshot));
+  }
+}
+


[2/2] beam git commit: This closes #3826

Posted by al...@apache.org.
This closes #3826


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/c09886a4
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/c09886a4
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/c09886a4

Branch: refs/heads/master
Commit: c09886a4d228dc0e003a660ad298add29618f7a0
Parents: 307b036 81d0c43
Author: Aljoscha Krettek <al...@gmail.com>
Authored: Fri Sep 15 10:27:24 2017 +0200
Committer: Aljoscha Krettek <al...@gmail.com>
Committed: Fri Sep 15 10:27:24 2017 +0200

----------------------------------------------------------------------
 .../translation/types/CoderTypeSerializer.java  |  2 +-
 .../types/CoderTypeSerializerTest.java          | 79 ++++++++++++++++++++
 2 files changed, 80 insertions(+), 1 deletion(-)
----------------------------------------------------------------------