TsReaper commented on a change in pull request #8682: 
[FLINK-12796][table-planner-blink] Introduce BaseArray and BaseMap to reduce 
conversion overhead to blink
URL: https://github.com/apache/flink/pull/8682#discussion_r300348438
 
 

 ##########
 File path: 
flink-table/flink-table-runtime-blink/src/test/java/org/apache/flink/table/typeutils/BaseMapSerializerTest.java
 ##########
 @@ -0,0 +1,87 @@
+/*
+ * 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.typeutils;
+
+import org.apache.flink.api.common.typeutils.SerializerTestBase;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.dataformat.BaseMap;
+import org.apache.flink.table.dataformat.BinaryArray;
+import org.apache.flink.table.dataformat.BinaryArrayWriter;
+import org.apache.flink.table.dataformat.BinaryMap;
+import org.apache.flink.table.dataformat.BinaryString;
+import org.apache.flink.table.dataformat.GenericMap;
+import org.apache.flink.testutils.DeeplyEqualsChecker;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A test for the {@link BaseMapSerializer}.
+ */
+public class BaseMapSerializerTest extends SerializerTestBase<BaseMap> {
+
+       public BaseMapSerializerTest() {
+               super(new DeeplyEqualsChecker().withCustomCheck(
+                               (o1, o2) -> o1 instanceof BaseMap && o2 
instanceof BaseMap,
+                               (o1, o2, checker) -> 
newSer().toBinaryMap((BaseMap) o1).equals(newSer().toBinaryMap((BaseMap) o2))
+               ));
+       }
+
+       private static BaseMapSerializer newSer() {
+               return new BaseMapSerializer(DataTypes.INT().getLogicalType(), 
DataTypes.STRING().getLogicalType());
+       }
+
+       @Override
+       protected BaseMapSerializer createSerializer() {
+               return newSer();
+       }
+
+       @Override
+       protected int getLength() {
+               return -1;
+       }
+
+       @Override
+       protected Class<BaseMap> getTypeClass() {
+               return BaseMap.class;
+       }
+
+       @Override
+       protected BaseMap[] getTestData() {
+               Map<Object, Object> first = new HashMap<>();
+               first.put(1, BinaryString.fromString(""));
+               return new BaseMap[] {
+                               new GenericMap(first),
+                               BinaryMap.valueOf(createArray(1, 2), 
BaseArraySerializerTest.createArray("11", "haa")),
+                               BinaryMap.valueOf(createArray(1, 3, 4), 
BaseArraySerializerTest.createArray("11", "haa", "ke")),
+                               BinaryMap.valueOf(createArray(1, 4, 2), 
BaseArraySerializerTest.createArray("11", "haa", "ke")),
+                               BinaryMap.valueOf(createArray(1, 5, 6, 7), 
BaseArraySerializerTest.createArray("11", "lele", "haa", "ke"))
+               };
+       }
+
+       private static BinaryArray createArray(int... vs) {
+               BinaryArray array = new BinaryArray();
+               BinaryArrayWriter writer = new BinaryArrayWriter(array, 
vs.length, 8);
 
 Review comment:
   8 should be 4?

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to