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

Use search index also when following links #3432

Merged
merged 5 commits into from
Oct 22, 2019
Merged

Conversation

jedelbo
Copy link
Contributor

@jedelbo jedelbo commented Oct 21, 2019

Change-Id: Ia8888fcf8530fd9b14740cab7228d320a0832887

Change-Id: Ia8888fcf8530fd9b14740cab7228d320a0832887
Copy link
Contributor

@finnschiermer finnschiermer left a comment

Choose a reason for hiding this comment

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

Virtually Epic!

template <>
inline Mixed get_mixed(const Value<RowIndex>&)
{
return Mixed();
Copy link
Contributor

Choose a reason for hiding this comment

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

assert(false) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

@@ -3883,6 +3986,22 @@ class Compare : public Expression {
{
m_left->set_base_table(table);
m_right->set_base_table(table);
if (std::is_same<TCond, Equal>::value && m_left_is_const && m_right->has_search_index()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know that this will be triggered if the query is re-evaluated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the init function is called as part of both Query::find and Query::find:all

@@ -12218,5 +12218,66 @@ TEST(Query_StringOrLongStrings)
}
}

TEST(Query_LinksWithIndex)
Copy link
Contributor

@finnschiermer finnschiermer Oct 21, 2019

Choose a reason for hiding this comment

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

I think we need unittests demonstrating correct operation across table changes and sync_if_needed() on dependent tableview

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test case modified.

Change-Id: If013cf622825a192ab00025f6b7832459b2d3550
@jedelbo jedelbo force-pushed the je/query-over-links branch from 289d77b to 6d7443b Compare October 21, 2019 12:49
Change-Id: Ief3c1b7b40e4c2d9188c3d1993404f503eba232e
@jedelbo jedelbo force-pushed the je/query-over-links branch from b181daa to 14028b8 Compare October 21, 2019 13:31
Copy link
Contributor

@ironage ironage left a comment

Choose a reason for hiding this comment

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

Changes look good to me!
It would have been nice to see a benchmark showing the improvement, but that's not blocking.

@@ -101,6 +101,11 @@ class BinaryColumn : public ColumnBaseSimple {
void verify() const override;
void to_dot(std::ostream&, StringData title) const override;
void do_dump_node_structure(std::ostream&, int) const override;
void find_all(IntegerColumn&, BinaryData, size_t, size_t) const
{
// Dummy implementation
Copy link
Contributor

Choose a reason for hiding this comment

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

assert false here too?

@@ -113,6 +113,11 @@ class TimestampColumn : public ColumnBaseSimple {
return npos;
}

void find_all(IntegerColumn&, Timestamp, size_t, size_t) const
{
// Dummy implementation
Copy link
Contributor

Choose a reason for hiding this comment

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

Timestamp column supports an index, doesn't this need to be implemented?

Change-Id: I564c45bcee7f64a296138e273171c015b802b073
Change-Id: I3354eebcd03e4578da92ce9a137bb13e2ea48579
@jedelbo jedelbo force-pushed the je/query-over-links branch from 5ba012c to 5b81529 Compare October 22, 2019 07:13
Copy link
Contributor

@ironage ironage left a comment

Choose a reason for hiding this comment

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

Nice 💯

@jedelbo jedelbo merged commit 61c114e into master Oct 22, 2019
@jedelbo jedelbo deleted the je/query-over-links branch October 22, 2019 07:25
tgoyne added a commit that referenced this pull request May 29, 2020
The optimization added in #3432 to use the search index when performing
equality queries over a link assumed that Queries would be evaluated in
ascending table order, which is not always the case when the query is being
performed on a link list.

Fixes realm/realm-swift#6540.
tgoyne added a commit that referenced this pull request May 29, 2020
The optimization added in #3432 to use the search index when performing
equality queries over a link assumed that Queries would be evaluated in
ascending table order, which is not always the case when the query is being
performed on a link list.

Fixes realm/realm-swift#6540.
jedelbo added a commit that referenced this pull request Jun 2, 2020
…er (#3752)

The optimization added in #3432 to use the search index when performing
equality queries over a link assumed that Queries would be evaluated in
ascending table order, which is not always the case when the query is being
performed on a link list.

Fixes realm/realm-swift#6540.

* Remove an unused member variable

Co-authored-by: Jørgen Edelbo <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants