APIdia Launch Partner
Top Inners Fields Constructors Methods
jdk.internal.net.http.qpack

public final Class DynamicTable

extends Object
implements HeadersTable
Class Inheritance
All Implemented Interfaces
jdk.internal.net.http.qpack.HeadersTable
Imports
jdk.internal.net.http.http3.streams.QueuingStreamPair, jdk.internal.net.http.qpack.Encoder.EncodingContext, .Encoder.SectionReference, .QPACK.Logger, jdk.internal.net.http.qpack.writers.EncoderInstructionsWriter, java.io.IOException, java.nio.ByteBuffer, java.util.Comparator, .Deque, .HashMap, .LinkedList, .Map, .PriorityQueue, .Queue, java.util.concurrent.CompletableFuture, java.util.concurrent.locks.ReentrantReadWriteLock, java.util.function.Predicate

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
private long
private long
private final int
private HeaderField[]
private final boolean
pack-priv static final long
public static final long
private long
private final Map<String, Map<String, Deque<Long>>>
private static final int
private final Queue<DynamicTable.TableInsertCountNotification>
private final ReentrantReadWriteLock
pack-priv final QPACK.Logger
private static final int
private long
private long
private long
private long

Constructor Summary

AccessConstructor and Description
public
public
DynamicTable(QPACK.Logger logger, boolean encoderTable)

Method Summary

Modifier and TypeMethod and Description
private void
public long
public CompletableFuture<Void>
awaitFutureInsertCount(long streamId, long valueToAwait)

private boolean
canReferenceEntry(long absId)

public long

Returns:

current capacity
capacity
()

Returns current capacity of the dynamic table

public boolean
private static boolean
public long
duplicate(long relativeId)

public long
duplicateWithEncoderStreamUpdate(EncoderInstructionsWriter writer, long absoluteEntryId, QueuingStreamPair encoderStreams, Encoder.EncodingContext encodingContext)

private void
private boolean

Returns:

true if entry was evicted, false if nothing to remove
evictEntry
()

Evicts one entry from the table tail.

public HeaderField

Returns:

retrieved header field
get
(long
an entry unique index
uniqueID
)

Implements jdk.internal.net.http.qpack.HeadersTable.get.

Retrieves a header field by its absolute index.

private int
public HeaderField

Returns:

retrieved header field
getRelative
(long
index relative to the most recently inserted entry
relativeId
)

Retrieves a header field by its relative index.

public static long
public static long
headerSize(String name, String value)

private boolean
public long

Returns:

unique index of an entry added to the table. If element cannot be added -1 is returned.
insert
(String
header name
name
,
String
header value
value
)

Implements jdk.internal.net.http.qpack.HeadersTable.insert.

Add an entry to the dynamic table.

public long

Returns:

unique index of an entry added to the table. If element cannot be added -1 is returned.
insert
(long
index of the header name to add
nameIndex
,
boolean
if name index references static table header name
isStaticIndex
,
String
header value
value
)

Add entry to the dynamic table with name specified as index in static or dynamic table.

public long

Returns:

unique index of an entry added to the table. If element cannot be added -1 is returned.
insert
(String
header name
name
,
String
header value
value
,
Encoder.SectionReference
unacknowledged section references
sectionReference
)

Add an entry to the dynamic table.

private long
public long

Returns:

number of elements in the dynamic table
insertCount
()

Method returns number of elements inserted to the dynamic table.

public long

Returns:

absolute id of inserted entry OR already available entry, -1L if entry cannot be added
insertWithEncoderStreamUpdate
(TableEntry
table entry to add
entry
,
EncoderInstructionsWriter
non-configured encoder instruction writer for generating encoder instruction
writer
,
QueuingStreamPair
encoder stream pair
encoderStreams
,
Encoder.EncodingContext
encoder encoding context
encodingContext
)

Inserts an entry to the dynamic table and sends encoder insert instruction bytes to the peer decoder.

public long

Returns:

maximum capacity
maxCapacity
()

Returns a maximum capacity in bytes of the dynamic table.

public long

Returns:

max entries
maxEntries
()

Returns maximum possible number of entries that could be stored in the dynamic table with respect to MAX_CAPACITY setting.

private void
private HeaderField
private void
resize(int newSize)

public long

Returns:

positive index if name:value match found, negative index if only name match found, 0 if no match found
search
(String
a name to search for
name
,
String
a value to search for
value
)

