From 9db4130d53e03939924cad1c7b78e150114b3e42 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sat, 28 Feb 2026 18:39:18 -0500 Subject: [PATCH] feat(batch15): complete msgblock and consumer file store port --- .../JetStream/StoreEnumExtensions.cs | 34 ++++++++++++++++++ porting.db | Bin 6651904 -> 6651904 bytes reports/current.md | 8 ++--- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/dotnet/src/ZB.MOM.NatsNet.Server/JetStream/StoreEnumExtensions.cs b/dotnet/src/ZB.MOM.NatsNet.Server/JetStream/StoreEnumExtensions.cs index 1905200..bd6a0de 100644 --- a/dotnet/src/ZB.MOM.NatsNet.Server/JetStream/StoreEnumExtensions.cs +++ b/dotnet/src/ZB.MOM.NatsNet.Server/JetStream/StoreEnumExtensions.cs @@ -69,6 +69,22 @@ public static class StoreEnumExtensions }; } + public static (byte[]? Buffer, Exception? Error) Decompress(this StoreCompression alg, byte[] buf) + { + ArgumentNullException.ThrowIfNull(buf); + + const int checksumSize = FileStoreDefaults.RecordHashSize; + if (buf.Length < checksumSize) + return (null, new InvalidDataException("compressed buffer is too short")); + + return alg switch + { + StoreCompression.NoCompression => (buf, null), + StoreCompression.S2Compression => DecompressS2(buf, checksumSize), + _ => (null, new InvalidOperationException("compression algorithm not known")), + }; + } + private static (byte[]? Buffer, Exception? Error) CompressS2(byte[] buf, int checksumSize) { try @@ -86,4 +102,22 @@ public static class StoreEnumExtensions return (null, new IOException("error writing to compression writer", ex)); } } + + private static (byte[]? Buffer, Exception? Error) DecompressS2(byte[] buf, int checksumSize) + { + try + { + var bodyLength = buf.Length - checksumSize; + var decompressedBody = Snappy.Decode(buf.AsSpan(0, bodyLength)); + + var output = new byte[decompressedBody.Length + checksumSize]; + Buffer.BlockCopy(decompressedBody, 0, output, 0, decompressedBody.Length); + Buffer.BlockCopy(buf, bodyLength, output, decompressedBody.Length, checksumSize); + return (output, null); + } + catch (Exception ex) + { + return (null, new IOException("error reading compression reader", ex)); + } + } } diff --git a/porting.db b/porting.db index f4a09db6bce009c7f71c638cc9bd2df08331002b..1ce1d5864e76b8f69bce32c5f9f9a2317dd9d565 100644 GIT binary patch delta 786 zcmYMy%TE(g7zOa&zQE~Yrixn8mRnxpqfBWLYfT$f^;N5%ELHfvEtB7CO}XBb37EkG zRHc=36l_ z+h<=lHSDiVTv!qp2wzT$y>_eP7xD5BFU411$Ue78Ql6OI>qf~Vt?_-2)a@iiqth={ z%+}p{!!Lmc4#N@XfTM5>j)NCYKqs7pQ{V$XbOD6`bVCpHLLcNJ&0Y8uTa^;CwHXj)|&EvP!hxSCsK{|AHr f1~aOrheP3!U??06M`<_`i~RlA+9F>`u+6|9{J0l_ delta 619 zcmYky$xjne0D$p6YTIF2W~N#|5xP)8+!(}_g5riKDDEiW6e?{H6Df-a5(p_F(8LQG zmzUtBy?HTkdq?Ll@yxLoIQwzq@XL4k3WcBE0(MHa*jp>x#j-6>1uu@k2R{PPP_4?g z{!5pcT`ea6+Cf9wDP5O~bG}Ad`Qi;0w^BL|8bS>WwUsj8w`kuzKm5y{z=qN$%u%7T z8ME0hKS--aeVa1pev5tOv#gIoehOP_qEqdMtz<~7$cCu3DF038jAAKjA&jFqh6rj= zhk6{x2{hm&8qtI(Vu&MwW+ZV6EojAQwBZcS;vCN70@`7t0~gVWOSp_HxQc7IjxMCo zjUL>^kY-p}kmf9i%ai31sjNld9roBb!>4k@uKGMqVZ2V$x9gbna{7KQ@-+U;qFB diff --git a/reports/current.md b/reports/current.md index 92eec57..ef3e9f3 100644 --- a/reports/current.md +++ b/reports/current.md @@ -1,6 +1,6 @@ # NATS .NET Porting Status Report -Generated: 2026-02-28 23:34:28 UTC +Generated: 2026-02-28 23:39:18 UTC ## Modules (12 total) @@ -13,10 +13,10 @@ Generated: 2026-02-28 23:34:28 UTC | Status | Count | |--------|-------| | complete | 22 | -| deferred | 1698 | +| deferred | 1697 | | n_a | 24 | | stub | 1 | -| verified | 1928 | +| verified | 1929 | ## Unit Tests (3257 total) @@ -35,4 +35,4 @@ Generated: 2026-02-28 23:34:28 UTC ## Overall Progress -**3601/6942 items complete (51.9%)** +**3602/6942 items complete (51.9%)**