HpackDynamicTable Class — netty Architecture
Architecture documentation for the HpackDynamicTable class in HpackDynamicTable.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD feed71e9_4455_9bda_6187_d37edd627c61["HpackDynamicTable"] fac22d78_3ef1_eb32_74eb_9f9a92850599["HpackDynamicTable.java"] feed71e9_4455_9bda_6187_d37edd627c61 -->|defined in| fac22d78_3ef1_eb32_74eb_9f9a92850599 dadc6b8a_e343_c864_4e2a_037e0d00e2e2["HpackDynamicTable()"] feed71e9_4455_9bda_6187_d37edd627c61 -->|method| dadc6b8a_e343_c864_4e2a_037e0d00e2e2 d5ad6030_d26c_c0ab_aa8c_77ac80f9a8b6["length()"] feed71e9_4455_9bda_6187_d37edd627c61 -->|method| d5ad6030_d26c_c0ab_aa8c_77ac80f9a8b6 2e5bce26_eedf_4583_6e33_38cb076d86e6["size()"] feed71e9_4455_9bda_6187_d37edd627c61 -->|method| 2e5bce26_eedf_4583_6e33_38cb076d86e6 e6058ea2_7dc3_049d_cb14_071be4661f83["capacity()"] feed71e9_4455_9bda_6187_d37edd627c61 -->|method| e6058ea2_7dc3_049d_cb14_071be4661f83 e2aac505_a762_df0f_db79_55d35adf0f2b["HpackHeaderField()"] feed71e9_4455_9bda_6187_d37edd627c61 -->|method| e2aac505_a762_df0f_db79_55d35adf0f2b 21867544_ab89_d7b1_f726_8379f4db34b6["add()"] feed71e9_4455_9bda_6187_d37edd627c61 -->|method| 21867544_ab89_d7b1_f726_8379f4db34b6 61b2a680_e65a_da65_797a_cdbf7d0f1757["clear()"] feed71e9_4455_9bda_6187_d37edd627c61 -->|method| 61b2a680_e65a_da65_797a_cdbf7d0f1757 6eb146ec_7738_9327_a090_71feef80629d["setCapacity()"] feed71e9_4455_9bda_6187_d37edd627c61 -->|method| 6eb146ec_7738_9327_a090_71feef80629d
Relationship Graph
Source Code
codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDynamicTable.java lines 37–201
final class HpackDynamicTable {
// a circular queue of header fields
HpackHeaderField[] hpackHeaderFields;
int head;
int tail;
private long size;
private long capacity = -1; // ensure setCapacity creates the array
/**
* Creates a new dynamic table with the specified initial capacity.
*/
HpackDynamicTable(long initialCapacity) {
setCapacity(initialCapacity);
}
/**
* Return the number of header fields in the dynamic table.
*/
public int length() {
int length;
if (head < tail) {
length = hpackHeaderFields.length - tail + head;
} else {
length = head - tail;
}
return length;
}
/**
* Return the current size of the dynamic table. This is the sum of the size of the entries.
*/
public long size() {
return size;
}
/**
* Return the maximum allowable size of the dynamic table.
*/
public long capacity() {
return capacity;
}
/**
* Return the header field at the given index. The first and newest entry is always at index 1,
* and the oldest entry is at the index length().
*/
public HpackHeaderField getEntry(int index) {
if (index <= 0 || index > length()) {
throw new IndexOutOfBoundsException("Index " + index + " out of bounds for length " + length());
}
int i = head - index;
if (i < 0) {
return hpackHeaderFields[i + hpackHeaderFields.length];
} else {
return hpackHeaderFields[i];
}
}
/**
* Add the header field to the dynamic table. Entries are evicted from the dynamic table until
* the size of the table and the new header field is less than or equal to the table's capacity.
* If the size of the new entry is larger than the table's capacity, the dynamic table will be
* cleared.
*/
public void add(HpackHeaderField header) {
int headerSize = header.size();
if (headerSize > capacity) {
clear();
return;
}
while (capacity - size < headerSize) {
remove();
}
hpackHeaderFields[head++] = header;
size += headerSize;
if (head == hpackHeaderFields.length) {
head = 0;
}
}
Source
Frequently Asked Questions
What is the HpackDynamicTable class?
HpackDynamicTable is a class in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDynamicTable.java.
Where is HpackDynamicTable defined?
HpackDynamicTable is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDynamicTable.java at line 37.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free