Skip to main content

WORST_CASE_QUAD_WIRE

Constant WORST_CASE_QUAD_WIRE 

Source
pub const WORST_CASE_QUAD_WIRE: usize = _; // 143usize
Expand description

Worst-case serialized bytes one row contributes to a ScanPatternResponse, dividing GRPC_MAX_MESSAGE_SIZE into the maximum row count a unary scan response may carry. Worked from the term-encoding invariant and proto framing, per row:

per term field   1 tag byte + 1 length varint + WRITTEN_TERM_MAX_SIZE
               = 1 + 1 + 33                              = 35 bytes
quad payload    4 term fields                            = 140 bytes
outer framing   1 field tag + 2 length varints (payload ≥ 128)
                                                         =   3 bytes
total                                                     = 143 bytes

Inputs and their validity bounds (each is load-bearing; the pinning test below fails if any moves):

  • WRITTEN_TERM_MAX_SIZE (33) — the largest encoded term, a type byte plus two 16-byte halves (the hashed typed/lang literal families). The per-term length varint is one byte only while this stays under 128; the outer quad length varint is two bytes only while the quad payload stays under 16,384.
  • four bytes slots on waratah.v1.EncodedQuad and no fifth field; DefaultGraph and omitted slots only ever shrink a slot below the bound, never grow it.

This is the wire WORST case — every slot of every row carrying a max-width literal simultaneously. Real pages are dominated by 17-byte node terms (~79 B/row), but the unary ceiling must hold for the data the encoder can produce, not the data we expect.