use of org.apache.flink.table.runtime.generated.RecordEqualiser 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);
}
use of org.apache.flink.table.runtime.generated.RecordEqualiser in project flink by apache.
the class EqualiserCodeGeneratorTest method testTimestamp.
@Test
public void testTimestamp() {
RecordEqualiser equaliser = new EqualiserCodeGenerator(new LogicalType[] { new TimestampType() }).generateRecordEqualiser("TIMESTAMP").newInstance(Thread.currentThread().getContextClassLoader());
Function<TimestampData, BinaryRowData> func = o -> {
BinaryRowData row = new BinaryRowData(1);
BinaryRowWriter writer = new BinaryRowWriter(row);
writer.writeTimestamp(0, o, 9);
writer.complete();
return row;
};
assertBoolean(equaliser, func, fromEpochMillis(1024), fromEpochMillis(1024), true);
assertBoolean(equaliser, func, fromEpochMillis(1024), fromEpochMillis(1025), false);
}
use of org.apache.flink.table.runtime.generated.RecordEqualiser in project flink by apache.
the class EqualiserCodeGeneratorTest method testManyFields.
@Test
public void testManyFields() {
final LogicalType[] fieldTypes = IntStream.range(0, 499).mapToObj(i -> new VarCharType()).toArray(LogicalType[]::new);
final RecordEqualiser equaliser = new EqualiserCodeGenerator(fieldTypes).generateRecordEqualiser("ManyFields").newInstance(Thread.currentThread().getContextClassLoader());
final StringData[] fields = IntStream.range(0, 499).mapToObj(i -> StringData.fromString("Entry " + i)).toArray(StringData[]::new);
assertTrue(equaliser.equals(GenericRowData.of((Object[]) fields), GenericRowData.of((Object[]) fields)));
}
Aggregations