Package dev.relism.flash.bytes
Class SegmentedByteView
java.lang.Object
dev.relism.flash.bytes.SegmentedByteView
- All Implemented Interfaces:
dev.relism.fpr.core.ByteView
A
ByteView over up to K discontiguous byte[] segments, presented as one
logical byte sequence. Exists for the one case in this codebase where a "single contiguous
slice of one buffer" model (every other ByteView implementation) does not hold: an
HPACK header block whose encoding spans more than one CONTINUATION frame (RFC 9113
§6.10), where each frame's payload lives in its own connection-buffer region.
Deliberately not array-backed
This does not implementArrayBackedByteView — there is no single (array,
offset) pair that describes it — and supportsLong() returns false
time path is only sound for a genuinely contiguous backing array; see
FastPathViews.MethodPathByteView for the other deliberately-segmented view in this
codebase, which makes the same choice for the same reason).
Reusable, not allocated per block
reset(byte[][], int[], int[], int) repositions this view over a new set of segments without allocating — the same
idiom PooledSlice uses for the contiguous case. The segments/offsets/
lengths arrays passed to reset(byte[][], int[], int[], int) are retained by reference, not copied; the
caller owns their lifetime (typically the connection's HPACK scratch, sized to
Http2Limits.MAX_CONTINUATION_FRAMES_PER_BLOCK).
Cost model
byteAt(int) walks the segment table to find which segment an index falls in — O(segments),
not O(1) — because this view exists precisely for the rare, deliberately-bounded case
(at most MAX_CONTINUATION_FRAMES_PER_BLOCK segments); optimizing it further would add
complexity for a path that, by construction, is never hot.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbytebyteAt(int index) intlength()voidreset(byte[][] segments, int[] offsets, int[] lengths, int count) Repositions this view oversegments[0..count), where segmenticontributes bytessegments[i][offsets[i], offsets[i] + lengths[i]).booleanAlwaysfalse— see the class Javadoc for why a cross-segment word read is unsound.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.relism.fpr.core.ByteView
longAt
-
Constructor Details
-
SegmentedByteView
public SegmentedByteView()
-
-
Method Details
-
reset
public void reset(byte[][] segments, int[] offsets, int[] lengths, int count) Repositions this view oversegments[0..count), where segmenticontributes bytessegments[i][offsets[i], offsets[i] + lengths[i]). Zero allocation: the three arrays are retained by reference. -
length
public int length()- Specified by:
lengthin interfacedev.relism.fpr.core.ByteView
-
byteAt
public byte byteAt(int index) - Specified by:
byteAtin interfacedev.relism.fpr.core.ByteView
-
supportsLong
public boolean supportsLong()Alwaysfalse— see the class Javadoc for why a cross-segment word read is unsound.- Specified by:
supportsLongin interfacedev.relism.fpr.core.ByteView
-