Expand description
On-the-wire codec for cluster-coordinated FT.SEARCH.
This module defines the binary serialisation format the
coordinator uses when broadcasting an FT.SEARCH to remote
peers via the crate::proto::dnode::DmsgType::FtSearchReq
and crate::proto::dnode::DmsgType::FtSearchRep DNODE
frames.
§Format choice
The codec is a small, hand-rolled length-prefixed layout
that uses only the standard library, mirroring the
crate::proto::dnode::Handshake approach. Pulling in a
heavier serde codec was rejected because:
- the message shapes are tiny and stable;
- the FT.SEARCH path is hot, so allocation and parse cost matter;
- keeping the codec in this module keeps the cluster-FT surface honest: any new field shows up here and is covered by the round-trip tests below.
All multi-byte integers are little-endian. Lengths are
u32 so individual fields are bounded at 4 GiB which is
well above any realistic vector / pattern payload.
§Wire layout
§Request (FtSearchReq)
magic(4) = "FTQ1"
flags(2) = 0
top_k(4) = u32 (LE)
table_len = u32 (LE)
table = utf-8 bytes
query_tag = u8 (0=KNN, 1=Text, 2=Regex)
query body = ... (depends on tag, see below)§Reply (FtSearchRep)
magic(4) = "FTR1"
flags(2) = 0
timed_out(1) = 0|1
hit_count(4) = u32 (LE)
repeat hit_count times:
doc_id_len = u32 (LE)
doc_id = bytes
score = f32 (LE)Tag bodies:
KNN: field_len(4) field_utf8 bytes_len(4) vector_bytes
ef_present(1) [ef(4)]
Text: field_len(4) field_utf8 query_len(4) query_bytes
Regex: field_len(4) field_utf8 pattern_len(4) pattern_utf8
max_errors(2)Enums§
- Codec
Error - Errors raised by the cluster-FT codec.
Constants§
- REP_
MAGIC - Magic literal that opens every encoded
PeerReplypayload. - REQ_
MAGIC - Magic literal that opens every encoded
BroadcastRequestpayload.
Functions§
- decode_
reply - Decode a
PeerReplypreviously produced byencode_reply. - decode_
request - Decode a
BroadcastRequestpreviously produced byencode_request. - encode_
reply - Encode a
PeerReply(one peer’s per-peer top-K) for thecrate::proto::dnode::DmsgType::FtSearchRepDNODE frame. - encode_
request - Encode a
BroadcastRequestto a binary payload suitable for thecrate::proto::dnode::DmsgType::FtSearchReqDNODE frame.