~bigbes/tarantool-protobuf: 77ccfc15

lazy: zero-copy decode view (decode_lazy) with passthrough re-encode

Adds pb.decode_lazy(desc, bytes) returning a MessageView/ArrayView/MapView
that indexes the wire bytes in a single pass and decodes individual
fields only on :get / :at access. Nested messages return more lazy
sub-views; WKT descriptors (those carrying desc.decode) are
eager-wrapped so the API stays uniform.

Surface (see runtime/pb/lazy.lua):
  - MessageView: :get / :has / :which / :iter / :names / :set / :encode
  - ArrayView:   :len / :at / :iter / :tolist
  - MapView:     :get / :has / :keys / :iter / :totable

:encode is three-modes: WKT delegates to desc.encode on the materialized
table; untouched views return their original bytes verbatim
(passthrough); mixed views walk fields in id order, splicing clean
segments and re-emitting dirty ones. Sub-MessageView mutations
propagate to parent encode via a flat _sub_msg_views array (walked with
ipairs, so :is_dirty stays on a single JIT trace — pairs over a hash
is NYI in LuaJIT 2.1).

Codegen emits M.<Type>_decode_lazy in both modes as a one-line
delegation to pb.decode_lazy(<desc>, b); no inline expansion.
codec.encode_field is exposed so the lazy passthrough emitter can
splice fresh bytes for a single dirty field without rebuilding the
whole message.

Tests: 40 new lazy_test.lua cases parameterized over both codegen
modes; all 11 interop fixtures round-trip byte-equal through
decode_lazy(b):encode() in both modes. Total: 300/300 luatest, up
from 226.

Eugene Blikh <bigbes@gmail.com> — 2026-05-15 14:17:59 UTC

Commit 77ccfc1573a4f5a78cbfd3bc2bac432b5ea8468fview raw patch

Parent(s): add2f224

13 changed file(s)

FileStatus+
cmd/protoc-gen-tarantool/internal/gen/gen.go M +1
cmd/protoc-gen-tarantool/internal/gen/inline.go M +1
examples/expected/full/conformance/conformance_pb.lua M +5
examples/expected/full/hello/hello_pb.lua M +6
examples/expected/full/protobuf_test_messages/proto3/test_messages_proto3_pb.lua M +5
examples/expected/runtime/conformance/conformance_pb.lua M +5
examples/expected/runtime/hello/hello_pb.lua M +6
examples/expected/runtime/protobuf_test_messages/proto3/test_messages_proto3_pb.lua M +5
runtime/pb/codec.lua M +8
runtime/pb/init.lua M +13 -2
runtime/pb/lazy.lua A +729
test/interop_test.lua M +21
test/lazy_test.lua A +328