-
Notifications
You must be signed in to change notification settings - Fork 173
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
Lexicographical comparison for string queries #7273
Conversation
Pull Request Test Coverage Report for Build james.stone_480
💛 - Coveralls |
There is a discrepancy between how nulls behave in this and the way it works in the string based queries; converting this to a draft until I investigate further. |
070690f
to
23d5873
Compare
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.
nice! There is a lint issue to be fixed.
src/realm/query_engine.hpp
Outdated
if (cond(StringData(m_value), m_ucase.c_str(), m_lcase.c_str(), t)) | ||
return s; | ||
if constexpr (case_sensitive_comparison) { | ||
// case insensitive not implemented for these comparisons |
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.
nit: probably a better comment here is needed, we are talking about string lexicographical comparisons, right?
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.
right, updated the comment to be specific
@@ -1545,9 +1544,14 @@ class StringNodeBase : public ParentNode { | |||
template <class TConditionFunction> | |||
class StringNode : public StringNodeBase { | |||
public: | |||
constexpr static bool case_sensitive_comparison = |
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.
nit: I guess you want this constexpr
, available at compile time, but do you need this to be static as well, in order to be used like this StringNode::case_sensitive_comparison
?
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 is a compile error to remove the static on a constexpr member
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.
I was more thinking whether you needed it as public
member, or you could just have a constexpr
variable defined in the method.
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.
Oh I see. Well I suppose it doesn't need to be public, but I'd like it at the class scope because I use it for a small optimization in the constructor as well.
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.
LGTM
This feature was requested by realm/realm-swift#8008.
I also added a small performance improvement for string queries; no need to always convert the constant
std::optional<std::string>
to aStringData
in the hot query path, it can be done once in the constructor of the query node.☑️ ToDos
bindgen/spec.yml
, if public C++ API changed