You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by tg...@apache.org on 2017/01/23 21:02:11 UTC
[2/3] beam git commit: Refactor EmptyOnDeserializationThreadLocal to
util
Refactor EmptyOnDeserializationThreadLocal to util
This is a serialization-capable ThreadLocal used in AvroCoder.
Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/e1ee05e8
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/e1ee05e8
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/e1ee05e8
Branch: refs/heads/master
Commit: e1ee05e80e54e61b511a71a98a66868b81745533
Parents: 9db5f74
Author: Kai Jiang <ji...@gmail.com>
Authored: Mon Jan 23 11:45:36 2017 -0800
Committer: Thomas Groh <tg...@google.com>
Committed: Mon Jan 23 11:46:48 2017 -0800
----------------------------------------------------------------------
.../org/apache/beam/sdk/coders/AvroCoder.java | 19 +---------
.../util/EmptyOnDeserializationThreadLocal.java | 39 ++++++++++++++++++++
2 files changed, 40 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/beam/blob/e1ee05e8/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/AvroCoder.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/AvroCoder.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/AvroCoder.java
index 2c88c9a..9316224 100644
--- a/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/AvroCoder.java
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/AvroCoder.java
@@ -24,7 +24,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Supplier;
import java.io.IOException;
import java.io.InputStream;
-import java.io.ObjectStreamException;
import java.io.OutputStream;
import java.io.Serializable;
import java.lang.reflect.Field;
@@ -59,6 +58,7 @@ import org.apache.avro.specific.SpecificData;
import org.apache.avro.util.ClassUtils;
import org.apache.avro.util.Utf8;
import org.apache.beam.sdk.util.CloudObject;
+import org.apache.beam.sdk.util.EmptyOnDeserializationThreadLocal;
import org.apache.beam.sdk.values.TypeDescriptor;
/**
@@ -176,23 +176,6 @@ public class AvroCoder<T> extends StandardCoder<T> {
private static final DecoderFactory DECODER_FACTORY = DecoderFactory.get();
/**
- * A {@link Serializable} {@link ThreadLocal} which discards any "stored" objects. This allows
- * for Kryo to serialize an {@link AvroCoder} as a final field.
- */
- private static class EmptyOnDeserializationThreadLocal<T>
- extends ThreadLocal<T> implements Serializable {
- private void writeObject(java.io.ObjectOutputStream out) throws IOException {
- }
-
- private void readObject(java.io.ObjectInputStream in)
- throws IOException, ClassNotFoundException {
- }
-
- private void readObjectNoData() throws ObjectStreamException {
- }
- }
-
- /**
* A {@link Serializable} object that holds the {@link String} version of a {@link Schema}.
* This is paired with the {@link SerializableSchemaSupplier} via {@link Serializable}'s usage
* of the {@link #readResolve} method.
http://git-wip-us.apache.org/repos/asf/beam/blob/e1ee05e8/sdks/java/core/src/main/java/org/apache/beam/sdk/util/EmptyOnDeserializationThreadLocal.java
----------------------------------------------------------------------
diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/util/EmptyOnDeserializationThreadLocal.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/EmptyOnDeserializationThreadLocal.java
new file mode 100644
index 0000000..890728a
--- /dev/null
+++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/util/EmptyOnDeserializationThreadLocal.java
@@ -0,0 +1,39 @@
+/*
+ * 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.util;
+
+import java.io.IOException;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+import org.apache.beam.sdk.coders.Coder;
+
+/**
+ * A {@link Serializable} {@link ThreadLocal} which discards any "stored" objects. This allows
+ * for Kryo to serialize a {@link Coder} as a final field.
+ */
+public class EmptyOnDeserializationThreadLocal<T> extends ThreadLocal<T> implements Serializable {
+ private void writeObject(java.io.ObjectOutputStream out) throws IOException {
+ }
+
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ }
+
+ private void readObjectNoData() throws ObjectStreamException {
+ }
+}