Home / Function/ testAllocateSmallOffset() — netty Function Reference

testAllocateSmallOffset() — netty Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java lines 318–357

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

        int size = pageSize * 5;

        ByteBuf[] bufs = new ByteBuf[10];
        for (int i = 0; i < 10; i++) {
            bufs[i] = allocator.buffer(size);
        }

        for (int i = 0; i < 5; i++) {
            bufs[i].release();
        }

        //make sure we always allocate runs with small offset
        for (int i = 0; i < 5; i++) {
            ByteBuf buf = allocator.buffer(size);
            PooledByteBuf<ByteBuffer> unwrapedBuf = unwrapIfNeeded(buf);
            assertEquals(runOffset(unwrapedBuf.handle), i * 5);
            bufs[i] = buf;
        }

        //release at reverse order
        for (int i = 10 - 1; i >= 5; i--) {
            bufs[i].release();
        }

        for (int i = 5; i < 10; i++) {
            ByteBuf buf = allocator.buffer(size);
            PooledByteBuf<ByteBuffer> unwrapedBuf = unwrapIfNeeded(buf);
            assertEquals(runOffset(unwrapedBuf.handle), i * 5);
            bufs[i] = buf;
        }

        for (int i = 0; i < 10; i++) {
            bufs[i].release();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testAllocateSmallOffset() do?
testAllocateSmallOffset() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java.
Where is testAllocateSmallOffset() defined?
testAllocateSmallOffset() is defined in buffer/src/test/java/io/netty/buffer/PooledByteBufAllocatorTest.java at line 318.
What does testAllocateSmallOffset() call?
testAllocateSmallOffset() 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