flushBufferedData() — netty Function Reference
Architecture documentation for the flushBufferedData() function in Lz4FrameEncoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 159fbf77_5b7d_bd62_3287_8d2df4c59091["flushBufferedData()"] 4a29aef3_e017_5f9e_e255_496a25a8988e["Lz4FrameEncoder"] 159fbf77_5b7d_bd62_3287_8d2df4c59091 -->|defined in| 4a29aef3_e017_5f9e_e255_496a25a8988e 2f6f9195_61e1_597f_53c0_b36ef1d7b36a["encode()"] 2f6f9195_61e1_597f_53c0_b36ef1d7b36a -->|calls| 159fbf77_5b7d_bd62_3287_8d2df4c59091 685f3ff0_d3ac_dc7e_e9b8_0f821240ad37["flush()"] 685f3ff0_d3ac_dc7e_e9b8_0f821240ad37 -->|calls| 159fbf77_5b7d_bd62_3287_8d2df4c59091 d42f2a9d_aec3_3afd_815f_5642220dd27c["ChannelFuture()"] d42f2a9d_aec3_3afd_815f_5642220dd27c -->|calls| 159fbf77_5b7d_bd62_3287_8d2df4c59091 2f6f9195_61e1_597f_53c0_b36ef1d7b36a["encode()"] 159fbf77_5b7d_bd62_3287_8d2df4c59091 -->|calls| 2f6f9195_61e1_597f_53c0_b36ef1d7b36a style 159fbf77_5b7d_bd62_3287_8d2df4c59091 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-compression/src/main/java/io/netty/handler/codec/compression/Lz4FrameEncoder.java lines 256–294
private void flushBufferedData(ByteBuf out) {
int flushableBytes = buffer.readableBytes();
if (flushableBytes == 0) {
return;
}
checksum.reset();
checksum.update(buffer, buffer.readerIndex(), flushableBytes);
final int check = (int) checksum.getValue();
final int bufSize = compressor.maxCompressedLength(flushableBytes) + HEADER_LENGTH;
out.ensureWritable(bufSize);
final int idx = out.writerIndex();
int compressedLength;
try {
ByteBuffer outNioBuffer = out.internalNioBuffer(idx + HEADER_LENGTH, out.writableBytes() - HEADER_LENGTH);
int pos = outNioBuffer.position();
// We always want to start at position 0 as we take care of reusing the buffer in the encode(...) loop.
compressor.compress(buffer.internalNioBuffer(buffer.readerIndex(), flushableBytes), outNioBuffer);
compressedLength = outNioBuffer.position() - pos;
} catch (LZ4Exception e) {
throw new CompressionException(e);
}
final int blockType;
if (compressedLength >= flushableBytes) {
blockType = BLOCK_TYPE_NON_COMPRESSED;
compressedLength = flushableBytes;
out.setBytes(idx + HEADER_LENGTH, buffer, buffer.readerIndex(), flushableBytes);
} else {
blockType = BLOCK_TYPE_COMPRESSED;
}
out.setLong(idx, MAGIC_NUMBER);
out.setByte(idx + TOKEN_OFFSET, (byte) (blockType | compressionLevel));
out.setIntLE(idx + COMPRESSED_LENGTH_OFFSET, compressedLength);
out.setIntLE(idx + DECOMPRESSED_LENGTH_OFFSET, flushableBytes);
out.setIntLE(idx + CHECKSUM_OFFSET, check);
out.writerIndex(idx + HEADER_LENGTH + compressedLength);
buffer.clear();
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does flushBufferedData() do?
flushBufferedData() is a function in the netty codebase, defined in codec-compression/src/main/java/io/netty/handler/codec/compression/Lz4FrameEncoder.java.
Where is flushBufferedData() defined?
flushBufferedData() is defined in codec-compression/src/main/java/io/netty/handler/codec/compression/Lz4FrameEncoder.java at line 256.
What does flushBufferedData() call?
flushBufferedData() calls 1 function(s): encode.
What calls flushBufferedData()?
flushBufferedData() is called by 3 function(s): ChannelFuture, encode, flush.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free