This is an automated email from the ASF dual-hosted git repository. tzulitai pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/flink.git
commit 572b9d6250b8bcdd5d9968ab12a223a3daf762f1 Author: Tzu-Li (Gordon) Tai <[email protected]> AuthorDate: Thu Feb 28 17:29:29 2019 +0800 [FLINK-11755] [core] Removed no longer used class TypeDeserializer --- .../api/common/typeutils/TypeDeserializer.java | 80 ------------- .../common/typeutils/TypeDeserializerAdapter.java | 133 --------------------- 2 files changed, 213 deletions(-) diff --git a/flink-core/src/main/java/org/apache/flink/api/common/typeutils/TypeDeserializer.java b/flink-core/src/main/java/org/apache/flink/api/common/typeutils/TypeDeserializer.java deleted file mode 100644 index de60ebc..0000000 --- a/flink-core/src/main/java/org/apache/flink/api/common/typeutils/TypeDeserializer.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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.flink.api.common.typeutils; - -import org.apache.flink.core.memory.DataInputView; - -import java.io.IOException; - -/** - * This interface describes the methods that are required for a data type to be read by the Flink runtime. - * Specifically, this interface contains the deserialization methods. In contrast, the {@link TypeSerializer} - * interface contains the complete set of methods for both serialization and deserialization. - * - * <p>The methods in this class are assumed to be stateless, such that it is effectively thread safe. Stateful - * implementations of the methods may lead to unpredictable side effects and will compromise both stability and - * correctness of the program. - * - * @param <T> The data type that the deserializer deserializes. - */ -public interface TypeDeserializer<T> { - - /** - * Creates a deep copy of this deserializer if it is necessary, i.e. if it is stateful. This - * can return itself if the serializer is not stateful. - * - * We need this because deserializers might be used in several threads. Stateless deserializers - * are inherently thread-safe while stateful deserializers might not be thread-safe. - */ - TypeSerializer<T> duplicate(); - - /** - * De-serializes a record from the given source input view. - * - * @param source The input view from which to read the data. - * @return The deserialized element. - * - * @throws IOException Thrown, if the de-serialization encountered an I/O related error. Typically raised by the - * input view, which may have an underlying I/O channel from which it reads. - */ - T deserialize(DataInputView source) throws IOException; - - /** - * De-serializes a record from the given source input view into the given reuse record instance if mutable. - * - * @param reuse The record instance into which to de-serialize the data. - * @param source The input view from which to read the data. - * @return The deserialized element. - * - * @throws IOException Thrown, if the de-serialization encountered an I/O related error. Typically raised by the - * input view, which may have an underlying I/O channel from which it reads. - */ - T deserialize(T reuse, DataInputView source) throws IOException; - - /** - * Gets the length of the data type, if it is a fix length data type. - * - * @return The length of the data type, or <code>-1</code> for variable length data types. - */ - int getLength(); - - boolean equals(Object obj); - - int hashCode(); -} diff --git a/flink-core/src/main/java/org/apache/flink/api/common/typeutils/TypeDeserializerAdapter.java b/flink-core/src/main/java/org/apache/flink/api/common/typeutils/TypeDeserializerAdapter.java deleted file mode 100644 index 86883e8..0000000 --- a/flink-core/src/main/java/org/apache/flink/api/common/typeutils/TypeDeserializerAdapter.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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.flink.api.common.typeutils; - -import org.apache.flink.annotation.Internal; -import org.apache.flink.core.memory.DataInputView; -import org.apache.flink.core.memory.DataOutputView; -import org.apache.flink.util.Preconditions; - -import java.io.IOException; - -/** - * A utility class that is used to bridge a {@link TypeSerializer} and {@link TypeDeserializer}. - * It either wraps a type deserializer or serializer, and can only ever be used for deserialization - * (i.e. only read-related methods is functional). - * - * <p>Methods related to deserialization are directly forwarded to the wrapped deserializer or serializer, - * while serialization methods are masked and not intended for use. - * - * @param <T> The data type that the deserializer deserializes. - */ -@Internal -public final class TypeDeserializerAdapter<T> extends TypeSerializer<T> implements TypeDeserializer<T> { - - private static final long serialVersionUID = 1L; - - /** The actual wrapped deserializer or serializer instance */ - private final TypeDeserializer<T> deserializer; - private final TypeSerializer<T> serializer; - - /** - * Creates a {@link TypeDeserializerAdapter} that wraps a {@link TypeDeserializer}. - * - * @param deserializer the actual deserializer to wrap. - */ - public TypeDeserializerAdapter(TypeDeserializer<T> deserializer) { - this.deserializer = Preconditions.checkNotNull(deserializer); - this.serializer = null; - } - - /** - * Creates a {@link TypeDeserializerAdapter} that wraps a {@link TypeSerializer}. - * - * @param serializer the actual serializer to wrap. - */ - public TypeDeserializerAdapter(TypeSerializer<T> serializer) { - this.deserializer = null; - this.serializer = Preconditions.checkNotNull(serializer); - } - - // -------------------------------------------------------------------------------------------- - // Forwarded deserialization related methods - // -------------------------------------------------------------------------------------------- - - public T deserialize(DataInputView source) throws IOException { - return (deserializer != null) ? deserializer.deserialize(source) : serializer.deserialize(source); - } - - public T deserialize(T reuse, DataInputView source) throws IOException { - return (deserializer != null) ? deserializer.deserialize(reuse, source) : serializer.deserialize(reuse, source); - } - - public TypeSerializer<T> duplicate() { - return (deserializer != null) ? deserializer.duplicate() : serializer.duplicate(); - } - - public int getLength() { - return (deserializer != null) ? deserializer.getLength() : serializer.getLength(); - } - - public boolean equals(Object obj) { - return (deserializer != null) ? deserializer.equals(obj) : serializer.equals(obj); - } - - public int hashCode() { - return (deserializer != null) ? deserializer.hashCode() : serializer.hashCode(); - } - - // -------------------------------------------------------------------------------------------- - // Irrelevant methods not intended for use - // -------------------------------------------------------------------------------------------- - - public boolean isImmutableType() { - throw new UnsupportedOperationException( - "This is a TypeDeserializerAdapter used only for deserialization; this method should not be used."); - } - - public T createInstance() { - throw new UnsupportedOperationException( - "This is a TypeDeserializerAdapter used only for deserialization; this method should not be used."); - } - - public T copy(T from) { - throw new UnsupportedOperationException( - "This is a TypeDeserializerAdapter used only for deserialization; this method should not be used."); - } - - public T copy(T from, T reuse) { - throw new UnsupportedOperationException( - "This is a TypeDeserializerAdapter used only for deserialization; this method should not be used."); - } - - public void serialize(T record, DataOutputView target) throws IOException { - throw new UnsupportedOperationException( - "This is a TypeDeserializerAdapter used only for deserialization; this method should not be used."); - } - - public void copy(DataInputView source, DataOutputView target) throws IOException { - throw new UnsupportedOperationException( - "This is a TypeDeserializerAdapter used only for deserialization; this method should not be used."); - } - - public TypeSerializerSnapshot<T> snapshotConfiguration() { - throw new UnsupportedOperationException( - "This is a TypeDeserializerAdapter used only for deserialization; this method should not be used."); - } -}
