Home / Type/ ByteBufType Type — netty Architecture

ByteBufType Type — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  1561ad02_6619_2db8_d40f_96f45f2f05d7["ByteBufType"]
  35bda7ea_11d0_140e_24ee_2d761506a72f["ByteBufUtilDecodeStringBenchmark.java"]
  1561ad02_6619_2db8_d40f_96f45f2f05d7 -->|defined in| 35bda7ea_11d0_140e_24ee_2d761506a72f
  style 1561ad02_6619_2db8_d40f_96f45f2f05d7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

microbench/src/main/java/io/netty/buffer/ByteBufUtilDecodeStringBenchmark.java lines 34–73

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

                while (length > 0) {
                    buffer.addComponent(true, Unpooled.wrappedBuffer(bytes, offset, Math.min(length, capacity)));
                    length -= capacity;
                    offset += capacity;
                }
                return buffer;
            }
        };

        abstract ByteBuf newBuffer(byte[] bytes, int length);
    }

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/buffer/ByteBufUtilDecodeStringBenchmark.java.
Where is ByteBufType defined?
ByteBufType is defined in microbench/src/main/java/io/netty/buffer/ByteBufUtilDecodeStringBenchmark.java at line 34.

Analyze Your Own Codebase

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

Try Supermodel Free