Home / Function/ decompose() — netty Function Reference

decompose() — netty Function Reference

Architecture documentation for the decompose() function in CompositeByteBuf.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  ec10a321_3746_2625_f943_7b713dc3b73d["decompose()"]
  6b8e4d93_5aed_4ff7_ccdd_9c021b0fe7d6["CompositeByteBuf"]
  ec10a321_3746_2625_f943_7b713dc3b73d -->|defined in| 6b8e4d93_5aed_4ff7_ccdd_9c021b0fe7d6
  56df3e62_e22d_e17d_1a00_60ba703c8e92["toComponentIndex0()"]
  ec10a321_3746_2625_f943_7b713dc3b73d -->|calls| 56df3e62_e22d_e17d_1a00_60ba703c8e92
  f3b514e7_34c9_d455_4036_4e2307c4dfb3["srcIdx()"]
  ec10a321_3746_2625_f943_7b713dc3b73d -->|calls| f3b514e7_34c9_d455_4036_4e2307c4dfb3
  79a833c5_92f9_7a41_19fc_646ea49cfaa3["length()"]
  ec10a321_3746_2625_f943_7b713dc3b73d -->|calls| 79a833c5_92f9_7a41_19fc_646ea49cfaa3
  style ec10a321_3746_2625_f943_7b713dc3b73d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java lines 722–759

    public List<ByteBuf> decompose(int offset, int length) {
        checkIndex(offset, length);
        if (length == 0) {
            return Collections.emptyList();
        }

        int componentId = toComponentIndex0(offset);
        int bytesToSlice = length;
        // The first component
        Component firstC = components[componentId];

        // It's important to use srcBuf and NOT buf as we need to return the "original" source buffer and not the
        // unwrapped one as otherwise we could loose the ability to correctly update the reference count on the
        // returned buffer.
        ByteBuf slice = firstC.srcBuf.slice(firstC.srcIdx(offset), Math.min(firstC.endOffset - offset, bytesToSlice));
        bytesToSlice -= slice.readableBytes();

        if (bytesToSlice == 0) {
            return Collections.singletonList(slice);
        }

        List<ByteBuf> sliceList = new ArrayList<ByteBuf>(componentCount - componentId);
        sliceList.add(slice);

        // Add all the slices until there is nothing more left and then return the List.
        do {
            Component component = components[++componentId];
            // It's important to use srcBuf and NOT buf as we need to return the "original" source buffer and not the
            // unwrapped one as otherwise we could loose the ability to correctly update the reference count on the
            // returned buffer.
            slice = component.srcBuf.slice(component.srcIdx(component.offset),
                    Math.min(component.length(), bytesToSlice));
            bytesToSlice -= slice.readableBytes();
            sliceList.add(slice);
        } while (bytesToSlice > 0);

        return sliceList;
    }

Domain

Subdomains

Frequently Asked Questions

What does decompose() do?
decompose() is a function in the netty codebase, defined in buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java.
Where is decompose() defined?
decompose() is defined in buffer/src/main/java/io/netty/buffer/CompositeByteBuf.java at line 722.
What does decompose() call?
decompose() calls 3 function(s): length, srcIdx, toComponentIndex0.

Analyze Your Own Codebase

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

Try Supermodel Free