Skip to content

Add OffHeapLongHashSet and utility methods for enhancements#255

Merged
fh-ms merged 13 commits intomainfrom
utility-updates
Apr 15, 2026
Merged

Add OffHeapLongHashSet and utility methods for enhancements#255
fh-ms merged 13 commits intomainfrom
utility-updates

Conversation

@fh-ms
Copy link
Copy Markdown
Contributor

@fh-ms fh-ms commented Apr 13, 2026

Summary

This pull request introduces the following changes:

  • Added OffHeapLongHashSet for efficient storage and retrieval of long values.
  • Added the isEmpty override and padLeft utility method for better usability.
  • Introduced a utility method for combined hash calculation.
  • Added array content check utility methods to simplify array handling.
  • Fix correctness and performance issues in Set_long

@fh-ms fh-ms added the enhancement New feature or request label Apr 13, 2026
@fh-ms fh-ms requested a review from Copilot April 13, 2026 13:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new utility helpers and a new off-heap hash set implementation to support more efficient handling of primitive values and common formatting/hashing operations across the base module.

Changes:

  • Introduces OffHeapLongHashSet backed by a direct ByteBuffer for off-heap storage of primitive long values.
  • Adds small utility methods: XHashing.hash(int,int) and XArrays.hasContent/hasNoContent(...) overloads for primitive arrays.
  • Enhances VarString with isEmpty() override and padLeft(int, ...) for integer formatting.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
base/src/main/java/org/eclipse/serializer/hashing/XHashing.java Adds a helper to combine two hash components.
base/src/main/java/org/eclipse/serializer/collections/XArrays.java Adds primitive-array “content present” convenience checks.
base/src/main/java/org/eclipse/serializer/collections/OffHeapLongHashSet.java New off-heap primitive long hash set with linear probing and resizing.
base/src/main/java/org/eclipse/serializer/chars/VarString.java Adds isEmpty() override and an int overload for padLeft.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread base/src/main/java/org/eclipse/serializer/collections/OffHeapLongHashSet.java Outdated
Comment thread base/src/main/java/org/eclipse/serializer/chars/VarString.java
fh-ms added 4 commits April 13, 2026 17:01
- Track 0L separately via containsZero; add/contains/iterate now handle the value correctly instead of treating it as a duplicate sentinel (previous behavior: add(0L) inflated size on every call, contains(0L) always returned false, iterate() skipped it).
- Null-check the chain in contains() to avoid NPE on lookups whose hash slot has never been populated; bail early at the first 0L sentinel in the chain.
- Reset hashRange (and containsZero) in truncate(); leaving the old hashRange caused AIOOBE on the next add/contains after a prior enlargement.
- Replace low-bit masking hash with the bit-mixing function to reduce clustering for high-bit-heavy values.
- Allow rebuild() to shrink; optimize() now passes pow2BoundCapped (size + 1) so an exact power-of-two size no longer triggers an immediate re-enlarge on the next add.
- Widen size field from int to long to match the Sized.size() contract.
- Seed filter() with the current hashSlots.length to avoid log(n) rebuilds while copying from a large source set.
- Skip 0L sentinels during redistributeElements to stop propagating them as spurious elements on rehash.
- Clamp chainGrowthFactor to >= 1.0f so an accidental <1 value doesn't make enlargeChain attempt to shrink.
…d` return status

- Restart probing after resize to avoid unreachable slots and ensure correct insertion/containment behavior.
- Modify `checkForRebuild` to return a boolean, signaling if resizing occurred.
- Adjust collision handling and improve comments for better clarity.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread base/src/main/java/org/eclipse/serializer/chars/VarString.java
Comment thread base/src/main/java/org/eclipse/serializer/chars/VarString.java
Comment thread base/src/main/java/org/eclipse/serializer/collections/OffHeapLongHashSet.java Outdated
…dling

- Add `MAX_CAPACITY` to constrain the maximum number of slots.
- Throw `IllegalArgumentException` or `CapacityExceededException` when exceeding capacity limits.
- Introduce `ensureOpen` to validate the set's state before operations and throw `IllegalStateException` if closed.
- Update collision handling logic in `checkForRebuild` for clearer and stricter thresholds.
- Improve resizing safety checks and error messaging in `enlarge` and `resize`.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread base/src/main/java/org/eclipse/serializer/collections/Set_long.java Outdated
Comment thread base/src/main/java/org/eclipse/serializer/collections/OffHeapLongHashSet.java Outdated
Comment thread base/src/main/java/org/eclipse/serializer/chars/VarString.java
Comment thread base/src/main/java/org/eclipse/serializer/chars/VarString.java
fh-ms added 2 commits April 14, 2026 09:45
…LongHashSet`

- Add validation to prevent capacity exceeding `MAX_CAPACITY` during power-of-two rounding.
- Revise probing loop to ensure termination based on table capacity rather than collision limits.
- Improve comments for clarity on collision handling and probing behavior.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add `ensureOpen` checks in `size`, `capacity`, and `currentLoad` methods to throw `IllegalStateException` if the set is closed.
@fh-ms fh-ms requested a review from zdenek-jonas April 14, 2026 08:18
@fh-ms fh-ms merged commit a781cd3 into main Apr 15, 2026
17 checks passed
@fh-ms fh-ms deleted the utility-updates branch April 15, 2026 08:00
@fh-ms fh-ms added this to the 4.1.0 milestone Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants