use of org.apache.flink.table.data.writer.BinaryRowWriter in project flink by apache.
the class BytesMapTestBase method createRow.
protected BinaryRowData createRow(Integer f0, String f1, Double f2, Long f3, Boolean f4, Float f5, Short f6) {
BinaryRowData row = new BinaryRowData(7);
BinaryRowWriter writer = new BinaryRowWriter(row);
// int, string, double, long, boolean
if (f0 == null) {
writer.setNullAt(0);
} else {
writer.writeInt(0, f0);
}
if (f1 == null) {
writer.setNullAt(1);
} else {
writer.writeString(1, StringData.fromString(f1));
}
if (f2 == null) {
writer.setNullAt(2);
} else {
writer.writeDouble(2, f2);
}
if (f3 == null) {
writer.setNullAt(3);
} else {
writer.writeLong(3, f3);
}
if (f4 == null) {
writer.setNullAt(4);
} else {
writer.writeBoolean(4, f4);
}
if (f5 == null) {
writer.setNullAt(5);
} else {
writer.writeFloat(5, f5);
}
if (f6 == null) {
writer.setNullAt(6);
} else {
writer.writeShort(6, f6);
}
writer.complete();
return row;
}
use of org.apache.flink.table.data.writer.BinaryRowWriter in project flink by apache.
the class WindowKeySerializerTest method createRow.
private static BinaryRowData createRow(String f0, int f1) {
BinaryRowData row = new BinaryRowData(2);
BinaryRowWriter writer = new BinaryRowWriter(row);
writer.writeString(0, StringData.fromString(f0));
writer.writeInt(1, f1);
writer.complete();
return row;
}
use of org.apache.flink.table.data.writer.BinaryRowWriter in project flink by apache.
the class ResettableExternalBufferTest method randomInsert.
private long randomInsert(ResettableExternalBuffer buffer) throws IOException {
long l = random.nextLong();
BinaryRowData row = new BinaryRowData(1);
BinaryRowWriter writer = new BinaryRowWriter(row);
writer.reset();
writer.writeLong(0, l);
writer.complete();
buffer.add(row);
return l;
}
use of org.apache.flink.table.data.writer.BinaryRowWriter in project flink by apache.
the class ResettableExternalBufferTest method writeHuge.
private void writeHuge(ResettableExternalBuffer buffer, int size) throws IOException {
BinaryRowData row = new BinaryRowData(1);
BinaryRowWriter writer = new BinaryRowWriter(row);
writer.reset();
writer.writeString(0, StringData.fromString(RandomStringUtils.random(size)));
writer.complete();
buffer.add(row);
}
use of org.apache.flink.table.data.writer.BinaryRowWriter in project flink by apache.
the class EqualiserCodeGeneratorTest method testRaw.
@Test
public void testRaw() {
RecordEqualiser equaliser = new EqualiserCodeGenerator(new LogicalType[] { new TypeInformationRawType<>(Types.INT) }).generateRecordEqualiser("RAW").newInstance(Thread.currentThread().getContextClassLoader());
Function<RawValueData<?>, BinaryRowData> func = o -> {
BinaryRowData row = new BinaryRowData(1);
BinaryRowWriter writer = new BinaryRowWriter(row);
writer.writeRawValue(0, o, new RawValueDataSerializer<>(IntSerializer.INSTANCE));
writer.complete();
return row;
};
assertBoolean(equaliser, func, RawValueData.fromObject(1), RawValueData.fromObject(1), true);
assertBoolean(equaliser, func, RawValueData.fromObject(1), RawValueData.fromObject(2), false);
}
Aggregations