Add back `SerializedMessage{Reader,Rewriter}::OnLengthUnchecked()`.

It turns out to be significantly faster after all, the `ScopedLimiter` overhead
is too high.

This time it includes a check there against the source length, to make
processing untrusted input safer. In `OnLengthDelimited()` the analogous check
is performed by `ScopedLimiter` with the `exact` parameter.

Simplify `ScopedLimiter` constructor: use `LimitingReader::max_length()` and
`LimitingReader::set_max_length()` instead of converting the length to the
position first (which may overflow) and then working in terms of the position.
This delegates an overflow check to `set_max_length()`.

Tweak `Limiting{Reader,Writer,BackwardWriter}` failure messages to report
lengths instead of positions when appropriate.

PiperOrigin-RevId: 811779742
8 files changed
tree: b23e012d8815c3557bc0bc6a82ec5fa9c5e5dc21
  1. doc/
  2. python/
  3. riegeli/
  4. tf_dependency/
  5. .bazelrc
  6. configure
  7. CONTRIBUTING.md
  8. LICENSE
  9. MANIFEST.in
  10. MODULE.bazel
  11. README.md
README.md

Riegeli

Riegeli/records is a file format for storing a sequence of string records, typically serialized protocol buffers. It supports dense compression, fast decoding, seeking, detection and optional skipping of data corruption, filtering of proto message fields for even faster decoding, and parallel encoding.

See documentation.

Status

Riegeli file format will only change in a backward compatible way (i.e. future readers will understand current files, but current readers might not understand files using future features).

Riegeli C++ API might change in incompatible ways.