Search in sources :

Example 1 with LastUsedCompressionBufferPool

use of com.facebook.presto.orc.writer.CompressionBufferPool.LastUsedCompressionBufferPool in project presto by prestodb.

the class TestCompressionBufferPool method testLargeBuffer.

@Test
public void testLargeBuffer() {
    CompressionBufferPool bufferPool = new LastUsedCompressionBufferPool();
    byte[] buffer1 = bufferPool.checkOut(1000);
    verifyBuffer(buffer1, 1000);
    bufferPool.checkIn(buffer1);
    byte[] buffer2 = bufferPool.checkOut(500);
    assertSame(buffer1, buffer2);
    bufferPool.checkIn(buffer2);
    byte[] buffer3 = bufferPool.checkOut(2000);
    verifyBuffer(buffer3, 2000);
}
Also used : LastUsedCompressionBufferPool(com.facebook.presto.orc.writer.CompressionBufferPool.LastUsedCompressionBufferPool) LastUsedCompressionBufferPool(com.facebook.presto.orc.writer.CompressionBufferPool.LastUsedCompressionBufferPool) Test(org.testng.annotations.Test)

Example 2 with LastUsedCompressionBufferPool

use of com.facebook.presto.orc.writer.CompressionBufferPool.LastUsedCompressionBufferPool in project presto by prestodb.

the class TestCompressionBufferPool method testBufferReuse.

@Test
public void testBufferReuse() {
    CompressionBufferPool bufferPool = new LastUsedCompressionBufferPool();
    byte[] buffer1 = bufferPool.checkOut(0);
    verifyBuffer(buffer1, 0);
    bufferPool.checkIn(buffer1);
    byte[] buffer2 = bufferPool.checkOut(0);
    assertSame(buffer1, buffer2);
    // Do not checkIn buffer2, but ask for another buffer
    byte[] buffer3 = bufferPool.checkOut(0);
    assertNotSame(buffer1, buffer3);
    verifyBuffer(buffer3, 0);
    bufferPool.checkIn(buffer3);
}
Also used : LastUsedCompressionBufferPool(com.facebook.presto.orc.writer.CompressionBufferPool.LastUsedCompressionBufferPool) LastUsedCompressionBufferPool(com.facebook.presto.orc.writer.CompressionBufferPool.LastUsedCompressionBufferPool) Test(org.testng.annotations.Test)

Aggregations

LastUsedCompressionBufferPool (com.facebook.presto.orc.writer.CompressionBufferPool.LastUsedCompressionBufferPool)2 Test (org.testng.annotations.Test)2