Home / Function/ ByteBuf() — netty Function Reference

ByteBuf() — netty Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  b3efdd15_4c0c_d02e_84d6_27d3d3602708["ByteBuf()"]
  b937aa0f_a3c6_4d56_b7da_79ec59f96c8b["SpdyHeaderBlockJZlibEncoder"]
  b3efdd15_4c0c_d02e_84d6_27d3d3602708 -->|defined in| b937aa0f_a3c6_4d56_b7da_79ec59f96c8b
  753bdf9e_802b_a9ca_7897_9cc56d1189a3["setInput()"]
  b3efdd15_4c0c_d02e_84d6_27d3d3602708 -->|calls| 753bdf9e_802b_a9ca_7897_9cc56d1189a3
  style b3efdd15_4c0c_d02e_84d6_27d3d3602708 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockJZlibEncoder.java lines 82–122

    private ByteBuf encode(ByteBufAllocator alloc) {
        boolean release = true;
        ByteBuf out = null;
        try {
            int oldNextInIndex = z.next_in_index;
            int oldNextOutIndex = z.next_out_index;

            int maxOutputLength = (int) Math.ceil(z.next_in.length * 1.001) + 12;
            out = alloc.heapBuffer(maxOutputLength);
            z.next_out = out.array();
            z.next_out_index = out.arrayOffset() + out.writerIndex();
            z.avail_out = maxOutputLength;

            int resultCode;
            try {
                resultCode = z.deflate(JZlib.Z_SYNC_FLUSH);
            } finally {
                out.skipBytes(z.next_in_index - oldNextInIndex);
            }
            if (resultCode != JZlib.Z_OK) {
                throw new CompressionException("compression failure: " + resultCode);
            }

            int outputLength = z.next_out_index - oldNextOutIndex;
            if (outputLength > 0) {
                out.writerIndex(out.writerIndex() + outputLength);
            }
            release = false;
            return out;
        } finally {
            // Deference the external references explicitly to tell the VM that
            // the allocated byte arrays are temporary so that the call stack
            // can be utilized.
            // I'm not sure if the modern VMs do this optimization though.
            z.next_in = null;
            z.next_out = null;
            if (release && out != null) {
                out.release();
            }
        }
    }

Domain

Subdomains

Calls

Frequently Asked Questions

What does ByteBuf() do?
ByteBuf() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockJZlibEncoder.java.
Where is ByteBuf() defined?
ByteBuf() is defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdyHeaderBlockJZlibEncoder.java at line 82.
What does ByteBuf() call?
ByteBuf() calls 1 function(s): setInput.

Analyze Your Own Codebase

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

Try Supermodel Free