Home / Function/ testCollapse() — netty Function Reference

testCollapse() — netty Function Reference

Architecture documentation for the testCollapse() function in PooledByteBufAllocatorTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  cfef598c_108b_ac70_5f92_dc57caaddc6c["testCollapse()"]
  f8855572_2abf_1bf6_a32b_5cf6d1cf4947["PooledByteBufAllocatorTest"]
  cfef598c_108b_ac70_5f92_dc57caaddc6c -->|defined in| f8855572_2abf_1bf6_a32b_5cf6d1cf4947
  4e681469_9c14_67cb_5890_46b5d4b12dd2["PooledByteBufAllocator()"]
  cfef598c_108b_ac70_5f92_dc57caaddc6c -->|calls| 4e681469_9c14_67cb_5890_46b5d4b12dd2
  7eb106b2_cdf3_2750_a655_d411ed211f7c["unwrapIfNeeded()"]
  cfef598c_108b_ac70_5f92_dc57caaddc6c -->|calls| 7eb106b2_cdf3_2750_a655_d411ed211f7c
  style cfef598c_108b_ac70_5f92_dc57caaddc6c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java lines 284–316

    @Test
    public void testCollapse() {
        int pageSize = 8192;
        //no cache
        ByteBufAllocator allocator = new PooledByteBufAllocator(true, 1, 1, 8192, 9, 0, 0, 0);

        ByteBuf b1 = allocator.buffer(pageSize * 4);
        ByteBuf b2 = allocator.buffer(pageSize * 5);
        ByteBuf b3 = allocator.buffer(pageSize * 6);

        b2.release();
        b3.release();

        ByteBuf b4 = allocator.buffer(pageSize * 10);

        PooledByteBuf<ByteBuffer> b = unwrapIfNeeded(b4);

        //b2 and b3 are collapsed, b4 should start at offset 4
        assertEquals(4, runOffset(b.handle));
        assertEquals(10, runPages(b.handle));

        b1.release();
        b4.release();

        //all ByteBuf are collapsed, b5 should start at offset 0
        ByteBuf b5 = allocator.buffer(pageSize * 20);
        b = unwrapIfNeeded(b5);

        assertEquals(0, runOffset(b.handle));
        assertEquals(20, runPages(b.handle));

        b5.release();
    }

Domain

Subdomains

Frequently Asked Questions

What does testCollapse() do?
testCollapse() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java.
Where is testCollapse() defined?
testCollapse() is defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java at line 284.
What does testCollapse() call?
testCollapse() calls 2 function(s): PooledByteBufAllocator, unwrapIfNeeded.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free