use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.
the class HeapWindowsGroupingTest method processTriggerWindow.
private void processTriggerWindow(List<List<Long>> actual, List<TimeWindow> windows, HeapWindowsGrouping grouping) {
while (grouping.hasTriggerWindow()) {
RowIterator<BinaryRowData> iter = grouping.buildTriggerWindowElementsIterator();
TimeWindow window = grouping.getTriggerWindow();
List<Long> buffer = new ArrayList<>();
while (iter.advanceNext()) {
buffer.add(iter.getRow().getLong(0));
}
if (!buffer.isEmpty()) {
actual.add(buffer);
windows.add(window);
}
}
}
use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.
the class StreamRecordUtils method binaryRecord.
/**
* Creates n new {@link StreamRecord} of {@link BinaryRowData} based on the given fields array
* and the given RowKind.
*/
public static StreamRecord<RowData> binaryRecord(RowKind rowKind, Object... fields) {
BinaryRowData row = binaryrow(fields);
row.setRowKind(rowKind);
return new StreamRecord<>(row);
}
use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.
the class UniformBinaryRowGenerator method next.
@Override
public BinaryRowData next() {
key = new IntValue();
value = new IntValue();
return next(new BinaryRowData(2));
}
use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.
the class BytesHashMapTestBase method testBuildAndRetrieve.
@Test
public void testBuildAndRetrieve() throws Exception {
final int numMemSegments = needNumMemSegments(NUM_ENTRIES, rowLength(RowType.of(VALUE_TYPES)), rowLength(RowType.of(KEY_TYPES)), PAGE_SIZE);
int memorySize = numMemSegments * PAGE_SIZE;
MemoryManager memoryManager = MemoryManagerBuilder.newBuilder().setMemorySize(memorySize).build();
AbstractBytesHashMap<K> table = createBytesHashMap(memoryManager, memorySize, KEY_TYPES, VALUE_TYPES);
K[] keys = generateRandomKeys(NUM_ENTRIES);
List<BinaryRowData> expected = new ArrayList<>(NUM_ENTRIES);
verifyInsert(keys, expected, table);
verifyRetrieve(table, keys, expected);
table.free();
}
use of org.apache.flink.table.data.binary.BinaryRowData in project flink by apache.
the class BytesHashMapTestBase method verifyInsertAndUpdate.
private void verifyInsertAndUpdate(K[] keys, List<BinaryRowData> inserted, AbstractBytesHashMap<K> table) throws IOException {
final Random rnd = new Random(RANDOM_SEED);
for (int i = 0; i < NUM_ENTRIES; i++) {
K groupKey = keys[i];
// look up and insert
BytesMap.LookupInfo<K, BinaryRowData> lookupInfo = table.lookup(groupKey);
Assert.assertFalse(lookupInfo.isFound());
BinaryRowData entry = table.append(lookupInfo, defaultValue);
Assert.assertNotNull(entry);
// mock multiple updates
for (int j = 0; j < NUM_REWRITES; j++) {
updateOutputBuffer(entry, rnd);
}
inserted.add(entry.copy());
}
Assert.assertEquals(NUM_ENTRIES, table.getNumElements());
}
Aggregations