KurtYoung commented on a change in pull request #11925:
URL: https://github.com/apache/flink/pull/11925#discussion_r416271275



##########
File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/data/binary/BinaryRowDataUtil.java
##########
@@ -66,4 +69,20 @@ public static boolean byteArrayEquals(
                return true;
        }
 
+       public static String toString(RowData row, LogicalType[] types) {

Review comment:
       This is only used in tests, move it to tests?

##########
File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/data/binary/BinaryStringDataUtil.java
##########
@@ -134,49 +136,49 @@
                        }
                }
 
-               return substrings.toArray(new BinaryString[0]);
+               return substrings.toArray(new BinaryStringData[0]);
        }
 
        /**
         * Decide boolean representation of a string.
         */
-       public static Boolean toBooleanSQL(BinaryString str) {
-               BinaryString lowerCase = str.toLowerCase();
+       public static Boolean toBooleanSQL(BinaryStringData str) {
+               BinaryStringData lowerCase = str.toLowerCase();
                return TRUE_STRINGS.contains(lowerCase) ? Boolean.TRUE :
                                (FALSE_STRINGS.contains(lowerCase) ? 
Boolean.FALSE : null);
        }
 
        /**
         * Calculate the hash value of a given string use {@link MessageDigest}.
         */
-       public static BinaryString hash(BinaryString str, MessageDigest md) {
-               return fromString(EncodingUtils.hex(md.digest(str.getBytes())));
+       public static BinaryStringData hash(BinaryStringData str, MessageDigest 
md) {
+               return fromString(EncodingUtils.hex(md.digest(str.toBytes())));
        }
 
-       public static BinaryString hash(BinaryString str, String algorithm) 
throws NoSuchAlgorithmException {
+       public static BinaryStringData hash(BinaryStringData str, String 
algorithm) throws NoSuchAlgorithmException {
                return hash(str, MessageDigest.getInstance(algorithm));
        }
 
        /**
-        * Parses this BinaryString to Decimal.
+        * Parses this BinaryStringData to DecimalData.
         *
-        * @return Decimal value if the parsing was successful, or null if 
overflow
+        * @return DecimalData value if the parsing was successful, or null if 
overflow
         * @throws NumberFormatException if the parsing failed.
         */
-       public static Decimal toDecimal(BinaryString str, int precision, int 
scale) {
+       public static DecimalData toDecimal(BinaryStringData str, int 
precision, int scale) {
                str.ensureMaterialized();
 
-               if (precision > Decimal.MAX_LONG_DIGITS || str.getSizeInBytes() 
> Decimal.MAX_LONG_DIGITS) {
+               if (DecimalDataUtils.isByteArrayDecimal(precision) || 
DecimalDataUtils.isByteArrayDecimal(str.getSizeInBytes())) {

Review comment:
       Is this right? why we check both `precision` and `sizeInBytes` with the 
same method?

##########
File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/data/util/MapDataUtil.java
##########
@@ -16,44 +16,34 @@
  * limitations under the License.
  */
 
-package org.apache.flink.table.dataformat;
+package org.apache.flink.table.data.util;
 
+import org.apache.flink.table.data.ArrayData;
+import org.apache.flink.table.data.MapData;
 import org.apache.flink.table.types.logical.LogicalType;
 
+import java.util.HashMap;
 import java.util.Map;
 
 /**
- * A GenericMap is a map where all the keys have the same type, and all the 
values have the same type.
- * It can be considered as a wrapper class of the normal java map.
+ * Utilities for {@link MapData}.
  */
-public class GenericMap implements BaseMap {
-
-       private final Map<Object, Object> map;
-
-       public GenericMap(Map<Object, Object> map) {
-               this.map = map;
-       }
-
-       @Override
-       public int numElements() {
-               return map.size();
-       }
-
-       @Override
-       public Map toJavaMap(LogicalType keyType, LogicalType valueType) {
-               return map;
-       }
-
-       public Object get(Object key) {
-               return map.get(key);
-       }
-
-       @Override
-       public String toString() {
-               return map.toString();
-       }
-
-       public Map<Object, Object> getMap() {
-               return map;
+public final class MapDataUtil {
+
+       /**
+        * Converts a {@link MapData} into Java {@link Map}, the keys and 
values of the Java map
+        * still holds objects of internal data structures.
+        */
+       public static Map<Object, Object> convertToJavaMap(

Review comment:
       only used by tests




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to