Home / Type/ ByteBufType Type — netty Architecture

ByteBufType Type — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  2bd4af0f_07cf_5ca6_c043_eda23b4b7310["ByteBufType"]
  10c8755a_065a_38c1_c0ef_5adfa9694f2a["AbstractByteBufGetCharSequenceBenchmark.java"]
  2bd4af0f_07cf_5ca6_c043_eda23b4b7310 -->|defined in| 10c8755a_065a_38c1_c0ef_5adfa9694f2a
  style 2bd4af0f_07cf_5ca6_c043_eda23b4b7310 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

microbench/src/main/java/io/netty/buffer/AbstractByteBufGetCharSequenceBenchmark.java lines 35–98

    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);
            }
        },
        POOLED_HEAP {
            @Override
            ByteBuf newBuffer(byte[] bytes, int length) {
                return PooledByteBufAllocator.DEFAULT.heapBuffer(length).writeBytes(bytes, 0, length);
            }
        },
        POOLED_DIRECT {
            @Override
            ByteBuf newBuffer(byte[] bytes, int length) {
                return PooledByteBufAllocator.DEFAULT.directBuffer(length).writeBytes(bytes, 0, length);
            }
        },
        ADAPTIVE_HEAP {
            @Override
            ByteBuf newBuffer(byte[] bytes, int length) {
                return ADAPTIVE_ALLOC.heapBuffer(length).writeBytes(bytes, 0, length);
            }
        },
        ADAPTIVE_DIRECT {
            @Override
            ByteBuf newBuffer(byte[] bytes, int length) {
                return ADAPTIVE_ALLOC.directBuffer(length).writeBytes(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/AbstractByteBufGetCharSequenceBenchmark.java.
Where is ByteBufType defined?
ByteBufType is defined in microbench/src/main/java/io/netty/buffer/AbstractByteBufGetCharSequenceBenchmark.java at line 35.

Analyze Your Own Codebase

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

Try Supermodel Free