Home / Type/ ByteBufType Type — netty Architecture

ByteBufType Type — netty Architecture

Architecture documentation for the ByteBufType type/interface in ByteBufType.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  cdb1378e_81e6_5cdb_d772_2ec163216052["ByteBufType"]
  e4ed239c_7d81_05a1_9131_88b5adc51f6a["ByteBufType.java"]
  cdb1378e_81e6_5cdb_d772_2ec163216052 -->|defined in| e4ed239c_7d81_05a1_9131_88b5adc51f6a
  style cdb1378e_81e6_5cdb_d772_2ec163216052 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

microbench/src/main/java/io/netty/microbench/search/ByteBufType.java lines 22–52

public enum ByteBufType {
    HEAP {
        @Override
        ByteBuf newBuffer(byte[] bytes) {
            return Unpooled.wrappedBuffer(bytes, 0, bytes.length);
        }
    },
    COMPOSITE {
        @Override
        ByteBuf newBuffer(byte[] bytes) {
            CompositeByteBuf buf = Unpooled.compositeBuffer();
            int length = bytes.length;
            int offset = 0;
            int capacity = length / 8; // 8 buffers per composite

            while (length > 0) {
                buf.addComponent(true, Unpooled.wrappedBuffer(bytes, offset, Math.min(length, capacity)));
                length -= capacity;
                offset += capacity;
            }
            return buf;
        }
    },
    DIRECT {
        @Override
        ByteBuf newBuffer(byte[] bytes) {
            return Unpooled.directBuffer(bytes.length).writeBytes(bytes);
        }
    };
    abstract ByteBuf newBuffer(byte[] bytes);
}

Frequently Asked Questions

What is the ByteBufType type?
ByteBufType is a type/interface in the netty codebase, defined in microbench/src/main/java/io/netty/microbench/search/ByteBufType.java.
Where is ByteBufType defined?
ByteBufType is defined in microbench/src/main/java/io/netty/microbench/search/ByteBufType.java at line 22.

Analyze Your Own Codebase

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

Try Supermodel Free