Search in sources :

Example 1 with ValueComparator

use of org.apache.flink.api.java.typeutils.runtime.ValueComparator in project flink by apache.

the class HashTableTest method testSpillingFreesOnlyOverflowSegments.

/**
	 * This tests the case where no additional partition buffers are used at the point when spilling
	 * is triggered, testing that overflow bucket buffers are taken into account when deciding which
	 * partition to spill.
	 */
@Test
public void testSpillingFreesOnlyOverflowSegments() {
    final IOManager ioMan = new IOManagerAsync();
    final TypeSerializer<ByteValue> serializer = ByteValueSerializer.INSTANCE;
    final TypeComparator<ByteValue> buildComparator = new ValueComparator<>(true, ByteValue.class);
    final TypeComparator<ByteValue> probeComparator = new ValueComparator<>(true, ByteValue.class);
    @SuppressWarnings("unchecked") final TypePairComparator<ByteValue, ByteValue> pairComparator = Mockito.mock(TypePairComparator.class);
    try {
        final int pageSize = 32 * 1024;
        final int numSegments = 34;
        List<MemorySegment> memory = getMemory(numSegments, pageSize);
        MutableHashTable<ByteValue, ByteValue> table = new MutableHashTable<>(serializer, serializer, buildComparator, probeComparator, pairComparator, memory, ioMan, 1, false);
        table.open(new ByteValueIterator(100000000), new ByteValueIterator(1));
        table.close();
        checkNoTempFilesRemain(ioMan);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    } finally {
        ioMan.shutdown();
    }
}
Also used : ByteValue(org.apache.flink.types.ByteValue) IOManager(org.apache.flink.runtime.io.disk.iomanager.IOManager) ValueComparator(org.apache.flink.api.java.typeutils.runtime.ValueComparator) MemorySegment(org.apache.flink.core.memory.MemorySegment) IOException(java.io.IOException) IOManagerAsync(org.apache.flink.runtime.io.disk.iomanager.IOManagerAsync) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 ValueComparator (org.apache.flink.api.java.typeutils.runtime.ValueComparator)1 MemorySegment (org.apache.flink.core.memory.MemorySegment)1 IOManager (org.apache.flink.runtime.io.disk.iomanager.IOManager)1 IOManagerAsync (org.apache.flink.runtime.io.disk.iomanager.IOManagerAsync)1 ByteValue (org.apache.flink.types.ByteValue)1 Test (org.junit.Test)1