feat(base-query): Indexable(each = true) with contains/doesNotContain#88
Merged
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
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.
@Indexablegains aneach()attribute (defaultfalse). Wheneach = true, the function is expected to return aStream,Collection, orIterable, and each element is indexed individually as a separate reverse-map key. Wheneach = false(the default), the return value is treated as a single scalar key, exactly as before. Intent is declared at the field rather than inferred at runtime from the return type, so a function returningList<Tag>is never silently treated as multi-valued unless the author explicitly opts in.AbstractHeapBasedIndexroutes scalar and each functions through entirely separate code paths (indexNonUnique/indexEach,reindexNonUnique/reindexEach) backed by two new memoizers. The previousputNonUniqueValuewith its runtimeinstanceofdispatch is removed. If aneach = truefunction returns a non-container value, it throws at index time with a clear message.Conditiongainscontains(Object element)for O(1) indexed membership lookup (falling back to a linear scan for non-indexed functions) anddoesNotContain(Object element)which always scans. Amatches-based default was considered fordoesNotContainand rejected:Matches.findAll()iterates over individual reverse-map keys rather than the original container, which would return wrong results for indexed each-functions.shouldDistinguishScalarIndexingFromEachIndexingputs both modes side by side on the sameList<Color>field --COLORS_SCALARwithisEqualTo(list)andCOLORS_EACHwithcontains(element)— making the difference concrete and executable. Additional contract tests coverCollectionandIterableelement types, reindex after mutation, the non-indexed fallback path, anddoesNotContainexclusion semantics.