use of org.apache.flink.types.ByteValue 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();
}
}
use of org.apache.flink.types.ByteValue in project flink by apache.
the class ByteValueComparatorTest method getSortedTestData.
@Override
protected ByteValue[] getSortedTestData() {
Random rnd = new Random(874597969123412338L);
int rndByte = rnd.nextInt(Byte.MAX_VALUE);
if (rndByte < 0) {
rndByte = -rndByte;
}
if (rndByte == Byte.MAX_VALUE) {
rndByte -= 3;
}
if (rndByte <= 2) {
rndByte += 3;
}
return new ByteValue[] { new ByteValue(Byte.MIN_VALUE), new ByteValue(Integer.valueOf(-rndByte).byteValue()), new ByteValue(Integer.valueOf(-1).byteValue()), new ByteValue(Integer.valueOf(0).byteValue()), new ByteValue(Integer.valueOf(1).byteValue()), new ByteValue(Integer.valueOf(2).byteValue()), new ByteValue(Integer.valueOf(rndByte).byteValue()), new ByteValue(Byte.MAX_VALUE) };
}
use of org.apache.flink.types.ByteValue in project flink by apache.
the class ByteValueComparator method compareToReference.
@Override
public int compareToReference(TypeComparator<ByteValue> referencedComparator) {
ByteValue otherRef = ((ByteValueComparator) referencedComparator).reference;
int comp = otherRef.compareTo(reference);
return ascendingComparison ? comp : -comp;
}
use of org.apache.flink.types.ByteValue in project flink by apache.
the class ByteValueSerializerTest method getTestData.
@Override
protected ByteValue[] getTestData() {
Random rnd = new Random(874597969123412341L);
byte[] byteArray = new byte[1];
rnd.nextBytes(byteArray);
return new ByteValue[] { new ByteValue((byte) 0), new ByteValue((byte) 1), new ByteValue((byte) -1), new ByteValue(Byte.MAX_VALUE), new ByteValue(Byte.MIN_VALUE), new ByteValue(byteArray[0]), new ByteValue((byte) -byteArray[0]) };
}
Aggregations