Implements jdk.internal.net.http.qpack.HeadersTable.search.

Search an absolute id of a name:value pair in the dynamic table.

public void
setCapacity(long
dynamic table capacity to set
capacity
)

Sets the dynamic table capacity in bytes.

public void
setCapacityWithEncoderStreamUpdate(EncoderInstructionsWriter
non-configured encoder instruction writer for generating encoder instruction
writer
,
long
new capacity value
capacity
,
QueuingStreamPair
encoder stream pair
encoderStreams
)

Updates the capacity of the dynamic table and sends encoder capacity update instruction bytes to the peer decoder.

public void
setMaxTableCapacity(long
a non-negative long
maxCapacity
)

Sets a maximum capacity in bytes of the dynamic table.

public long

Returns:

size of the dynamic table
size
()

Returns size of the dynamic table in bytes

public long

Returns:

relative entry index
toRelative
(long
absolute index of an entry
absoluteId
)

Converts absolute entry index to relative index that can be used in the encoder instructions.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public boolean
private void
private double
private void
writeEncoderInstruction(EncoderInstructionsWriter writer, int instructionSize, QueuingStreamPair encoderStreams)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

capacityback to summary
private long capacity
drainback to summary
private long drain
drainUsedSpaceThresholdback to summary
private final int drainUsedSpaceThreshold
elementsback to summary
private HeaderField[] elements
encoderTableback to summary
private final boolean encoderTable
ENTRY_NOT_INSERTEDback to summary
pack-priv static final long ENTRY_NOT_INSERTED
ENTRY_SIZEback to summary
public static final long ENTRY_SIZE
indicesMapback to summary
private final Map<String, Map<String, Deque<Long>>> indicesMap
INITIAL_HOLDER_ARRAY_LENGTHback to summary
private static final int INITIAL_HOLDER_ARRAY_LENGTH
insertCountNotificationsback to summary
private final Queue<DynamicTable.TableInsertCountNotification> insertCountNotifications
lockback to summary
private final ReentrantReadWriteLock lock
loggerback to summary
pack-priv final QPACK.Logger logger
MAX_BUFFER_SIZEback to summary
private static final int MAX_BUFFER_SIZE
maxCapacityback to summary
private long maxCapacity
maxEntriesback to summary
private long maxEntries
sizeback to summary
private long size
tailback to summary
private long tail

Constructor Detail

DynamicTableback to summary
public DynamicTable(QPACK.Logger logger)
DynamicTableback to summary
public DynamicTable(QPACK.Logger logger, boolean encoderTable)

Method Detail

addWithInverseMappingback to summary
private void addWithInverseMapping(HeaderField field)
availableEvictableSpaceback to summary
public long availableEvictableSpace(Encoder.SectionReference sectionReference)
awaitFutureInsertCountback to summary
public CompletableFuture<Void> awaitFutureInsertCount(long streamId, long valueToAwait)
canReferenceEntryback to summary
private boolean canReferenceEntry(long absId)
capacityback to summary
public long capacity()

Returns current capacity of the dynamic table

Returns:long

current capacity

cleanupStreamInsertCountNotificationsback to summary
public boolean cleanupStreamInsertCountNotifications(long streamId)
completeIfback to summary
private static boolean completeIf(Predicate<DynamicTable.TableInsertCountNotification> predicate, DynamicTable.TableInsertCountNotification insertCountNotification)
duplicateback to summary
public long duplicate(long relativeId)
duplicateWithEncoderStreamUpdateback to summary
public long duplicateWithEncoderStreamUpdate(EncoderInstructionsWriter writer, long absoluteEntryId, QueuingStreamPair encoderStreams, Encoder.EncodingContext encodingContext)
ensureElementsArrayLengthback to summary
private void ensureElementsArrayLength()
evictEntryback to summary
private boolean evictEntry()

Evicts one entry from the table tail.

Returns:boolean

true if entry was evicted, false if nothing to remove

getback to summary
public HeaderField get(long uniqueID)

Implements jdk.internal.net.http.qpack.HeadersTable.get.

Retrieves a header field by its absolute index. Entry referenced by an absolute index does not depend on the state of the dynamic table.

Parameters
uniqueID:long

an entry unique index

Returns:HeaderField

retrieved header field

