fix: make values method behave like keys method#2967
fix: make values method behave like keys method#2967robfrank merged 1 commit intoArcadeData:mainfrom
Conversation
Summary of ChangesHello @gramian, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an inconsistency in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🧪 CI InsightsHere's what we observed from your CI run for a517425. 🟢 All jobs passed!But CI Insights is watching 👀 |
There was a problem hiding this comment.
Code Review
This pull request aims to make the values method handle collection arguments, similar to the keys method. While the intent is good, the current implementation introduces a critical bug that can cause a NullPointerException when processing collections containing unsupported element types. Additionally, the logic for handling collections of Document objects is flawed due to a pre-existing issue, which will lead to incorrect results or a ClassCastException. I've provided a suggestion to make the collection handling safer, but further changes are needed for it to work correctly with Documents. The tests should also be expanded to cover these failure scenarios to prevent regressions.
| final List<Object> result = collection.stream() | ||
| .flatMap(o -> ((Collection<Object>) execute(o, currentRecord, context, params)).stream()).toList(); |
There was a problem hiding this comment.
This implementation has two critical issues:
- NullPointerException: If an element in the
collectiondoes not match any of the handled types,execute()returnsnull, causing an NPE when.stream()is called. - Incorrect result for Documents: For a
Document,execute()returns aList<Collection<Object>>. The current code will throw aClassCastException. The suggested fix below resolves the NPE and cast issue, but it will still produce a list of collections forDocumentinputs, not a flat list of values. This is due to an existing issue in howDocumentvalues are retrieved (List.of(document.toMap().values())). You should consider fixing that or adapting this logic to correctly flatten the results.
final List<Object> result = collection.stream()
.map(o -> execute(o, currentRecord, context, params))
.filter(Collection.class::isInstance)
.flatMap(c -> ((Collection<?>) c).stream()).toList();| @Test | ||
| void withCollection() { | ||
| List<Map<String, Object>> collection = List.of(Map.of("key1", "value1"), Map.of("key2", "value2")); | ||
|
|
||
| Object result = function.execute(collection, null, null, null); | ||
| assertThat(result).isEqualTo(List.of("value1", "value2")); | ||
| } | ||
|
|
||
| @Test | ||
| void withNull() { | ||
| Object result = function.execute(null, null, null, null); | ||
| assertThat(result).isNull(); | ||
| } |
There was a problem hiding this comment.
The new tests are a good start, but they don't cover all scenarios. The current implementation has issues with certain inputs that are not covered by these tests. Please consider adding more test cases to ensure robustness:
- A test with a collection of
Documentobjects to verify correct flattening of values. - A test with a collection containing mixed or unsupported types (e.g.,
List.of(Map.of("k", "v"), "some string")) to ensureNullPointerExceptionis not thrown. - A test with a collection of
Resultobjects.
….1 [skip ci] Bumps [com.arcadedb:arcadedb-network](https://github.com/ArcadeData/arcadedb) from 25.11.1 to 25.12.1. Release notes *Sourced from [com.arcadedb:arcadedb-network's releases](https://github.com/ArcadeData/arcadedb/releases).* > 25.12.1 > ------- > > ArcadeDB 25.12.1 Release Notes > ============================== > > We're excited to announce the release of ArcadeDB v25.12.1! This release includes significant bug fixes, new features, performance improvements, and dependency updates. > > Highlights > ---------- > > ### Vector Search Enhancements > > * **Fixed critical vector quantization bug** ([#3052](https://redirect.github.com/ArcadeData/arcadedb/issues/3052), [#3053](https://redirect.github.com/ArcadeData/arcadedb/issues/3053)) - INT8 and BINARY vector quantization now works correctly across all dimensions > * **New filtered vector search** ([#3071](https://redirect.github.com/ArcadeData/arcadedb/issues/3071), [#3072](https://redirect.github.com/ArcadeData/arcadedb/issues/3072)) - LSMVectorIndex now supports filtered searches for more precise queries > * **Better vector type support** ([#3090](https://redirect.github.com/ArcadeData/arcadedb/issues/3090)) - Added support for `List<Float>` in vector indexes > * **Improved compression** ([#2911](https://redirect.github.com/ArcadeData/arcadedb/issues/2911)) - Enhanced compression for LSM vector indexes > * **Fixed HNSW graph persistence** ([#2916](https://redirect.github.com/ArcadeData/arcadedb/issues/2916)) - Ensures JVector HNSW graph file is properly closed and flushed to disk > > ### SQL and Query Improvements > > * **Fixed IF statement execution** ([#2775](https://redirect.github.com/ArcadeData/arcadedb/issues/2775)) - SQL scripts with IF statements now execute correctly from console > * **Fixed index creation with IF NOT EXISTS** ([#1819](https://redirect.github.com/ArcadeData/arcadedb/issues/1819)) - Console no longer errors when creating existing indexes with IF NOT EXISTS clause > * **Custom function parameter binding** ([#3046](https://redirect.github.com/ArcadeData/arcadedb/issues/3046), [#3049](https://redirect.github.com/ArcadeData/arcadedb/issues/3049)) - Fixed parameter binding for SQL and JavaScript custom functions > * **SQL method consistency** ([#2964](https://redirect.github.com/ArcadeData/arcadedb/issues/2964), [#2967](https://redirect.github.com/ArcadeData/arcadedb/issues/2967)) - `values()` method now behaves consistently with `keys()` method > * **CONTAINSANY index fix** ([#3051](https://redirect.github.com/ArcadeData/arcadedb/issues/3051)) - Fixed index usage for lists of embedded documents with CONTAINSANY > > ### Transaction Management > > * **Revised transaction logic** ([#3074](https://redirect.github.com/ArcadeData/arcadedb/issues/3074)) - Improved transaction handling and consistency > * **Fixed edge index invalidation** ([#3091](https://redirect.github.com/ArcadeData/arcadedb/issues/3091)) - Edge indexes now remain valid in edge-case scenarios > > ### New Features > > * **Database size API** ([#3045](https://redirect.github.com/ArcadeData/arcadedb/issues/3045)) - Added new `database.getSize()` API method > * **Version display enhancement** ([#2905](https://redirect.github.com/ArcadeData/arcadedb/issues/2905)) - Server log version number now displayed consistently > > What's Changed > -------------- > > ### Bug Fixes > > * Fix INT8 and BINARY vector quantization offset bug in LSMVectorIndex page loading by [`@Copilot`](https://github.com/Copilot) in [ArcadeData/arcadedb#3053](https://redirect.github.com/ArcadeData/arcadedb/pull/3053) > * fix: revert SQL grammar changes and disable deep level JSON insert tests by [`@robfrank`](https://github.com/robfrank) in [ArcadeData/arcadedb#2961](https://redirect.github.com/ArcadeData/arcadedb/pull/2961) > * [#2915](https://redirect.github.com/ArcadeData/arcadedb/issues/2915) fix: ensure Jvector HNSW graph file is closed and flushed to disk on database close by [`@robfrank`](https://github.com/robfrank) in [ArcadeData/arcadedb#2916](https://redirect.github.com/ArcadeData/arcadedb/pull/2916) > * fix: make values method behave like keys method by [`@gramian`](https://github.com/gramian) in [ArcadeData/arcadedb#2967](https://redirect.github.com/ArcadeData/arcadedb/pull/2967) > * Fix custom function parameter binding for SQL and JavaScript functions by [`@Copilot`](https://github.com/Copilot) in [ArcadeData/arcadedb#3049](https://redirect.github.com/ArcadeData/arcadedb/pull/3049) > * fix CONTAINSANY index use for lists of embedded documents by [`@gramian`](https://github.com/gramian) in [ArcadeData/arcadedb#3051](https://redirect.github.com/ArcadeData/arcadedb/pull/3051) > * fix: support List in vector index by [`@szekelyszabi`](https://github.com/szekelyszabi) in [ArcadeData/arcadedb#3090](https://redirect.github.com/ArcadeData/arcadedb/pull/3090) > > ### Features > > * Show version number same as in server log by [`@gramian`](https://github.com/gramian) in [ArcadeData/arcadedb#2905](https://redirect.github.com/ArcadeData/arcadedb/pull/2905) > * feat: added new `database.getSize()` api by [`@lvca`](https://github.com/lvca) in [ArcadeData/arcadedb#3045](https://redirect.github.com/ArcadeData/arcadedb/pull/3045) > * Add filtered vector search support to LSMVectorIndex by [`@Copilot`](https://github.com/Copilot) in [ArcadeData/arcadedb#3072](https://redirect.github.com/ArcadeData/arcadedb/pull/3072) > * add stars chart by [`@robfrank`](https://github.com/robfrank) in [ArcadeData/arcadedb#3084](https://redirect.github.com/ArcadeData/arcadedb/pull/3084) > > ### Performance Improvements > > * Lsm vector fix by [`@lvca`](https://github.com/lvca) in [ArcadeData/arcadedb#2907](https://redirect.github.com/ArcadeData/arcadedb/pull/2907) > * perf: improved compression with lsm vectors by [`@lvca`](https://github.com/lvca) in [ArcadeData/arcadedb#2911](https://redirect.github.com/ArcadeData/arcadedb/pull/2911) ... (truncated) Commits * [`6290454`](ArcadeData/arcadedb@6290454) Set release version to 25.12.1 * [`5bdbdfa`](ArcadeData/arcadedb@5bdbdfa) chore: removed system.out * [`5764b95`](ArcadeData/arcadedb@5764b95) fix: deletion of light edge after last fix * [`a81163a`](ArcadeData/arcadedb@a81163a) fix: avoid reuse of deleted record in same tx * [`a42ae5e`](ArcadeData/arcadedb@a42ae5e) perf: avoid conversion of float[] into List<Float> in SQL engine * [`c8fb3e5`](ArcadeData/arcadedb@c8fb3e5) chore: refactoring conversion functions to float[] in a centralized method * [`de9bfcf`](ArcadeData/arcadedb@de9bfcf) fix: support List<Float> in vector index ([#3090](https://redirect.github.com/ArcadeData/arcadedb/issues/3090)) * [`9e964ef`](ArcadeData/arcadedb@9e964ef) Merge branch 'main' of <https://github.com/ArcadeData/arcadedb> * [`07c7d3e`](ArcadeData/arcadedb@07c7d3e) Fixed failing test using java * [`51a058b`](ArcadeData/arcadedb@51a058b) fix CONTAINSANY index use for lists of embedded documents ([#3051](https://redirect.github.com/ArcadeData/arcadedb/issues/3051)) * Additional commits viewable in [compare view](ArcadeData/arcadedb@25.11.1...25.12.1) [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
What does this PR do?
This change adds handling of collection arguments to the
valuesmethod, copied from thekeysmethod which already handles these argument types.Motivation
Comparing outputs of
keysandvaluesmethods.Related issues
#2964
Checklist
mvn clean packagecommand