Bzip2HuffmanAllocator Class — netty Architecture
Architecture documentation for the Bzip2HuffmanAllocator class in Bzip2HuffmanAllocator.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 3ede8457_e9d7_5e55_8fd7_02b725a73605["Bzip2HuffmanAllocator"] 328dbacc_46be_83a4_62c6_00e0c5fa776e["Bzip2HuffmanAllocator.java"] 3ede8457_e9d7_5e55_8fd7_02b725a73605 -->|defined in| 328dbacc_46be_83a4_62c6_00e0c5fa776e 9ea0eddc_76b9_92b2_0ab9_81aa6582f3b6["first()"] 3ede8457_e9d7_5e55_8fd7_02b725a73605 -->|method| 9ea0eddc_76b9_92b2_0ab9_81aa6582f3b6 21a7e6f4_2182_ef35_16b7_26d7774b9f85["setExtendedParentPointers()"] 3ede8457_e9d7_5e55_8fd7_02b725a73605 -->|method| 21a7e6f4_2182_ef35_16b7_26d7774b9f85 536a1061_cf34_c364_3957_752998cccfb4["findNodesToRelocate()"] 3ede8457_e9d7_5e55_8fd7_02b725a73605 -->|method| 536a1061_cf34_c364_3957_752998cccfb4 a7f0d7e8_8c26_ba76_56bf_1426cfcf43d0["allocateNodeLengths()"] 3ede8457_e9d7_5e55_8fd7_02b725a73605 -->|method| a7f0d7e8_8c26_ba76_56bf_1426cfcf43d0 313bded7_9d4e_2a33_2056_0b95ca399438["allocateNodeLengthsWithRelocation()"] 3ede8457_e9d7_5e55_8fd7_02b725a73605 -->|method| 313bded7_9d4e_2a33_2056_0b95ca399438 2de6ad84_ece2_e1f6_0d2d_5992144ef04b["allocateHuffmanCodeLengths()"] 3ede8457_e9d7_5e55_8fd7_02b725a73605 -->|method| 2de6ad84_ece2_e1f6_0d2d_5992144ef04b 82d9ab6c_64b1_df54_2880_eab242c7db7a["Bzip2HuffmanAllocator()"] 3ede8457_e9d7_5e55_8fd7_02b725a73605 -->|method| 82d9ab6c_64b1_df54_2880_eab242c7db7a
Relationship Graph
Source Code
codec-compression/src/main/java/io/netty/handler/codec/compression/Bzip2HuffmanAllocator.java lines 25–184
final class Bzip2HuffmanAllocator {
/**
* @param array The code length array
* @param i The input position
* @param nodesToMove The number of internal nodes to be relocated
* @return The smallest {@code k} such that {@code nodesToMove <= k <= i} and
* {@code i <= (array[k] % array.length)}
*/
private static int first(final int[] array, int i, final int nodesToMove) {
final int length = array.length;
final int limit = i;
int k = array.length - 2;
while (i >= nodesToMove && array[i] % length > limit) {
k = i;
i -= limit - i + 1;
}
i = Math.max(nodesToMove - 1, i);
while (k > i + 1) {
int temp = i + k >>> 1;
if (array[temp] % length > limit) {
k = temp;
} else {
i = temp;
}
}
return k;
}
/**
* Fills the code array with extended parent pointers.
* @param array The code length array
*/
private static void setExtendedParentPointers(final int[] array) {
final int length = array.length;
array[0] += array[1];
for (int headNode = 0, tailNode = 1, topNode = 2; tailNode < length - 1; tailNode++) {
int temp;
if (topNode >= length || array[headNode] < array[topNode]) {
temp = array[headNode];
array[headNode++] = tailNode;
} else {
temp = array[topNode++];
}
if (topNode >= length || (headNode < tailNode && array[headNode] < array[topNode])) {
temp += array[headNode];
array[headNode++] = tailNode + length;
} else {
temp += array[topNode++];
}
array[tailNode] = temp;
}
}
/**
* Finds the number of nodes to relocate in order to achieve a given code length limit.
* @param array The code length array
* @param maximumLength The maximum bit length for the generated codes
* @return The number of nodes to relocate
*/
private static int findNodesToRelocate(final int[] array, final int maximumLength) {
int currentNode = array.length - 2;
for (int currentDepth = 1; currentDepth < maximumLength - 1 && currentNode > 1; currentDepth++) {
currentNode = first(array, currentNode - 1, 0);
}
return currentNode;
}
/**
* A final allocation pass with no code length limit.
* @param array The code length array
*/
private static void allocateNodeLengths(final int[] array) {
int firstNode = array.length - 2;
int nextNode = array.length - 1;
for (int currentDepth = 1, availableNodes = 2; availableNodes > 0; currentDepth++) {
final int lastNode = firstNode;
Defined In
Source
Frequently Asked Questions
What is the Bzip2HuffmanAllocator class?
Bzip2HuffmanAllocator is a class in the netty codebase, defined in codec-compression/src/main/java/io/netty/handler/codec/compression/Bzip2HuffmanAllocator.java.
Where is Bzip2HuffmanAllocator defined?
Bzip2HuffmanAllocator is defined in codec-compression/src/main/java/io/netty/handler/codec/compression/Bzip2HuffmanAllocator.java at line 25.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free