-
Notifications
You must be signed in to change notification settings - Fork 87
Bytes docs + API polish: architecture/requirements docs, and tighten parsing / array ref safety #714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
peter-lawrey
wants to merge
22
commits into
develop
Choose a base branch
from
adv/develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…o comments, variable declarations, and encoding handling
…larity and consistency
james-mcsherry
approved these changes
Nov 20, 2025
…s for ElasticBenchmarkRunner, ElasticByteBufferJmh, ElasticDirectJmh, and related classes to clarify their purpose and usage.
…improved code clarity
…view, testing strategy, functional requirements, and security review; improve clarity and structure in existing guides.
… README formatting
# Conflicts: # GEMINI.md # src/main/java/net/openhft/chronicle/bytes/BytesStore.java # src/test/java/net/openhft/chronicle/bytes/NativeBytesStoreTest.java # src/test/java/net/openhft/chronicle/bytes/algo/OptimisedBytesStoreHashTest.java
…y and consistency
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



This PR is mostly documentation and API hygiene for Chronicle-Bytes, with a few small but real functional fixes and safer behaviours.
Functional changes
Safer
Binary*ArrayReference.bindValueAt(…)BinaryIntArrayReference.bindValueAt(long index, IntValue value)andBinaryLongArrayReference.bindValueAt(long index, LongValue value)now:valueis aBinaryIntReference/BinaryLongReferencebefore binding.IllegalArgumentExceptionwith a clear message instead of an uncheckedClassCastException.This makes misuse easier to diagnose and avoids surprising runtime
ClassCastExceptions.More robust
parse8bit(…)for genericAppendableByteStringParser.parse8bit(Appendable, StopCharTester/StopCharsTester):Previously only handled
StringBuilderandBytes; otherAppendableimplementations were effectively unsupported.Now falls back via a temporary
StringBuilderand copies into the targetAppendable, so:StringWriter,ByteStringWriterand otherAppendabletypes work correctly.ByteStringParser.appendTo(Appendable, CharSequence)wraps IOExceptions inIORuntimeException.BytesInternalvectorised content-equals error handling tightenedThe Java-11
VectorizedMismatchpath now:HeapBytesStorefor the vectorised fast path.UnsupportedOperationExceptionif the preconditions are not met or the reflective call fails, instead of silently returningnull.This makes misconfiguration or unexpected store types fail loudly instead of silently dropping back on a partially initialised path. Call sites that rely on vectorisation will now see a clear failure if the optimisation cannot be used.
BytesUtil.combineDoubleNewlineswitch exhaustivenessreturnin all branches (includingdefault), removing an implicit fall-through.Type-safe
Bytes.equals(...)/NoBytesStore.equals(...)edge casesNoBytesStore.equals(Object)now checksother.isEmpty()instead oflength() == 0, making it robust for stores wherelength()might not be a cheap or meaningful call but emptiness is.Bytes.allocateElasticOnHeapvsBytes.allocateElasticDirect) is consistently exercised.Mapped file / page-size edge cases
Additional tests and small fixes around:
MappedFile.safeLimit()andMappedBytes.inside(...)when using non-default page sizes.MappedBytes.zeroOut(long from, long to)to ensure it honours safe limits even when huge page sizes differ from OS page size.These primarily affect corner cases with custom page sizes and ensure we never write beyond the mapped region.
Misc small correctness improvements
DistributedUniqueTimeProvidernow exposes itsDistributedUniqueTimeDeduplicatorvia a package-visible accessor for tighter testing and coordination.MappedBytes,MappedFile, and time providers now assert more invariants (e.g. that black-hole fields change, that temporary files are deleted or scheduled for deletion).Non-functional changes (docs, API surface, tests)
1. New agent / AI guidance docs
CLAUDE.mdDetailed guidance for Claude Code / claude.ai agents working on Chronicle-Bytes:
mvn clean verify,-DskipTests, profilesquality,sonar).assertReferencesReleased(), JMH benchmarks, etc.GEMINI.mdAI-generated Chronicle-Bytes project summary aimed at Gemini-style agents:
-P run-benchmarks,-P assertions,-P quality,-P sonar).src/main/docs/.AGENTS.md(Bytes-local)Now explicitly states that:
AGENTS.mddefines global rules; this file adds Chronicle-Bytes specifics.src/main/docs/withREADME.adocas the landing page.Language / charset table tightened:
iconvor IDE settings.2. Documentation restructure under
src/main/docs/Most docs have moved / been consolidated into a canonical
src/main/docs/tree:Overview & architecture:
architecture-overview.adoc– refreshed C4-style description of Bytes vs BytesStore, memory types, threading model, elastic buffers, reference counting, and container diagrams, including context within the OpenHFT stack.algo-overview.adoc– non-cryptographic hash algorithms (OptimisedBytesStoreHash, VanillaBytesStoreHash, XxHash) with trade-offs and usage notes.domestic-overview.adoc– internal utilities (e.g.ReentrantFileLock) and their trade-offs.Requirements & decision log (Nine-Box aligned):
project-requirements.adoc– updated with anchors ([[CB-FN-001]]etc.),:sectnums:, and clearer tables for:CB-FN-*),CB-NF-P-*,CB-NF-S-*,CB-NF-O-*,CB-NF-MP-*),CB-DOC-*,CB-TEST-*,CB-RISK-*,CB-OPS-*).functional-requirements.adoc– human-friendly slice over theCB-FN-*requirements, organised by domain (core API, encoding/utilities, pooling/lifecycle) with references back toproject-requirements.adoc.decision-log.adoc– new ADR-style log:Operational / quality docs:
memory-management.adoc– expanded explanation of reference counting, native memory, mapped files, resource tracing, elastic buffers and best practices, with simple lifetime diagrams.pool-overview.adoc– trade-offs and usage ofBytesPool+ScopedResourcePool, with clear guidance on when to pool vs allocate.testing-strategy.adoc– maps test layers (unit, integration, JMH) toCB-TEST-*requirements and describes how they support ISO-style verification.security-review.adoc– Chronicle-Bytes–focused security considerations covering:CB-NF-S-001,CB-NF-S-003),CB-NF-S-002),CB-NF-S-004,CB-FN-003),system-properties.adoc– replaces olddocs/systemProperties.adoc:bytes.guarded,bytes.bounds.unchecked,trace.mapped.bytes,mappedFile.retain,bytes.max-array-len) and their backing constants.API guides and FAQs:
api-guide.adoc– significantly enriched:Bytesinstances (heap/direct/mapped), cursor invariants, common patterns, advanced topics (endian, fences, alignment).FAQ.adoc– reorganised::sectnums:),decimal-rendering.adoc&render-overview.adoc– explain the decimaliser / appender model, trade-offs between simple/maximum-precision/BigDecimal strategies, and guidance for hot vs exact paths.util-overview.adoc– summary of utility helpers (compression, interning, length prefixes, escaping testers, decorated exceptions) with a small diagram.ref-overview.adoc–ReentrantFileLockusage, features and trade-offs.wire-integration.adoc– refreshed Wire integration guide:Images / structure:
docs/images/...tosrc/main/docs/images/...with updated references (e.g.Figure1.png, IntelliJ screenshots).All new docs follow the Chronicle house style:
:sectnums:,:lang: en-GB,:source-highlighter: rouge.3. README / microbench README polish
README.adoc::toc:,:lang:,:source-highlighter: rouge,:toclevels:).src/main/docs/system-properties.adoc.project-requirements.adocanddecision-log.adocfor more formal design and requirement rationale.opts=novalidateto code blocks that are pure examples (avoid Asciidoctor complaining about Java syntax).microbenchmarks/README.adoc::toc:and:source-highlighter: rouge.4. JavaDoc and package-info improvements
Added / updated
package-info.javaacross:net.openhft.chronicle.bytes,.internal,.algo,.domestic,.pool,.ref,.render,.util,.internal.migration.Tightened JavaDoc for many public types and methods:
Bytes,BytesStore,BytesIn,BytesOut,RandomDataInput,RandomDataOutput,StreamingDataInput,StreamingDataOutput,BytesRingBuffer,RingBufferReader,DistributedUniqueTimeProvider,XxHash,OptimisedBytesStoreHash,NativeBytesStore,SingleMappedFile,Invocation,BinaryBooleanReference,ByteStringAppender,AppendableUtil, etc.Most of these are narrative/doc-only and do not change runtime behaviour.
5. ByteBuffer compatibility helper
New internal helper:
internal.BufferUtil:Wraps
position,limit,clear,flipcalls onByteBuffervia((Buffer) bb)casts.Replaces direct calls in:
NativeBytes,UncheckedNativeBytes,VanillaBytes, some tests, and a few other classes.Fixes Java 8 vs Java 9+ compatibility around
ByteBuffercovariant return types without relying on “redundant” casts that some IDEs / tools remove.6. Tests and benchmarks
Many tests updated for:
.getBytes(ISO_8859_1)/new String(..., ISO_8859_1)).isDirectMemoryReturnsExpectedValue,compactResetsPositionsAndLimits, equality tests exercising heap/direct combinations).new Random(1L)instead of default-seeded RNG).JLBH / perf harnesses:
7. Build / dependency
pom.xml:net.openhft:third-party-bomfrom3.27ea5to3.27ea7.