Annotations
@Override
Exceptions
IllegalArgumentException:
if entry is not received yet, already evicted or invalid entry index is specified.
getElementsCountback to summary
private int getElementsCount()
getRelativeback to summary
public HeaderField getRelative(long relativeId)

Retrieves a header field by its relative index. Entry referenced by a relative index depends on the state of the dynamic table.

Parameters
relativeId:long

index relative to the most recently inserted entry

Returns:HeaderField

retrieved header field

headerSizeback to summary
public static long headerSize(HeaderField f)
headerSizeback to summary
public static long headerSize(String name, String value)
indexesUniqueAndOrderedback to summary
private boolean indexesUniqueAndOrdered(Deque<Long> indexes)
insertback to summary
public long insert(String name, String value)

Implements jdk.internal.net.http.qpack.HeadersTable.insert.

Add an entry to the dynamic table. Entries could be evicted from the dynamic table. Unacknowledged section references are not checked by this method, therefore this method is intended to be used by the decoder only. The encoder should use overloaded method that takes global unacknowledged section reference.

Parameters
name:String

header name

value:String

header value

Returns:long

unique index of an entry added to the table. If element cannot be added -1 is returned.

Annotations
@Override
insertback to summary
public long insert(long nameIndex, boolean isStaticIndex, String value)

Add entry to the dynamic table with name specified as index in static or dynamic table. Entries could be evicted from the dynamic table. Unacknowledged section references are not checked by this method, therefore this method is intended to be used by the decoder only. The encoder should use overloaded method that takes global unacknowledged section reference.

Parameters
nameIndex:long

index of the header name to add

isStaticIndex:boolean

if name index references static table header name

value:String

header value

Returns:long

unique index of an entry added to the table. If element cannot be added -1 is returned.

Exceptions
IllegalStateException:
if table memory reclamation error observed
insertback to summary
public long insert(String name, String value, Encoder.SectionReference sectionReference)

Add an entry to the dynamic table. Entries could be evicted from the dynamic table. The supplied unacknowledged section references are checked by this method to check if entries are evictable. Such checks are performed when there is not enough space in the dynamic table to insert the requested header. This method is intended to be used by the encoder only.

Parameters
name:String

header name

value:String

header value

sectionReference:Encoder.SectionReference

unacknowledged section references

Returns:long

unique index of an entry added to the table. If element cannot be added -1 is returned.

Exceptions
IllegalStateException:
if table memory reclamation error observed
insertback to summary
private long insert(HeaderField h, Encoder.SectionReference sectionReference)
insertCountback to summary
public long insertCount()

Method returns number of elements inserted to the dynamic table. Since element ids start from 0 the returned value is equal to the id of the head element plus one.

Returns:long

number of elements in the dynamic table

insertWithEncoderStreamUpdateback to summary
public long insertWithEncoderStreamUpdate(TableEntry entry, EncoderInstructionsWriter writer, QueuingStreamPair encoderStreams, Encoder.EncodingContext encodingContext)

Inserts an entry to the dynamic table and sends encoder insert instruction bytes to the peer decoder. This method is designated to be used by the Encoder class only. If an entry with matching name:value is available, its index is returned and no insert instruction is generated on encoder stream. If duplicate entry is required due to entry being non-referencable then DynamicTable#duplicateWithEncoderStreamUpdate( EncoderInstructionsWriter, long, QueuingStreamPair, EncodingContext) is used.

Parameters
entry:TableEntry

table entry to add

writer:EncoderInstructionsWriter

non-configured encoder instruction writer for generating encoder instruction

encoderStreams:QueuingStreamPair

encoder stream pair

encodingContext:Encoder.EncodingContext

encoder encoding context

Returns:long

absolute id of inserted entry OR already available entry, -1L if entry cannot be added

maxCapacityback to summary
public long maxCapacity()

Returns a maximum capacity in bytes of the dynamic table.

Returns:long

maximum capacity

maxEntriesback to summary
public long maxEntries()

Returns maximum possible number of entries that could be stored in the dynamic table with respect to MAX_CAPACITY setting.

Returns:long

max entries

notifyInsertCountChangeback to summary
private void notifyInsertCountChange()
removeback to summary
private HeaderField remove()
resizeback to summary
private void resize(int newSize)
searchback to summary
public long search(String name, String value)

Implements jdk.internal.net.http.qpack.HeadersTable.search.

