Home / Function/ ByteBuf() — netty Function Reference

ByteBuf() — netty Function Reference

Architecture documentation for the ByteBuf() function in AdaptivePoolingAllocator.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  9928adc3_c1c7_6145_dd14_c9c1e6101da8["ByteBuf()"]
  e9381b1a_dc06_843c_be7e_5e0eddee4a3a["AdaptiveByteBuf"]
  9928adc3_c1c7_6145_dd14_c9c1e6101da8 -->|defined in| e9381b1a_dc06_843c_be7e_5e0eddee4a3a
  1ffe8f20_ccfd_e36a_bc9a_a6eac8ef4ccf["reallocate()"]
  9928adc3_c1c7_6145_dd14_c9c1e6101da8 -->|calls| 1ffe8f20_ccfd_e36a_bc9a_a6eac8ef4ccf
  57c1d4e8_2f83_03da_aa55_345ed2144af3["getBytes()"]
  9928adc3_c1c7_6145_dd14_c9c1e6101da8 -->|calls| 57c1d4e8_2f83_03da_aa55_345ed2144af3
  ef722249_476f_4a76_c1e0_45de8d8d8a4a["idx()"]
  9928adc3_c1c7_6145_dd14_c9c1e6101da8 -->|calls| ef722249_476f_4a76_c1e0_45de8d8d8a4a
  c4507935_a46f_63d6_724d_0b79ac9627bd["setBytes()"]
  9928adc3_c1c7_6145_dd14_c9c1e6101da8 -->|calls| c4507935_a46f_63d6_724d_0b79ac9627bd
  40622caf_e835_f15f_b02b_5d52243a6fae["hasArray()"]
  9928adc3_c1c7_6145_dd14_c9c1e6101da8 -->|calls| 40622caf_e835_f15f_b02b_5d52243a6fae
  0d87a4f6_817c_89dc_baee_630435215d14["capacity()"]
  9928adc3_c1c7_6145_dd14_c9c1e6101da8 -->|calls| 0d87a4f6_817c_89dc_baee_630435215d14
  f1f91104_8721_329c_3138_235bb4f03863["releaseSegment()"]
  9928adc3_c1c7_6145_dd14_c9c1e6101da8 -->|calls| f1f91104_8721_329c_3138_235bb4f03863
  style 9928adc3_c1c7_6145_dd14_c9c1e6101da8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java lines 1598–1638

        @Override
        public ByteBuf capacity(int newCapacity) {
            if (length <= newCapacity && newCapacity <= maxFastCapacity) {
                ensureAccessible();
                length = newCapacity;
                return this;
            }
            checkNewCapacity(newCapacity);
            if (newCapacity < capacity()) {
                length = newCapacity;
                trimIndicesToCapacity(newCapacity);
                return this;
            }

            if (PlatformDependent.isJfrEnabled() && ReallocateBufferEvent.isEventEnabled()) {
                ReallocateBufferEvent event = new ReallocateBufferEvent();
                if (event.shouldCommit()) {
                    event.fill(this, AdaptiveByteBufAllocator.class);
                    event.newCapacity = newCapacity;
                    event.commit();
                }
            }

            // Reallocation required.
            Chunk chunk = this.chunk;
            AdaptivePoolingAllocator allocator = chunk.allocator;
            int readerIndex = this.readerIndex;
            int writerIndex = this.writerIndex;
            int baseOldRootIndex = startIndex;
            int oldLength = length;
            int oldCapacity = maxFastCapacity;
            AbstractByteBuf oldRoot = rootParent();
            allocator.reallocate(newCapacity, maxCapacity(), this);
            oldRoot.getBytes(baseOldRootIndex, this, 0, oldLength);
            chunk.releaseSegment(baseOldRootIndex, oldCapacity);
            assert oldCapacity < maxFastCapacity && newCapacity <= maxFastCapacity:
                    "Capacity increase failed";
            this.readerIndex = readerIndex;
            this.writerIndex = writerIndex;
            return this;
        }

Domain

Subdomains

Frequently Asked Questions

What does ByteBuf() do?
ByteBuf() is a function in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java.
Where is ByteBuf() defined?
ByteBuf() is defined in buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java at line 1598.
What does ByteBuf() call?
ByteBuf() calls 7 function(s): capacity, getBytes, hasArray, idx, reallocate, releaseSegment, setBytes.

Analyze Your Own Codebase

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

Try Supermodel Free