Home / Function/ testMaxFastWritableBytes() — netty Function Reference

testMaxFastWritableBytes() — netty Function Reference

Architecture documentation for the testMaxFastWritableBytes() function in AbstractPooledByteBufTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  171cd40c_02a0_7ed0_1483_5e748559f459["testMaxFastWritableBytes()"]
  0134bc31_3b19_a967_d2aa_113b2ccd098c["AbstractPooledByteBufTest"]
  171cd40c_02a0_7ed0_1483_5e748559f459 -->|defined in| 0134bc31_3b19_a967_d2aa_113b2ccd098c
  b8bc1e06_1910_c817_ce88_108d0c0e3922["pooledByteBuf()"]
  171cd40c_02a0_7ed0_1483_5e748559f459 -->|calls| b8bc1e06_1910_c817_ce88_108d0c0e3922
  style 171cd40c_02a0_7ed0_1483_5e748559f459 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/test/java/io/netty/buffer/AbstractPooledByteBufTest.java lines 68–96

    @Override
    @Test
    public void testMaxFastWritableBytes() {
        ByteBuf buffer = newBuffer(150, 500).writerIndex(100);
        assertEquals(50, buffer.writableBytes());
        assertEquals(150, buffer.capacity());
        assertEquals(500, buffer.maxCapacity());
        assertEquals(400, buffer.maxWritableBytes());

        int chunkSize = pooledByteBuf(buffer).maxLength;
        assertTrue(chunkSize >= 150);
        int remainingInAlloc = Math.min(chunkSize - 100, 400);
        assertEquals(remainingInAlloc, buffer.maxFastWritableBytes());

        // write up to max, chunk alloc should not change (same handle)
        long handleBefore = pooledByteBuf(buffer).handle;
        buffer.writeBytes(new byte[remainingInAlloc]);
        assertEquals(handleBefore, pooledByteBuf(buffer).handle);

        assertEquals(0, buffer.maxFastWritableBytes());
        // writing one more should trigger a reallocation (new handle)
        buffer.writeByte(7);
        assertNotEquals(handleBefore, pooledByteBuf(buffer).handle);

        // should not exceed maxCapacity even if chunk alloc does
        buffer.capacity(500);
        assertEquals(500 - buffer.writerIndex(), buffer.maxFastWritableBytes());
        buffer.release();
    }

Domain

Subdomains

Frequently Asked Questions

What does testMaxFastWritableBytes() do?
testMaxFastWritableBytes() is a function in the netty codebase, defined in buffer/src/test/java/io/netty/buffer/AbstractPooledByteBufTest.java.
Where is testMaxFastWritableBytes() defined?
testMaxFastWritableBytes() is defined in buffer/src/test/java/io/netty/buffer/AbstractPooledByteBufTest.java at line 68.
What does testMaxFastWritableBytes() call?
testMaxFastWritableBytes() calls 1 function(s): pooledByteBuf.

Analyze Your Own Codebase

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

Try Supermodel Free