use of org.apache.flink.table.runtime.util.KeyValueIterator in project flink by apache.
the class BytesMultiMapTestBase method testBuildAndRetrieve.
// ------------------------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------------------------
@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(numMemSegments * PAGE_SIZE).build();
AbstractBytesMultiMap<K> table = createBytesMultiMap(memoryManager, memorySize, KEY_TYPES, VALUE_TYPES);
K[] keys = generateRandomKeys(NUM_ENTRIES / 10);
BinaryRowData[] values = genValues(NUM_VALUE_PER_KEY);
for (K key : keys) {
BytesMap.LookupInfo<K, Iterator<RowData>> lookupInfo;
for (BinaryRowData value : values) {
lookupInfo = table.lookup(key);
table.append(lookupInfo, value);
}
}
KeyValueIterator<K, Iterator<RowData>> iter = table.getEntryIterator(false);
while (iter.advanceNext()) {
int i = 0;
Iterator<RowData> valueIter = iter.getValue();
while (valueIter.hasNext()) {
Assert.assertEquals(valueIter.next(), values[i++]);
}
}
}
Aggregations