public SpillSpaceTracker(DataSize maxSize)
    {
        requireNonNull(maxSize, "maxSize is null");
        maxBytes = maxSize.toBytes();
        currentBytes = 0;
    }
@Test
    public void testSpillSpaceTracker()
    {
        assertEquals(spillSpaceTracker.getCurrentBytes(), 0);
        assertEquals(spillSpaceTracker.getMaxBytes(), MAX_DATA_SIZE.toBytes());
        long reservedBytes = new DataSize(5, MEGABYTE).toBytes();
        spillSpaceTracker.reserve(reservedBytes);
        assertEquals(spillSpaceTracker.getCurrentBytes(), reservedBytes);

        long otherReservedBytes = new DataSize(2, MEGABYTE).toBytes();
        spillSpaceTracker.reserve(otherReservedBytes);
        assertEquals(spillSpaceTracker.getCurrentBytes(), (reservedBytes + otherReservedBytes));

        spillSpaceTracker.reserve(otherReservedBytes);
        assertEquals(spillSpaceTracker.getCurrentBytes(), (reservedBytes + 2 * otherReservedBytes));

        spillSpaceTracker.free(otherReservedBytes);
        spillSpaceTracker.free(otherReservedBytes);
        assertEquals(spillSpaceTracker.getCurrentBytes(), reservedBytes);

        spillSpaceTracker.free(reservedBytes);
        assertEquals(spillSpaceTracker.getCurrentBytes(), 0);
    }