Skip to content

Commit

Permalink
handle collection array for mixed types
Browse files Browse the repository at this point in the history
  • Loading branch information
nicola-cab committed Mar 5, 2024
1 parent 65b78aa commit cb83c4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/realm/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1646,12 +1646,14 @@ ref_type Cluster::typed_write(ref_type ref, _impl::ArrayWriterBase& out, const T
written_leaf.set_as_ref(1, Array::write(rot1.get_as_ref(), m_alloc, out, only_modified, true));
}
else if (col_type == col_type_Mixed) {
// REALM_ASSERT(leaf.size() == 4);
for (size_t i = 0; i < leaf.size(); ++i) {
const auto sz = leaf.size();
REALM_ASSERT(sz == 6);
for (size_t i = 0; i < sz; ++i) {
auto rot = leaf.get_as_ref_or_tagged(i);
if (rot.is_ref() && rot.get_as_ref()) {
// entries 0-2 are integral and can be compressed, entry 3 is strings and not compressed (yet)
bool do_compress = compress && i < 3;
// collections in mixed are stored at position 4.
bool do_compress = (i < 3 || i == 4) ? true : false;
written_leaf.set_as_ref(
i, Array::write(rot.get_as_ref(), m_alloc, out, only_modified, do_compress));
}
Expand Down
11 changes: 2 additions & 9 deletions src/realm/spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,8 @@ bool Spec::operator==(const Spec& spec) const noexcept

ColKey Spec::get_key(size_t column_ndx) const
{
auto val = m_keys.get(column_ndx);

auto key = ColKey(val);
// when type is not valid ... val == -128
auto type = key.get_type();
// type is 0x20 ObjectId | TypeLink ... in the test we are setting a backlink
if (!type.is_valid())
REALM_ASSERT(m_keys.is_encoded());
REALM_ASSERT(type.is_valid());
const auto val = m_keys.get(column_ndx);
const auto key = ColKey(val);
return key;
}

Expand Down

0 comments on commit cb83c4d

Please sign in to comment.