Search an absolute id of a name:value pair in the dynamic table.

Parameters
name:String

a name to search for

value:String

a value to search for

Returns:long

positive index if name:value match found, negative index if only name match found, 0 if no match found

Annotations
@Override
setCapacityback to summary
public void setCapacity(long capacity)

Sets the dynamic table capacity in bytes. The new capacity must be lower than or equal to the limit defined by SETTINGS_QPACK_MAX_TABLE_CAPACITY HTTP/3 settings parameter. This limit is enforced by DynamicTable#setMaxTableCapacity(long).

Parameters
capacity:long

dynamic table capacity to set

setCapacityWithEncoderStreamUpdateback to summary
public void setCapacityWithEncoderStreamUpdate(EncoderInstructionsWriter writer, long capacity, QueuingStreamPair encoderStreams)

Updates the capacity of the dynamic table and sends encoder capacity update instruction bytes to the peer decoder. This method is designated to be used by the Encoder class only.

Parameters
writer:EncoderInstructionsWriter

non-configured encoder instruction writer for generating encoder instruction

capacity:long

new capacity value

encoderStreams:QueuingStreamPair

encoder stream pair

setMaxTableCapacityback to summary
public void setMaxTableCapacity(long maxCapacity)

Sets a maximum capacity in bytes of the dynamic table.

The value has to be agreed between decoder and encoder out-of-band, e.g. by a protocol that uses QPACK (see 3.2.3 Maximum Dynamic Table Capacity).

May be called only once to set maximum dynamic table capacity.

This method doesn't change the actual capacity of the dynamic table.

Parameters
maxCapacity:long

a non-negative long

Exceptions
IllegalArgumentException:
if max capacity is negative
IllegalStateException:
if max capacity was already set
See Also
setCapacity(long)
sizeback to summary
public long size()

Returns size of the dynamic table in bytes

Returns:long

size of the dynamic table

toRelativeback to summary
public long toRelative(long absoluteId)

Converts absolute entry index to relative index that can be used in the encoder instructions. Relative index of 0 refers to the most recently inserted entry.

Parameters
absoluteId:long

absolute index of an entry

Returns:long

relative entry index

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
tryReferenceEntryback to summary
public boolean tryReferenceEntry(TableEntry tableEntry, Encoder.EncodingContext context)
updateDrainIndexback to summary
private void updateDrainIndex()
usedSpaceback to summary
private double usedSpace()
writeEncoderInstructionback to summary
private void writeEncoderInstruction(EncoderInstructionsWriter writer, int instructionSize, QueuingStreamPair encoderStreams)
jdk.internal.net.http.qpack back to summary

private final Record DynamicTable.TableInsertCountNotification

extends Record
Class Inheritance
Record Components
streamId:long 
minimumRIC:long 
completion:CompletableFuture<Void> 

Field Summary

Modifier and TypeField and Description
private final CompletableFuture<Void>
completion

Record Component accessed by completion().

private final long
minimumRIC

Record Component accessed by minimumRIC().

private final long
streamId

Record Component accessed by streamId().

Constructor Summary

AccessConstructor and Description
private
TableInsertCountNotification(long streamId, long minimumRIC, CompletableFuture<Void> completion)

Method Summary

Modifier and TypeMethod and Description
public CompletableFuture<Void>
completion()

Record Component getter of completion.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public boolean
isFulfilled(long insertionCount)

public boolean
isStreamId(long streamId)

public long
minimumRIC()

Record Component getter of minimumRIC.

public long
streamId()

Record Component getter of streamId.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

completionback to summary
private final CompletableFuture<Void> completion

Record Component accessed by completion().

minimumRICback to summary
private final long minimumRIC

Record Component accessed by minimumRIC().

streamIdback to summary
private final long streamId

Record Component accessed by streamId().

Constructor Detail

TableInsertCountNotificationback to summary
private TableInsertCountNotification(long streamId, long minimumRIC, CompletableFuture<Void> completion)

Method Detail

completionback to summary
public CompletableFuture<Void> completion()

Record Component getter of completion.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

isFulfilledback to summary
public boolean isFulfilled(long insertionCount)
isStreamIdback to summary
public boolean isStreamId(long streamId)
minimumRICback to summary
public long minimumRIC()

Record Component getter of minimumRIC.

streamIdback to summary
public long streamId()

Record Component getter of streamId.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.