-
-
Notifications
You must be signed in to change notification settings - Fork 79
test: add unit test for distinct value retrieval in LSM index #2330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @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 introduces a new unit test to validate the integrity of results returned when querying non-unique LSM tree indexes. The test ensures that even when multiple documents share the same indexed key, the database correctly retrieves distinct documents, preventing any spurious duplicates in the result set.
Highlights
- New Unit Test for LSM Index: A new JUnit 5 test file,
Issue2328Test.java
, has been added to theengine
module. This test focuses on verifying the behavior of LSM (Log-Structured Merge-tree) indexes. - Distinct Value Retrieval Verification: The
notUniqueShouldReturnDistinctValues
test method specifically checks that when querying a non-unique LSM index, the result set does not contain duplicate documents. It achieves this by populating the database with documents where the indexed key (p2
) is intentionally duplicated across multiple documents, but a different property (p1
) remains unique per document. The test then asserts that allp1
values retrieved from the query are distinct.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and 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 to provide feedback.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds a new unit test to verify that queries on a non-unique LSM index return distinct records. The test logic is sound. I've provided a few suggestions to improve the test code's quality and maintainability by adhering to common testing best practices.
final File tmp = File.createTempFile("ArcadeTmp", ""); | ||
tmp.delete(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System.out.println("Tmp Database: " + tmp); | ||
|
||
try(final DatabaseFactory fact = new DatabaseFactory(tmp.toString())){ | ||
try(final LocalDatabase local = (LocalDatabase) fact.create()){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good practice to program against interfaces rather than concrete implementations. The fact.create()
method returns a Database
, and all subsequent calls on local
are available on the Database
interface. Casting to LocalDatabase
is unnecessary here and makes the code more flexible.
try(final LocalDatabase local = (LocalDatabase) fact.create()){ | |
try(final Database local = fact.create()){ |
System.out.println("Found: " + count); | ||
System.out.println("Duplicates: " + dup); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(dup>0) { | ||
throw new IllegalStateException("Duplicates found: " + dup); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 preferences |
What does this PR do?
A brief description of the change being made with this pull request.
Motivation
What inspired you to submit this pull request?
Related issues
A list of issues either fixed, containing architectural discussions, otherwise relevant
for this Pull Request.
Additional Notes
Anything else we should know when reviewing?
Checklist
mvn clean package
command