use of org.apache.flink.table.data.writer.BinaryRowWriter in project flink by apache.
the class BinaryMergeIteratorTest method newIterator.
private MutableObjectIterator<BinaryRowData> newIterator(final int[] keys, final String[] values) {
BinaryRowData row = serializer.createInstance();
BinaryRowWriter writer = new BinaryRowWriter(row);
return new MutableObjectIterator<BinaryRowData>() {
private int current = 0;
@Override
public BinaryRowData next(BinaryRowData reuse) {
if (current < keys.length) {
int key = keys[current];
String value = values[current];
current++;
writer.reset();
writer.writeInt(0, key);
writer.writeString(1, StringData.fromString(value));
writer.complete();
return row;
} else {
return null;
}
}
@Override
public BinaryRowData next() {
throw new RuntimeException();
}
};
}
use of org.apache.flink.table.data.writer.BinaryRowWriter in project flink by apache.
the class RandomSortMergeInnerJoinTest method newRow.
public static BinaryRowData newRow(int i, String s1, String s2) {
BinaryRowData row = new BinaryRowData(3);
BinaryRowWriter writer = new BinaryRowWriter(row);
writer.writeInt(0, i);
if (s1 == null) {
writer.setNullAt(1);
} else {
writer.writeString(1, StringData.fromString(s1));
}
if (s2 == null) {
writer.setNullAt(2);
} else {
writer.writeString(2, StringData.fromString(s2));
}
writer.complete();
return row;
}
use of org.apache.flink.table.data.writer.BinaryRowWriter 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.writer.BinaryRowWriter 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.writer.BinaryRowWriter 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);
}
Aggregations