~bigbes/tarantool-protobuf: 8c1e6078

c_runtime: map<K,V> encode + decode dispatch (ra6 3h)

Encode walks the user map with lua_next (the documented JIT exception
per CLAUDE.md — map hot paths can't avoid hash iteration). Each entry
goes into a stack-backed sub-buffer with synthetic tag(1,key) +
tag(2,value); proto3-elides default key and default value independently.
Map<,message> resolves its value sub-plan once and recurses through
encode_body. Decode reads the entry payload bounded, dispatches inner
id=1/id=2 (skipping anything else per spec), and lua_rawsets into a
lazy-created result map table; missing key or value defaults to the
proto3 zero. Reuses the existing list_stack_idx[] slot for the lazy
map cache since a field is either repeated or map, never both.

12 new tests cover round-trip for ages_by_nickname (string->int32),
nickname_by_age (int32->string), and addresses_by_label (string->
message), plus default-elision, multi-key correctness, empty maps,
and unknown-inner-id tolerance. Full suite 964/964 with PB_ENABLE_C=1.

bd-asz

Eugene Blikh <bigbes@gmail.com> — 2026-05-23 17:07:26 UTC

Commit 8c1e6078b7b32825347c6e551e8ccff4e8c34e2eview raw patch

Parent(s): b840992a

4 changed file(s)

FileStatus+
.beads/issues.jsonl M +1 -1
runtime/pb/c/c_runtime.c M +438 -11
test/c_runtime_decode_test.lua M +67 -14
test/c_runtime_encode_test.lua M +65 -15