You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ro...@apache.org on 2025/01/15 02:51:53 UTC

(flink) branch master updated: [FLINK-36493][table-common] Remove all deprecated methods in MapView (#25566)

This is an automated email from the ASF dual-hosted git repository.

ron pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e174ff363f [FLINK-36493][table-common] Remove all deprecated methods in MapView (#25566)
3e174ff363f is described below

commit 3e174ff363f0e8ae76443d6305d0413a0ee3e3b0
Author: Gantigmaa Selenge <39...@users.noreply.github.com>
AuthorDate: Wed Jan 15 02:51:45 2025 +0000

    [FLINK-36493][table-common] Remove all deprecated methods in MapView (#25566)
    
    Signed-off-by: Gantigmaa Selenge <ti...@gmail.com>
---
 .../apache/flink/table/api/dataview/MapView.java   | 29 ++----------
 .../table/dataview/MapViewTypeInfoFactory.java     | 54 ----------------------
 .../planner/typeutils/LegacyDataViewUtils.scala    | 28 +++--------
 3 files changed, 9 insertions(+), 102 deletions(-)

diff --git a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/dataview/MapView.java b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/dataview/MapView.java
index a99f58957ce..887d9dfe44f 100644
--- a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/dataview/MapView.java
+++ b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/dataview/MapView.java
@@ -20,11 +20,8 @@ package org.apache.flink.table.api.dataview;
 
 import org.apache.flink.annotation.PublicEvolving;
 import org.apache.flink.api.common.state.MapState;
-import org.apache.flink.api.common.typeinfo.TypeInfo;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
 import org.apache.flink.table.annotation.DataTypeHint;
 import org.apache.flink.table.api.DataTypes;
-import org.apache.flink.table.dataview.MapViewTypeInfoFactory;
 import org.apache.flink.table.functions.AggregateFunction;
 import org.apache.flink.table.functions.TableAggregateFunction;
 import org.apache.flink.table.types.DataType;
@@ -89,10 +86,12 @@ import java.util.Objects;
  *
  * }</pre>
  *
+ * <p>{@code MapView(TypeInformation<?> keyType, TypeInformation<?> valueType)} method was
+ * deprecated and removed. Please use a {@link DataTypeHint} instead.
+ *
  * @param <K> key type
  * @param <V> value type
  */
-@TypeInfo(MapViewTypeInfoFactory.class)
 @PublicEvolving
 public class MapView<K, V> implements DataView {
 
@@ -255,26 +254,4 @@ public class MapView<K, V> implements DataView {
                 DataTypes.FIELD(
                         "map", DataTypes.MAP(keyDataType, valueDataType).bridgedTo(Map.class)));
     }
-
-    // --------------------------------------------------------------------------------------------
-    // Legacy
-    // --------------------------------------------------------------------------------------------
-
-    @Deprecated public transient TypeInformation<?> keyType;
-
-    @Deprecated public transient TypeInformation<?> valueType;
-
-    /**
-     * Creates a {@link MapView} with the specified key and value types.
-     *
-     * @param keyType The type of keys of the map view.
-     * @param valueType The type of values of the map view.
-     * @deprecated This method uses the old type system. Please use a {@link DataTypeHint} instead
-     *     if the reflective type extraction is not successful.
-     */
-    @Deprecated
-    public MapView(TypeInformation<?> keyType, TypeInformation<?> valueType) {
-        this.keyType = keyType;
-        this.valueType = valueType;
-    }
 }
diff --git a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/dataview/MapViewTypeInfoFactory.java b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/dataview/MapViewTypeInfoFactory.java
deleted file mode 100644
index c54664c4ecc..00000000000
--- a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/dataview/MapViewTypeInfoFactory.java
+++ /dev/null
@@ -1,54 +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.table.dataview;
-
-import org.apache.flink.annotation.Internal;
-import org.apache.flink.api.common.typeinfo.TypeInfoFactory;
-import org.apache.flink.api.common.typeinfo.TypeInformation;
-import org.apache.flink.api.java.typeutils.GenericTypeInfo;
-import org.apache.flink.table.api.dataview.MapView;
-
-import java.lang.reflect.Type;
-import java.util.Map;
-
-/** TypeInformation factory for {@link MapView}. */
-@Internal
-@Deprecated
-public class MapViewTypeInfoFactory<K, V> extends TypeInfoFactory<MapView<K, V>> {
-
-    @Override
-    public TypeInformation<MapView<K, V>> createTypeInfo(
-            Type t, Map<String, TypeInformation<?>> genericParameters) {
-        TypeInformation<?> keyType = genericParameters.get("K");
-        TypeInformation<?> valueType = genericParameters.get("V");
-
-        if (keyType == null) {
-            // we might can get the keyType later from the MapView constructor
-            keyType = new GenericTypeInfo<>(Object.class);
-        }
-
-        if (valueType == null) {
-            // we might can get the keyType later from the MapView constructor
-            valueType = new GenericTypeInfo<>(Object.class);
-        }
-
-        //noinspection unchecked
-        return new MapViewTypeInfo<>((TypeInformation<K>) keyType, (TypeInformation<V>) valueType);
-    }
-}
diff --git a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/typeutils/LegacyDataViewUtils.scala b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/typeutils/LegacyDataViewUtils.scala
index 3553397a254..fa29cfe749c 100644
--- a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/typeutils/LegacyDataViewUtils.scala
+++ b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/typeutils/LegacyDataViewUtils.scala
@@ -17,7 +17,6 @@
  */
 package org.apache.flink.table.planner.typeutils
 
-import org.apache.flink.api.common.ExecutionConfig
 import org.apache.flink.api.common.serialization.SerializerConfigImpl
 import org.apache.flink.api.common.typeinfo.TypeInformation
 import org.apache.flink.api.common.typeutils.CompositeType
@@ -158,40 +157,25 @@ object LegacyDataViewUtils {
           "MapView, SortedMapView and ListView only supported at first level of " +
             "accumulators of Pojo type.")
       case map: MapViewTypeInfo[_, _] =>
-        val mapView = instance match {
-          case b: BinaryRawValueData[_] =>
-            b.getJavaObject.asInstanceOf[MapView[_, _]]
-          case _ =>
-            instance.asInstanceOf[MapView[_, _]]
-        }
-
-        val newTypeInfo =
-          if (mapView != null && mapView.keyType != null && mapView.valueType != null) {
-            // use explicit key value type if user has defined
-            new MapViewTypeInfo(mapView.keyType, mapView.valueType)
-          } else {
-            map
-          }
-
         if (!isStateBackedDataViews) {
           // add data view field if it is not backed by a state backend.
           // data view fields which are backed by state backend are not serialized.
-          newTypeInfo.setNullSerializer(false)
+          map.setNullSerializer(false)
         } else {
-          newTypeInfo.setNullSerializer(true)
+          map.setNullSerializer(true)
 
           // create map view specs with unique id (used as state name)
           val mapViewSpec = new MapViewSpec(
             "agg" + aggIndex + "$" + fieldName,
             fieldIndex, // dataview field index in pojo
-            fromLegacyInfoToDataType(newTypeInfo),
+            fromLegacyInfoToDataType(map),
             false,
-            newTypeInfo.getKeyType.createSerializer(new SerializerConfigImpl),
-            newTypeInfo.getValueType.createSerializer(new SerializerConfigImpl)
+            map.getKeyType.createSerializer(new SerializerConfigImpl),
+            map.getValueType.createSerializer(new SerializerConfigImpl)
           )
           spec = Some(mapViewSpec)
         }
-        newTypeInfo
+        map
 
       case list: ListViewTypeInfo[_] =>
         val listView = instance match {