Skip to content

Commit

Permalink
initial support collection in mixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nicola-cab committed Mar 20, 2024
1 parent 11f1b90 commit d8f4934
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
23 changes: 21 additions & 2 deletions src/realm/bplustree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,8 +867,27 @@ ref_type BPlusTreeBase::typed_write(ref_type ref, _impl::ArrayWriterBase& out, A
}
else {
if (node.has_refs()) {
// this should be extended to handle Mixed....
return node.write(out, deep, only_modified, false); // unknown substructure, don't compress
// TODO: handle collection in mixed here. This is breaking..
Array written_node(Allocator::get_default());
written_node.create(NodeHeader::type_InnerBptreeNode, false, node.size());
for (unsigned j = 0; j < node.size(); ++j) {
RefOrTagged rot = node.get_as_ref_or_tagged(j);
if (rot.is_ref() && rot.get_as_ref()) {
// it should/could only be a nested collection
compress = true;
written_node.set_as_ref(j, BPlusTreeBase::typed_write(rot.get_as_ref(), out, alloc, col_type,
deep, only_modified, compress));
}
else {
Array a(alloc);
a.init_from_ref(rot.get_as_ref());
written_node.set_as_ref(j, a.write(out, deep, only_modified, false));
}
}
auto written_ref = written_node.write(out, false, false, false);
written_node.destroy();
return written_ref;
// return node.write(out, deep, only_modified, false); // unknown substructure, don't compress
}
else {
return node.write(out, false, only_modified, compress); // leaf array - do compress
Expand Down
12 changes: 11 additions & 1 deletion src/realm/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,17 @@ ref_type Cluster::typed_write(ref_type ref, _impl::ArrayWriterBase& out, const T

const auto do_compress = (i < 3) ? true : false;
if (i == 4) {
// TODO: handle collections in mixed
// TODO this is not working...
bool compress = true;
auto bptree_rot = leaf.get_as_ref_or_tagged(i);
if (bptree_rot.is_ref() && bptree_rot.get_as_ref()) {
written_leaf.set_as_ref(i, BPlusTreeBase::typed_write(bptree_rot.get_as_ref(), out,
m_alloc, col_type, deep,
only_modified, compress));
}
else {
written_leaf.set(i, bptree_rot);
}
}
// compress only mixed arrays that are integers. skip all the rest for now.
written_leaf.set_as_ref(
Expand Down

0 comments on commit d8f4934

Please sign in to comment.