Fix ComparableVector Comparable contract violation#2817
Merged
lvca merged 2 commits intojvector-integrationfrom Nov 21, 2025
Merged
Fix ComparableVector Comparable contract violation#2817lvca merged 2 commits intojvector-integrationfrom
lvca merged 2 commits intojvector-integrationfrom
Conversation
2 tasks
Co-authored-by: lvca <312606+lvca@users.noreply.github.com>
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
[WIP] Address feedback on JVector integration PR
Fix ComparableVector Comparable contract violation
Nov 21, 2025
Contributor
🧪 CI InsightsHere's what we observed from your CI run for c56850e. 🟢 All jobs passed!But CI Insights is watching 👀 |
robfrank
pushed a commit
that referenced
this pull request
Nov 22, 2025
* Initial plan * Fix ComparableVector to maintain Comparable contract Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com>
lvca
added a commit
that referenced
this pull request
Nov 22, 2025
* First version with jvector * Implemented compaction of vector indexes * Added test cases * Fixed compilation problems * Fixed test cases, now all pass * Refactor vector index using the transaction index changes instead of internal map (with threadId) * feat: integrated new vector index with the `database import` command * Supported lsmvector in `vectorNeighbors()` sql function * Upgraded to jvector 4.0.0-rc.6 * Update LSMVectorIndexCompacted.java fix: error after compaction * Fix ComparableVector Comparable contract violation (#2817) * Initial plan * Fix ComparableVector to maintain Comparable contract Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Return similarity scores from LSMVectorIndex to avoid redundant distance recalculation (#2820) * Initial plan * Add findNeighborsFromVector method to LSMVectorIndex to return scores directly Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test artifacts and update .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Add mutable flag to vector index pages for safe compaction (#2819) * Initial plan * Add mutable byte indicator to vector index pages - Added mutable flag byte at offset 8 in page header (after offsetFreeContent and numberOfEntries) - New pages are created with mutable=1 (actively being written to) - Pages are marked as immutable (mutable=0) when they become full and a new page is created - Updated findLastImmutablePage() to scan from end backwards and stop at first immutable page - Updated all page reading/writing code to account for the mutable byte in header - All vector index tests passing Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test database files and update .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Add constants for page header offsets to improve maintainability - Added OFFSET_FREE_CONTENT, OFFSET_NUM_ENTRIES, OFFSET_MUTABLE, and HEADER_BASE_SIZE constants - Replaced magic numbers throughout the code with named constants - Makes the code more maintainable and self-documenting Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Update comments to reference constants instead of hardcoded offsets Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> Co-authored-by: Luca Garulli <lvca@users.noreply.github.com> * Make LSMVectorIndex ID property configurable (#2818) * Initial plan * Make ID property configurable in LSMVectorIndex Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test database files and add to .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Improve documentation for metadata JSON configuration Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> Co-authored-by: Luca Garulli <lvca@users.noreply.github.com> * First version with jvector * Implemented compaction of vector indexes * Added test cases * Fixed compilation problems * Fixed test cases, now all pass * Refactor vector index using the transaction index changes instead of internal map (with threadId) * feat: integrated new vector index with the `database import` command * Supported lsmvector in `vectorNeighbors()` sql function * Upgraded to jvector 4.0.0-rc.6 * Update LSMVectorIndexCompacted.java fix: error after compaction * Fix ComparableVector Comparable contract violation (#2817) * Initial plan * Fix ComparableVector to maintain Comparable contract Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Return similarity scores from LSMVectorIndex to avoid redundant distance recalculation (#2820) * Initial plan * Add findNeighborsFromVector method to LSMVectorIndex to return scores directly Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test artifacts and update .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Add mutable flag to vector index pages for safe compaction (#2819) * Initial plan * Add mutable byte indicator to vector index pages - Added mutable flag byte at offset 8 in page header (after offsetFreeContent and numberOfEntries) - New pages are created with mutable=1 (actively being written to) - Pages are marked as immutable (mutable=0) when they become full and a new page is created - Updated findLastImmutablePage() to scan from end backwards and stop at first immutable page - Updated all page reading/writing code to account for the mutable byte in header - All vector index tests passing Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test database files and update .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Add constants for page header offsets to improve maintainability - Added OFFSET_FREE_CONTENT, OFFSET_NUM_ENTRIES, OFFSET_MUTABLE, and HEADER_BASE_SIZE constants - Replaced magic numbers throughout the code with named constants - Makes the code more maintainable and self-documenting Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Update comments to reference constants instead of hardcoded offsets Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> Co-authored-by: Luca Garulli <lvca@users.noreply.github.com> * Make LSMVectorIndex ID property configurable (#2818) * Initial plan * Make ID property configurable in LSMVectorIndex Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test database files and add to .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Improve documentation for metadata JSON configuration Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> Co-authored-by: Luca Garulli <lvca@users.noreply.github.com> * fix pre-commit * Update engine/src/main/java/com/arcadedb/database/TransactionIndexContext.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixed compaction * test: fixed test --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Roberto Franchini <ro.franchini@gmail.com>
robfrank
pushed a commit
that referenced
this pull request
Feb 11, 2026
* First version with jvector * Implemented compaction of vector indexes * Added test cases * Fixed compilation problems * Fixed test cases, now all pass * Refactor vector index using the transaction index changes instead of internal map (with threadId) * feat: integrated new vector index with the `database import` command * Supported lsmvector in `vectorNeighbors()` sql function * Upgraded to jvector 4.0.0-rc.6 * Update LSMVectorIndexCompacted.java fix: error after compaction * Fix ComparableVector Comparable contract violation (#2817) * Initial plan * Fix ComparableVector to maintain Comparable contract Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Return similarity scores from LSMVectorIndex to avoid redundant distance recalculation (#2820) * Initial plan * Add findNeighborsFromVector method to LSMVectorIndex to return scores directly Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test artifacts and update .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Add mutable flag to vector index pages for safe compaction (#2819) * Initial plan * Add mutable byte indicator to vector index pages - Added mutable flag byte at offset 8 in page header (after offsetFreeContent and numberOfEntries) - New pages are created with mutable=1 (actively being written to) - Pages are marked as immutable (mutable=0) when they become full and a new page is created - Updated findLastImmutablePage() to scan from end backwards and stop at first immutable page - Updated all page reading/writing code to account for the mutable byte in header - All vector index tests passing Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test database files and update .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Add constants for page header offsets to improve maintainability - Added OFFSET_FREE_CONTENT, OFFSET_NUM_ENTRIES, OFFSET_MUTABLE, and HEADER_BASE_SIZE constants - Replaced magic numbers throughout the code with named constants - Makes the code more maintainable and self-documenting Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Update comments to reference constants instead of hardcoded offsets Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> Co-authored-by: Luca Garulli <lvca@users.noreply.github.com> * Make LSMVectorIndex ID property configurable (#2818) * Initial plan * Make ID property configurable in LSMVectorIndex Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test database files and add to .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Improve documentation for metadata JSON configuration Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> Co-authored-by: Luca Garulli <lvca@users.noreply.github.com> * First version with jvector * Implemented compaction of vector indexes * Added test cases * Fixed compilation problems * Fixed test cases, now all pass * Refactor vector index using the transaction index changes instead of internal map (with threadId) * feat: integrated new vector index with the `database import` command * Supported lsmvector in `vectorNeighbors()` sql function * Upgraded to jvector 4.0.0-rc.6 * Update LSMVectorIndexCompacted.java fix: error after compaction * Fix ComparableVector Comparable contract violation (#2817) * Initial plan * Fix ComparableVector to maintain Comparable contract Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Return similarity scores from LSMVectorIndex to avoid redundant distance recalculation (#2820) * Initial plan * Add findNeighborsFromVector method to LSMVectorIndex to return scores directly Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test artifacts and update .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Add mutable flag to vector index pages for safe compaction (#2819) * Initial plan * Add mutable byte indicator to vector index pages - Added mutable flag byte at offset 8 in page header (after offsetFreeContent and numberOfEntries) - New pages are created with mutable=1 (actively being written to) - Pages are marked as immutable (mutable=0) when they become full and a new page is created - Updated findLastImmutablePage() to scan from end backwards and stop at first immutable page - Updated all page reading/writing code to account for the mutable byte in header - All vector index tests passing Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test database files and update .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Add constants for page header offsets to improve maintainability - Added OFFSET_FREE_CONTENT, OFFSET_NUM_ENTRIES, OFFSET_MUTABLE, and HEADER_BASE_SIZE constants - Replaced magic numbers throughout the code with named constants - Makes the code more maintainable and self-documenting Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Update comments to reference constants instead of hardcoded offsets Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> Co-authored-by: Luca Garulli <lvca@users.noreply.github.com> * Make LSMVectorIndex ID property configurable (#2818) * Initial plan * Make ID property configurable in LSMVectorIndex Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Remove test database files and add to .gitignore Co-authored-by: lvca <312606+lvca@users.noreply.github.com> * Improve documentation for metadata JSON configuration Co-authored-by: lvca <312606+lvca@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> Co-authored-by: Luca Garulli <lvca@users.noreply.github.com> * fix pre-commit * Update engine/src/main/java/com/arcadedb/database/TransactionIndexContext.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fixed compaction * test: fixed test --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: lvca <312606+lvca@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Roberto Franchini <ro.franchini@gmail.com> (cherry picked from commit c470e6d)
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
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.
The
ComparableVectorclass violated the Comparable contract:compareToreturned 0 on hash collisions even when vectors differed, whileequalscorrectly compared array contents. This could cause data loss inTreeMap(used byTransactionIndexContext) where distinct vectors with matching hash codes would overwrite each other.Changes
LSMVectorIndex.ComparableVector.compareTo: Added lexicographical comparison fallback when hash codes collidecompareTo(v) == 0 ⟺ equals(v) == true💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.