Add flex.coll.subtract/containsAll/containsAny/flatten helpers#45
Add flex.coll.subtract/containsAll/containsAny/flatten helpers#45shahar-biron wants to merge 4 commits intomainfrom
Conversation
Co-Authored-By: Warp <agent@warp.dev>
|
Static Code Review 📊 ✅ All quality checks passed! |
📝 WalkthroughWalkthroughAdds four collection utility modules— Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Free 📒 Files selected for processing (1)
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Coverage reportCaution Test run failed
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run failedFailed tests: 7/70. Failed suites: 3/27.Report generated by 🧪jest coverage report action from 66c1221 |
handling toRemove null Co-authored-by: typo-app[bot] <139475626+typo-app[bot]@users.noreply.github.com>
Co-Authored-By: Warp <agent@warp.dev>
swilly22
left a comment
There was a problem hiding this comment.
Do you see these functions in APOC?
each function should have its own test file
each function should be documented under the docs folder.
Co-Authored-By: Warp <agent@warp.dev>
| // Seed the Set with `a` and copy `a` to result. | ||
| // This preserves the relative order of elements in `a`. | ||
| const set = new Set(a); | ||
| const result = a.slice(); |
There was a problem hiding this comment.
logic: The union function keeps duplicates from the first array a. Initialize result from the set to ensure uniqueness.
| const result = a.slice(); | |
| const result = [...set]; |
This PR implements the remaining collection helpers proposed in
scope-features/read-only-flex-scope.mdsection 2.3 (Rich Collection Helpers).\n\n### Changes\n- Add new collection helper modules undersrc/collections/:\n -flex.coll.subtract(list, toRemove)– remove elements appearing intoRemovefromlist, preserving order.\n -flex.coll.containsAll(list, candidates)– true iff all non-null candidates are contained in the list.\n -flex.coll.containsAny(list, candidates)– true iff any non-null candidate is contained in the list.\n -flex.coll.flatten(nestedList)– one-level flatten of nested lists.\n- Register UDFs ascoll.subtract,coll.containsAll,coll.containsAny, andcoll.flatten.\n- Export the helper functions viamodule.exportsfor Jest, matching the existing pattern used byfrequencies,union,zip, etc.\n- Addtests/collections/subtractContainsFlatten.test.jswhich exercises each helper both via FLEX UDFs in FalkorDB and via direct module imports.\n\n### Notes\n- All tests pass locally with:\n -FLEX_USE_LOCAL_FALKORDB=1 npm test -- --coverage --coverageReporters=json-summary\n- Collections coverage is now near 100% for the new helpers.\n\nRelated issue: #44Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.
PR Summary by Typo
Overview
This PR introduces four new utility functions for collection manipulation (
subtract,containsAll,containsAny,flatten) and refactors the existingunionfunction for improved performance and robustness. These additions enhance theflex.colllibrary with more versatile array operations.Key Changes
flex.coll.subtractto return a new list with specified elements removed.flex.coll.containsAllto check if a list contains all elements from a candidate list.flex.coll.containsAnyto check if a list contains any element from a candidate list.flex.coll.flattenfor one-level flattening of nested arrays.flex.coll.unionto be more allocation- and GC-friendly, and to handle non-array inputs more gracefully.Work Breakdown
To turn off PR summary, please visit Notification settings.