From d507a956c12080b811adf71454d2173912efdc91 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Tue, 10 May 2022 11:09:38 +0200 Subject: [PATCH] Update README.md --- s2/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/s2/README.md b/s2/README.md index d9ad481682..9121df054b 100644 --- a/s2/README.md +++ b/s2/README.md @@ -901,6 +901,14 @@ for each entry { } ``` +To decode from any given uncompressed offset `(wantOffset)`: + +* Iterate entries until `entry[n].UncompressedOffset > wantOffset`. +* Start decoding from `entry[n-1].CompressedOffset`. +* Discard `entry[n-1].UncompressedOffset - wantOffset` bytes from the decoded stream. + +See [using indexes](https://github.com/klauspost/compress/tree/master/s2#using-indexes) for functions that perform the operations with a simpler interface. + # Format Extensions * Frame [Stream identifier](https://github.com/google/snappy/blob/master/framing_format.txt#L68) changed from `sNaPpY` to `S2sTwO`.