-
Notifications
You must be signed in to change notification settings - Fork 152
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
Basic support for nested collections #6452
Conversation
72dd2cd
to
720e62d
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.
LGTM.
test_lists_numeric_agg<Decimal128>(test_context, sg, type_Decimal, Decimal128(realm::null()), true); | ||
} | ||
|
||
TEST(List_NestedListColumns) |
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.
Just a general comment we are missing some testing around links since you have added support for them compared to the original implementation.
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.
This PR soes not include support for links
, m_col_key(col_key) | ||
, m_top(*m_alloc) | ||
, m_refs(*m_alloc) | ||
, m_key_type(coll_type == CollectionType::List ? type_Int : type_String) |
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 would expect there to be some way to specify the key type of dictionaries, but the API here doesn't allow any control over that. Will we not support intermediate Dictionaries of Int key types by design?
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 don't think we will support dictionaries with other key types than strings in the foreseeable future. The only reason we support integers in our Dictionary implementation was just to indicate how that would work.
src/realm/table.cpp
Outdated
break; | ||
} | ||
if (collection_types.size() > 1) { | ||
// FIXME |
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.
Is this still needed? I think you handle the spec below.
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.
Yes, this is a leftover from an earlier stage
src/realm/column_type.hpp
Outdated
@@ -24,6 +24,8 @@ | |||
|
|||
namespace realm { | |||
|
|||
enum class CollectionType { List, Set, Dictionary }; |
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.
Since this is part of the file format in the spec, can you assign explicit values and add a comment that changing these will mean a file format breaking change?
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.
👍
CollectionListPtr get_collection_list(size_t ndx) const; | ||
|
||
void remove(size_t ndx); // TODO | ||
void remove(StringData key); // TODO |
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.
todo
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.
This stuff should have been implemented already in je/list-list. Probably we can remove this code if we intend to merge it into a separate PR
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.
This comes in a subsequent PR
src/realm/spec.cpp
Outdated
@@ -323,6 +331,15 @@ void Spec::erase_column(size_t column_ndx) | |||
REALM_ASSERT(column_ndx < m_types.size()); | |||
|
|||
if (ColumnType(int(m_types.get(column_ndx))) != col_type_BackLink) { | |||
if (auto ref = m_top.get_as_ref(3)) { |
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.
could be nice to have a named constant for position 3
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.
Done
auto list = obj.get_collection_list(list_col1); | ||
CHECK(list->is_empty()); | ||
auto collection = list->insert_collection(0); | ||
dynamic_cast<Lst<Int>*>(collection.get())->add(5); |
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.
SDKs will probably want a more typed API than using dynamic casts. At least that has been the traditional approach.
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.
Yes, lets see. Anyway that would be implemented in the ObjectStore interface.
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.
Anyway - I added a couple of functions. Will actually make some testing easier to write.
CHECK_EQUAL(table->get_nesting_levels(list_col2), 2); | ||
} | ||
|
||
TEST(List_NestedList) |
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.
Could also use some testing around removing nested collections and removing columns of nested collections.
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.
More testing has already been added around this are, things have been cherry-picked in this PR.
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.
Added removing of the column. Removing nested collections will come later.
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 still missing some of the original code, LGTM.
798de1c
to
adbc0d2
Compare
adbc0d2
to
7a194a9
Compare
What, How & Why?
☑️ ToDos