fix(metadata): write and detect gzip-compressed table metadata #1014
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 272 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.336
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1014"
general
weight: 0.35
LuciferYang
What
With
write.metadata.compression-codec=gzip, metadata files are named<version>-<uuid>.gz.metadata.json, butTableMetadataUtil::Writestored plain JSON in them, andCodec::FromFileNamemisdetected the codec:find_last_of(".metadata.json")searches for any one character of that string, so a.gz.metadata.jsonname was classified as uncompressed. The two bugs cancelled out inside iceberg-cpp, while files exchanged with Java failed in both directions.Closes #1013.
How
FromFileNameusesrfind, matching Java'slastIndexOf(".metadata.json"). Names without.metadata.jsonare now rejected, as in Java.Writecompresses the JSON when the location's codec is gzip, matching Java'sinternalWrite. This adds aGZipCompressornext toGZipDecompressorinutil/gzip_internal.h, plus akCompressErrorerror kind alongsidekDecompressError. Inputs above zlib's 32-bit length limit are rejected instead of being silently truncated.The two changes are in one PR because neither works alone: fixing only the read side would make iceberg-cpp try to inflate the plain JSON it writes today.
Tables that already have
write.metadata.compression-codec=gzipand were written by iceberg-cpp contain plain JSON under.gz.metadata.jsonnames; after this change iceberg-cpp reads those as gzip and fails, as Java already does. The property defaults tonone.Testing
New tests in
metadata_io_test.cc:CodecFromFileGzMetadataJson,CodecFromFilePlainAndLegacyGz,CodecFromFileInvalidName: codec detection for the.gz.metadata.json, plain, legacy.metadata.json.gz, and invalid names.RoundTripGzipCompressedMetadata: writes with the gzip codec, checks the file name, checks that the bytes on disk start with the gzip magic1f 8b, and reads the metadata back.New tests in
gzip_decompress_test.cc:GZipCompressorRoundTrip(100 KiB, more than one output buffer),GZipCompressorEmptyInput, andGZipCompressorReused(one compressor, two payloads, each decompresses on its own).Reverting the
rfindchange fails the three codec tests and the round trip; removing the write-side compression fails the round trip.