use of org.apache.flink.table.data.binary.BinaryMapData in project flink by apache.
the class BinaryArrayDataTest method testMap.
@Test
public void testMap() {
BinaryArrayData array1 = new BinaryArrayData();
BinaryArrayWriter writer1 = new BinaryArrayWriter(array1, 3, 4);
writer1.writeInt(0, 6);
writer1.writeInt(1, 5);
writer1.writeInt(2, 666);
writer1.complete();
BinaryArrayData array2 = new BinaryArrayData();
BinaryArrayWriter writer2 = new BinaryArrayWriter(array2, 3, 8);
writer2.writeString(0, fromString("6"));
writer2.writeString(1, fromString("5"));
writer2.writeString(2, fromString("666"));
writer2.complete();
BinaryMapData binaryMap = BinaryMapData.valueOf(array1, array2);
BinaryRowData row = new BinaryRowData(1);
BinaryRowWriter rowWriter = new BinaryRowWriter(row);
rowWriter.writeMap(0, binaryMap, new MapDataSerializer(DataTypes.INT().getLogicalType(), DataTypes.INT().getLogicalType()));
rowWriter.complete();
BinaryMapData map = (BinaryMapData) row.getMap(0);
BinaryArrayData key = map.keyArray();
BinaryArrayData value = map.valueArray();
assertEquals(binaryMap, map);
assertEquals(array1, key);
assertEquals(array2, value);
assertEquals(key.getInt(1), 5);
assertEquals(value.getString(1), fromString("5"));
}
Aggregations