From cb83c4da1f534dc4d566ae0469c53ac03de56fec Mon Sep 17 00:00:00 2001 From: Nicola Cabiddu Date: Tue, 5 Mar 2024 14:17:55 +0000 Subject: [PATCH] handle collection array for mixed types --- src/realm/cluster.cpp | 8 +++++--- src/realm/spec.cpp | 11 ++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/realm/cluster.cpp b/src/realm/cluster.cpp index 6da4891f2e7..8afd192f7eb 100644 --- a/src/realm/cluster.cpp +++ b/src/realm/cluster.cpp @@ -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)); } diff --git a/src/realm/spec.cpp b/src/realm/spec.cpp index 7efa4e21a0a..1a08606c0be 100644 --- a/src/realm/spec.cpp +++ b/src/realm/spec.cpp @@ -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; }