zstd: Add ResetWithOptions to encoder/decoder#1122
Conversation
## New API Methods ``` func (*Encoder) ResetWithOptions(w io.Writer, opts ...EOption) error func (*Decoder) ResetWithOptions(r io.Reader, opts ...DOption) error ``` New Options // Encoder - clears dictionary `WithEncoderDictDelete() EOption` // Decoder - removes dicts by ID; no args clears all `WithDecoderDictDelete(ids ...uint32) DOption` Option Reset Compatibility Can be changed with ResetWithOptions: - Encoder: WithEncoderCRC, WithEncoderPadding, WithZeroFrames, WithAllLitEntropyCompression, WithNoEntropyCompression, WithSingleSegment, WithEncoderDict, WithEncoderDictRaw, WithEncoderDictDelete - Decoder: WithDecoderMaxMemory, WithDecoderMaxWindow, WithDecoderDicts, WithDecoderDictRaw, WithDecoderDictDelete, WithDecodeAllCapLimit, IgnoreChecksum Cannot be changed with ResetWithOptions: - Encoder: WithEncoderConcurrency, WithWindowSize, WithEncoderLevel, WithLowerEncoderMem - Decoder: WithDecoderLowmem, WithDecoderConcurrency, WithDecodeBuffersBelow
📝 WalkthroughWalkthroughAdded ResetWithOptions to Encoder and Decoder to apply option changes during stream resets, moved decoder dictionary storage from per-decoder field to options-layer map, introduced resetOpt to restrict certain option changes during resets, and added dictionary deletion options and tests. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
# Conflicts: # zstd/encoder_options.go
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
zstd/decoder_options.go (1)
95-96: Typo in error message.The error message uses
WithDecoderMaxmemorybut the function isWithDecoderMaxMemory(capital M).Proposed fix
- return errors.New("WithDecoderMaxmemory must be less than 1 << 63") + return errors.New("WithDecoderMaxMemory must be less than 1 << 63")
New API Methods
New Options
Option Reset Compatibility
Can be changed with ResetWithOptions:
Cannot be changed with ResetWithOptions:
Summary by CodeRabbit
New Features
Chores
Tests
✏️ Tip: You can customize this high-level summary in your review settings.