Motivation
Zstd.compress(byte[]) / decompress(byte[]) operate on the whole array. Callers that hold a payload inside a larger buffer (a parsed record, a framing layer) must copy out the sub-range first — wasteful for a binding that prides itself on avoiding copies.
Proposal
Add ranged overloads on Zstd:
public static byte[] compress(byte[] src, int offset, int length);
public static byte[] compress(byte[] src, int offset, int length, int level);
public static byte[] decompress(byte[] compressed, int offset, int length, int maxSize);
Internally these can copy the sub-range into the native input segment directly (no intermediate Arrays.copyOfRange).
Acceptance criteria
- Overloads added with full Markdown
/// javadoc (@param/@return) per CLAUDE.md; ./mvnw javadoc:javadoc -pl zstd clean.
- Bounds validated (offset/length against
src.length) with a clear exception; covered by tests including corners (offset 0, full length, empty range, out-of-bounds).
- Round-trip + golden/JNI interop tests as appropriate.
Pointers
zstd/src/main/java/io/github/dfa1/zstd/Zstd.java (existing whole-array methods ~L31-118)
Motivation
Zstd.compress(byte[])/decompress(byte[])operate on the whole array. Callers that hold a payload inside a larger buffer (a parsed record, a framing layer) must copy out the sub-range first — wasteful for a binding that prides itself on avoiding copies.Proposal
Add ranged overloads on
Zstd:Internally these can copy the sub-range into the native input segment directly (no intermediate
Arrays.copyOfRange).Acceptance criteria
///javadoc (@param/@return) perCLAUDE.md;./mvnw javadoc:javadoc -pl zstdclean.src.length) with a clear exception; covered by tests including corners (offset 0, full length, empty range, out-of-bounds).Pointers
zstd/src/main/java/io/github/dfa1/zstd/Zstd.java(existing whole-array methods ~L31-118)