Skip to content

Conversation

romange
Copy link
Collaborator

@romange romange commented Aug 8, 2023

  1. intoduce variant of Redis and Dragonfly implementation and wrap each operation with a dedicated dispatcher operator. The dragonfly implementation path is a noop and not implemented.

  2. Introduce a very basic sorted_map_test around Add and move the unrelated old test from sorted_map_test to bptree_set_test.

@romange romange requested a review from dranikpg August 8, 2023 06:36
dranikpg
dranikpg previously approved these changes Aug 8, 2023
dranikpg
dranikpg previously approved these changes Aug 8, 2023
1. intoduce variant of Redis and Dragonfly implementation and
wrap each operation with a dedicated dispatcher operator.
The dragonfly implementation path is a noop and not implemented.

2. Introduce a very basic sorted_map_test around Add and move the unrelated old test
   from sorted_map_test to bptree_set_test.

Signed-off-by: Roman Gershman <[email protected]>
dranikpg
dranikpg previously approved these changes Aug 8, 2023
Comment on lines 67 to 72
int Add(double score, sds ele, int in_flags, int* out_flags, double* newscore) {
return std::visit(
Overload{[&](RdImpl& impl) { return impl.Add(score, ele, in_flags, out_flags, newscore); },
[&](DfImpl& impl) { return impl.Add(score, ele, in_flags, out_flags, newscore); }},
impl_);
}
Copy link
Contributor

@dranikpg dranikpg Aug 8, 2023

Choose a reason for hiding this comment

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

Didn't want to bother you refactoring, but either way... 100LOC less is good 😆
Just a side note, you can use auto-lambdas (template under the hood), so you don't need to type it all out twice, i.e.

visit([](auto& impl) { impl.Add(); }, impl_)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was not sure I can, I thought this feature actually requires explicit override so it will deduce the base class types. checking it now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

indeed, it works. PTAL

Signed-off-by: Roman Gershman <[email protected]>
Copy link
Contributor

@dranikpg dranikpg left a comment

Choose a reason for hiding this comment

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

One last nit: you don't need the Overload around the lambda 😬

@romange
Copy link
Collaborator Author

romange commented Aug 8, 2023

One last nit: you don't need the Overload around the lambda grimacing

hmm, it won't reduce number of lines, I will leave it as is :)

@romange romange merged commit 464fa30 into main Aug 9, 2023
@romange romange deleted the RefactorSM branch August 9, 2023 08:17
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