Skip to content
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

Global Unique Index #88

Merged
merged 7 commits into from
Sep 26, 2024
Merged

Conversation

g-sg-v
Copy link
Contributor

@g-sg-v g-sg-v commented Sep 23, 2024

No description provided.

@g-sg-v g-sg-v requested a review from nvamelichev September 23, 2024 15:31
@g-sg-v g-sg-v marked this pull request as ready for review September 23, 2024 16:15
Copy link
Collaborator

@nvamelichev nvamelichev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall 👍
Minor changes requested

/**
* Is unique index type
*/
boolean unique() default false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "unique" an index type or a property of any index that can be created? If it's a dedicated index type, we should use an enum instead, I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to enum

}

private Map<String, Object> buildIndexValues(Schema.Index index, T entity) {
Map<String, Object> cells = schema.flatten(entity);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, Schema.flatten() is not guaranteed to return a mutable map (but in practice, it does).

I would probably use .entrySet().stream().filter(...).collect(toMap(...)); instead, to filter out fields not belonging to the index (and it would create a new map).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe new HashMap<>(...); =)? Same result - less code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make a new HashMap<>() 👍

@nvamelichev nvamelichev merged commit eb8de29 into ydb-platform:main Sep 26, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants