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

Optimize MixedNode<Equal> unindexed #6506

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Enhancements
* <New feature description> (PR [#????](https://github.com/realm/realm-core/pull/????))
* None.
* Improve performance of equality queries on a non-indexed mixed property by about 30%. ([#6506](https://github.com/realm/realm-core/issues/6506))

### Fixed
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
Expand Down
2 changes: 1 addition & 1 deletion src/realm/array_mixed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ size_t ArrayMixed::find_first(Mixed value, size_t begin, size_t end) const noexc
if (end == realm::npos)
end = size();
for (size_t i = begin; i < end; i++) {
if (this->get_type(i) == type && get(i) == value) {
if (Mixed::data_types_are_comparable(this->get_type(i), type) && get(i) == value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it changes which values get compared now - it also deserves changelog entry, no?

Also, it's fine to change it, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ArrayMixed::find_first was unused before this. When I added it in I found some failing tests, so I think there is no change log needed as there is no net new behaviour.

return i;
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/realm/query_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,7 @@ size_t MixedNode<Equal>::find_first_local(size_t start, size_t end)
return m_index_evaluator->do_search_index(m_cluster, start, end);
}
else {
Equal cond;
for (size_t i = start; i < end; i++) {
QueryValue val(m_leaf_ptr->get(i));
if (cond(val, m_value))
return i;
}
return m_leaf_ptr->find_first(m_value, start, end);
}

return not_found;
Expand Down