use of org.apache.flink.table.data.writer.BinaryRowWriter in project flink by apache.
the class SortMergeJoinIteratorTest method newRow.
public BinaryRowData newRow(Integer i) {
BinaryRowData row = new BinaryRowData(1);
BinaryRowWriter writer = new BinaryRowWriter(row);
if (i != null) {
writer.writeInt(0, i);
} else {
writer.setNullAt(0);
}
writer.complete();
return row;
}
use of org.apache.flink.table.data.writer.BinaryRowWriter in project flink by apache.
the class BufferedKVExternalSorterTest method randomRow.
public static BinaryRowData randomRow(Random random, int stringLength) {
BinaryRowData row = new BinaryRowData(2);
BinaryRowWriter writer = new BinaryRowWriter(row);
writer.writeInt(0, random.nextInt());
writer.writeString(1, StringData.fromString(RandomStringUtils.random(stringLength)));
writer.complete();
return row;
}
use of org.apache.flink.table.data.writer.BinaryRowWriter 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.data.writer.BinaryRowWriter in project flink by apache.
the class CodeSplitTest method testProjection.
@SuppressWarnings("unchecked")
@Test
public void testProjection() {
int numFields = 1000;
RowType rowType = getIntRowType(numFields);
List<Integer> order = new ArrayList<>();
for (int i = 0; i < numFields; i++) {
order.add(i);
}
Collections.shuffle(order);
GenericRowData input = new GenericRowData(numFields);
for (int i = 0; i < numFields; i++) {
input.setField(i, i);
}
BinaryRowData output = new BinaryRowData(numFields);
BinaryRowWriter outputWriter = new BinaryRowWriter(output);
for (int i = 0; i < numFields; i++) {
outputWriter.writeInt(i, order.get(i));
}
outputWriter.complete();
Consumer<TableConfig> consumer = tableConfig -> {
Projection instance = ProjectionCodeGenerator.generateProjection(new CodeGeneratorContext(tableConfig), "", rowType, rowType, order.stream().mapToInt(i -> i).toArray()).newInstance(classLoader);
for (int i = 0; i < 100; i++) {
Assert.assertEquals(output, instance.apply(input));
}
};
runTest(consumer);
}
Aggregations