use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.
the class String2HashJoinOperatorTest method newRow.
public static BinaryRowData newRow(String... s) {
BinaryRowData row = new BinaryRowData(s.length);
BinaryRowWriter writer = new BinaryRowWriter(row);
for (int i = 0; i < s.length; i++) {
if (s[i] == null) {
writer.setNullAt(i);
} else {
writer.writeString(i, StringData.fromString(s[i]));
}
}
writer.complete();
return row;
}
use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.
the class RowDataTest method getBinaryRow.
private BinaryRowData getBinaryRow() {
BinaryRowData row = new BinaryRowData(18);
BinaryRowWriter writer = new BinaryRowWriter(row);
writer.writeBoolean(0, true);
writer.writeByte(1, (byte) 1);
writer.writeShort(2, (short) 2);
writer.writeInt(3, 3);
writer.writeLong(4, 4);
writer.writeFloat(5, 5);
writer.writeDouble(6, 6);
writer.writeString(8, str);
writer.writeRawValue(9, generic, genericSerializer);
writer.writeDecimal(10, decimal1, 5);
writer.writeDecimal(11, decimal2, 20);
writer.writeArray(12, array, new ArrayDataSerializer(DataTypes.INT().getLogicalType()));
writer.writeMap(13, map, new MapDataSerializer(DataTypes.INT().getLogicalType(), DataTypes.INT().getLogicalType()));
writer.writeRow(14, underRow, new RowDataSerializer(RowType.of(new IntType(), new IntType())));
writer.writeBinary(15, bytes);
writer.writeTimestamp(16, timestamp1, 3);
writer.writeTimestamp(17, timestamp2, 9);
return row;
}
use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.
the class RowDataTest method testBinaryRow.
@Test
public void testBinaryRow() {
BinaryRowData binaryRow = getBinaryRow();
testGetters(binaryRow);
testSetters(binaryRow);
}
use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.
the class RowDataTest method testNestedRow.
@Test
public void testNestedRow() {
BinaryRowData row = new BinaryRowData(1);
BinaryRowWriter writer = new BinaryRowWriter(row);
writer.writeRow(0, getBinaryRow(), null);
writer.complete();
RowData nestedRow = row.getRow(0, 18);
testGetters(nestedRow);
testSetters(nestedRow);
}
use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.
the class RowDataTest method before.
@Before
public void before() {
str = StringData.fromString("haha");
generic = RawValueData.fromObject("haha");
genericSerializer = new RawValueDataSerializer<>(StringSerializer.INSTANCE);
decimal1 = DecimalData.fromUnscaledLong(10, 5, 0);
decimal2 = DecimalData.fromBigDecimal(new BigDecimal(11), 20, 0);
array = new BinaryArrayData();
{
BinaryArrayWriter arrayWriter = new BinaryArrayWriter(array, 2, 4);
arrayWriter.writeInt(0, 15);
arrayWriter.writeInt(1, 16);
arrayWriter.complete();
}
map = BinaryMapData.valueOf(array, array);
underRow = new BinaryRowData(2);
{
BinaryRowWriter writer = new BinaryRowWriter(underRow);
writer.writeInt(0, 15);
writer.writeInt(1, 16);
writer.complete();
}
bytes = new byte[] { 1, 5, 6 };
timestamp1 = TimestampData.fromEpochMillis(123L);
timestamp2 = TimestampData.fromLocalDateTime(LocalDateTime.of(1969, 1, 1, 0, 0, 0, 123456789));
}
Aggregations