Home / Function/ encode() — netty Function Reference

encode() — netty Function Reference

Architecture documentation for the encode() function in BrotliEncoder.java from the netty codebase.

Function java Buffer Allocators calls 3 called by 2

Entity Profile

Dependency Diagram

graph TD
  986db13a_14ff_be0b_4d9e_590235a9bd16["encode()"]
  64c539b4_9d62_5673_892e_728dc5998630["Writer"]
  986db13a_14ff_be0b_4d9e_590235a9bd16 -->|defined in| 64c539b4_9d62_5673_892e_728dc5998630
  f1f60259_b8b8_2579_82be_39debafacd41["encode()"]
  f1f60259_b8b8_2579_82be_39debafacd41 -->|calls| 986db13a_14ff_be0b_4d9e_590235a9bd16
  aa67448e_54be_ac4a_4841_131ae7dc2553["ByteBuf()"]
  aa67448e_54be_ac4a_4841_131ae7dc2553 -->|calls| 986db13a_14ff_be0b_4d9e_590235a9bd16
  f1f60259_b8b8_2579_82be_39debafacd41["encode()"]
  986db13a_14ff_be0b_4d9e_590235a9bd16 -->|calls| f1f60259_b8b8_2579_82be_39debafacd41
  d056c373_d9ff_face_c66b_749abde43b73["allocate()"]
  986db13a_14ff_be0b_4d9e_590235a9bd16 -->|calls| d056c373_d9ff_face_c66b_749abde43b73
  fa8504eb_9619_5a41_f2aa_6fadb976fae6["write()"]
  986db13a_14ff_be0b_4d9e_590235a9bd16 -->|calls| fa8504eb_9619_5a41_f2aa_6fadb976fae6
  style 986db13a_14ff_be0b_4d9e_590235a9bd16 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-compression/src/main/java/io/netty/handler/codec/compression/BrotliEncoder.java lines 198–218

        private void encode(ByteBuf msg, boolean preferDirect) throws Exception {
            try {
                allocate(preferDirect);

                // Compress data and flush it into Buffer.
                //
                // As soon as we call flush, Encoder will be triggered to write encoded
                // data into WritableByteChannel.
                //
                // A race condition will not arise because one flush call to encoder will result
                // in only 1 call at `write(ByteBuffer)`.
                ByteBuffer nioBuffer = CompressionUtil.safeReadableNioBuffer(msg);
                int position = nioBuffer.position();
                brotliEncoderChannel.write(nioBuffer);
                msg.skipBytes(nioBuffer.position() - position);
                brotliEncoderChannel.flush();
            } catch (Exception e) {
                ReferenceCountUtil.release(msg);
                throw e;
            }
        }

Domain

Subdomains

Called By

Frequently Asked Questions

What does encode() do?
encode() is a function in the netty codebase, defined in codec-compression/src/main/java/io/netty/handler/codec/compression/BrotliEncoder.java.
Where is encode() defined?
encode() is defined in codec-compression/src/main/java/io/netty/handler/codec/compression/BrotliEncoder.java at line 198.
What does encode() call?
encode() calls 3 function(s): allocate, encode, write.
What calls encode()?
encode() is called by 2 function(s): ByteBuf, encode.

Analyze Your Own Codebase

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

Try Supermodel Free