refactor: enhance list indexing and full-text search capabilities#2720
refactor: enhance list indexing and full-text search capabilities#2720
Conversation
Summary of ChangesHello @robfrank, 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 significantly enhances the database's indexing and search capabilities, particularly for multi-value fields. It introduces robust support for 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
|
There was a problem hiding this comment.
Code Review
This pull request is a solid refactoring effort that enhances multi-value type handling in SQL operators, improves type safety, and simplifies schema management. The changes are well-implemented and align with modern Java practices. The addition of full-text and LIKE search capabilities on list items is a significant improvement, and the new tests provide good coverage for this functionality. I have one minor suggestion to improve code maintainability by removing magic numbers.
| if (indexField.endsWith(" by key")) { | ||
| baseFieldName = indexField.substring(0, indexField.length() - 7); | ||
| } else if (indexField.endsWith(" by value")) { | ||
| baseFieldName = indexField.substring(0, indexField.length() - 9); | ||
| } else if (indexField.endsWith(" by item")) { | ||
| baseFieldName = indexField.substring(0, indexField.length() - 8); | ||
| } |
There was a problem hiding this comment.
To improve readability and maintainability, it's better to avoid using magic numbers for the substring lengths. You can instead use the length() of the suffix strings. This makes the code more self-documenting and less prone to errors if the suffix strings are ever changed.
| if (indexField.endsWith(" by key")) { | |
| baseFieldName = indexField.substring(0, indexField.length() - 7); | |
| } else if (indexField.endsWith(" by value")) { | |
| baseFieldName = indexField.substring(0, indexField.length() - 9); | |
| } else if (indexField.endsWith(" by item")) { | |
| baseFieldName = indexField.substring(0, indexField.length() - 8); | |
| } | |
| if (indexField.endsWith(" by key")) { | |
| baseFieldName = indexField.substring(0, indexField.length() - " by key".length()); | |
| } else if (indexField.endsWith(" by value")) { | |
| baseFieldName = indexField.substring(0, indexField.length() - " by value".length()); | |
| } else if (indexField.endsWith(" by item")) { | |
| baseFieldName = indexField.substring(0, indexField.length() - " by item".length()); | |
| } |
🧪 CI InsightsHere's what we observed from your CI run for 89c65d5. 🟢 All jobs passed!But CI Insights is watching 👀 |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesFootnotes
|
This pull request introduces several improvements and refactorings across the codebase, focusing on better handling of multi-value types in SQL operators, modernization of type usage, and simplification of index creation and schema management. The most impactful changes are grouped below.
Multi-value support in SQL operators
LikeOperatorandMatchesConditionto correctly handle multi-value types (such as lists and iterables), allowing them to match any contained value rather than failing or matching only the outer object. This improves query flexibility for collections. [1] [2]MultiValueto use modern Java features such asgetFirst()andgetLast()for lists, and streamlined iterator handling for better readability and performance. [1] [2] [3] [4]Type safety and code modernization
IndexFactoryHandlerby specifying generic parameters for theIndexBuilder, reducing the risk of runtime type errors.Index and schema management
NULL_STRATEGYenum to reference it directly (rather than viaLSMTreeIndexAbstract), simplifying method signatures and configuration handling throughoutLocalSchema. [1] [2] [3] [4] [5] [6] [7] [8]Indexing improvements
DocumentIndexerby using pattern matching for type checks, ensuring robust error handling and clearer code.SelectExecutionPlannerto correctly strip index modifiers (like "by key", "by value", "by item") for more accurate index field matching. [1] [2]