This program generates the test vectors that the Rust client checks itself against, using the Apache Pulsar 5.0.1 Java client from Maven Central. The vectors are committed, so the Rust tests do not need a JVM.
It writes three files into crates/apache-pulsar-protocol/tests/vectors/:
routing.json: for each key, the raw and masked Murmur3 32-bit hashes, the segment hash (high 16 bits), the entry-bucket hash (low 16 bits), and the v4 partition for each partition count. The partitions come from SegmentRouter.route over a layout of legacy segments, which takes the v4 signSafeMod(makeHash(key), N) path.message_id.json: MessageIdV5.toByteArray() for a set of ids, with the v4 id bytes.checkpoint.json: CheckpointV5.toByteArray() for a set of checkpoints, including the EARLIEST/LATEST sentinels and latestOf.The generator is in package org.apache.pulsar.client.impl.v5 so it can reach the package-private API on the classpath. It decodes every id and checkpoint it encodes, compares the result field by field, and fails if anything differs.
Needs JDK 17 or newer and Maven 3.9. From this directory:
mvn -B compile exec:java
The output directory is set by the vectors.dir property in pom.xml. Run it twice and check that git diff is empty: the output is meant to be identical between runs.
Java writes position vectors and multi-topic vectors in HashMap iteration order. Cases where any vector has more than one entry have "byte_exact": false; compare those after decoding. Two sources of run-to-run variation are handled in the generator:
HashMap<byte[], ...>, whose order follows identity hash codes. For ids with two or more topics the generator encodes many times and keeps the lexicographically smallest result, so the committed bytes are a real Java encoding that does not change between runs.MessageIdV5 and CheckpointV5 copy their vectors with Map.copyOf, whose iteration order is salted per JVM. That only reaches the bytes when two segment ids share a HashMap bucket, so the multi-entry cases use segment ids that do not collide.