Skip to content

Add ranged byte[] overloads: compress/decompress(src, offset, length) #55

Description

@dfa1

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomersjavaPull requests that update java codewontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions