[Proposal] Java compatibility fixtures and PoC selection matrix for the Rust modernization groundwork

Open
#3,145 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
java

Research direction

Start with LongEncoding and its LongEncodingTest, then inspect the current Java 8 test-resource layout and build configuration. Define the candidate matrix, add the line-based LongEncoding corpus and JUnit 4 replay test, and document the stated edge cases, errors, invariants, and length limits. Done means the matrix is reviewed and the corpus and replay test run in the normal suite.

Written by the indexing model from the issue text.

Description

rust tests

Follow-up to the discussion in #3110. @imbajin confirmed the testing and validation groundwork can start before any Rust decision, so this issue tracks the Java-only part: a selection matrix for the first PoC candidate and golden compatibility fixtures for the codec classes.

Scope: Java-only compatibility groundwork before choosing a Rust PoC

Scope

Three deliverables, all plain Java against the current build:

  1. A selection matrix for PoC candidates (first cut below, to be refined in this thread).
  2. A golden fixture corpus for LongEncoding plus a replay test that runs it against the current implementation.
  3. Short written notes on the behavioral contract the fixtures lock down (edge cases, error behavior, invariants).

Non-goals

No Rust, no JNI, no Cargo, no packaging changes, no new Maven modules, no runtime wiring. Those wait for the component decision, a mentor, and a design review with contributors who have deeper Rust experience, as discussed in #3110.

Selection matrix

Criteria: an existing test oracle, enough call sites to matter, work per call big enough to survive a JNI crossing, and, following the maintainer feedback in #3110, keeping the Java implementation alive has to stay cheap: graceful fallback is the maintainer-preferred direction, which this matrix adopts as a selection criterion.

Candidate Oracle Fallback cost Notes
LongEncoding LongEncodingTest (684 lines) low, pure functions output feeds storage keys, so the contract needs locking either way
NumericUtil NumericUtilTest (475 lines) low coupled to LongEncoding.encodeNumber, candidate for the same corpus later
BytesBuffer BytesBufferTest (1351 lines) high persisted format, 30+ callers, a fallback would have to stay byte-identical; the store's read path structurally parses server-encoded values via the struct copy, so the shared format surface spans ids, vints and property encoding (thread)
IntSet / IntMap IntSetTest, IntMapTest high concurrent structures on Unsafe, a live double implementation risks divergence

With the fallback criterion the concurrent structures and the serializer drop out of round one. LongEncoding is the first fixture target. That is a choice about where to write fixtures first, not a decision that it becomes the Rust PoC.

Fixture shape

Plain ASCII, line-based (TSV with \uXXXX escapes for non-ASCII), checked into test resources so it needs no extra dependency to read. It covers: round trips across the full value range including Long.MIN_VALUE/MAX_VALUE (the encoding does intentional wrapping arithmetic), arbitrary UTF-16 input on the decode side (valid inputs are ASCII, invalid ones are not), the error cases (IllegalArgumentException vs NumberFormatException vs NPE on null), and the length limits.

The replay test is JUnit 4 and compiles at the Java 8 level, since that is the current hugegraph-commons baseline. Root is Java 11. Java 17 / commons Java 11 from #3117 are treated as declared targets, not assumptions.

Acceptance

  • matrix reviewed in this thread
  • corpus + replay test merged and running in the normal test suite
  • contract notes written up here or in the PR

Future PoC evaluation (outside the current implementation scope)

The following diagram illustrates a later evaluation step. No Rust component is selected here; any future PoC should compare compatibility and end-to-end costs, including JNI and data conversion, against the Java baseline.

Future PoC evaluation: compare Java and Rust end to end before adoption

References

Annotated references and suggested practices: SQLite, Parquet, Arrow, Protobuf, Go, Insta, Wycheproof, encoding test vectors, and Java/Rust integration examples.

Dominant language
Java
Stars
3.2k
Forks
637
Avg merge
3d 18h
Merged PRs (30d)
23

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/hugegraph

All issues in apache/hugegraph

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.