Skip to content

Commit

Permalink
split rtree_to_capnp, call it in fragment_info
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbindar committed Sep 2, 2024
1 parent b151e6b commit 3b25115
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
3 changes: 0 additions & 3 deletions tiledb/sm/serialization/array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,6 @@ void array_from_capnp(
// pass the right schema to deserialize fragment metadata
throw_if_not_ok(
fragment_metadata_from_capnp(schema, frag_meta_reader, meta));
// if (client_side) {
// meta->loaded_metadata()->set_rtree_loaded();
// }
fragment_metadata.emplace_back(meta);
}
array->set_fragment_metadata(std::move(fragment_metadata));
Expand Down
2 changes: 2 additions & 0 deletions tiledb/sm/serialization/fragment_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ Status single_fragment_info_to_capnp(
auto frag_meta_builder = single_frag_info_builder->initMeta();
RETURN_NOT_OK(
fragment_metadata_to_capnp(*single_frag_info.meta(), &frag_meta_builder));
rtree_to_capnp(
single_frag_info.meta()->loaded_metadata()->rtree(), &frag_meta_builder);

// set fragment size
single_frag_info_builder->setFragmentSize(single_frag_info.fragment_size());
Expand Down
33 changes: 19 additions & 14 deletions tiledb/sm/serialization/fragment_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,25 @@ void fragment_meta_sizes_offsets_to_capnp(
}
}
}

rtree_to_capnp(frag_meta.loaded_metadata()->rtree(), frag_meta_builder);
}

void rtree_to_capnp(
const RTree& rtree, capnp::FragmentMetadata::Builder* frag_meta_builder) {
// TODO: Can this be done better? Does this make a lot of copies?
SizeComputationSerializer size_computation_serializer;
rtree.serialize(size_computation_serializer);
if (size_computation_serializer.size() != 0) {
std::vector<uint8_t> buff(size_computation_serializer.size());
Serializer serializer(buff.data(), buff.size());
rtree.serialize(serializer);

auto vec = kj::Vector<uint8_t>();
vec.addAll(
kj::ArrayPtr<uint8_t>(static_cast<uint8_t*>(buff.data()), buff.size()));
frag_meta_builder->setRtree(vec.asPtr());
}
}

Status fragment_metadata_to_capnp(
Expand Down Expand Up @@ -691,20 +710,6 @@ Status fragment_metadata_to_capnp(
frag_meta.non_empty_domain(),
frag_meta.array_schema()->dim_num()));

// TODO: Can this be done better? Does this make a lot of copies?
SizeComputationSerializer size_computation_serializer;
frag_meta.loaded_metadata()->rtree().serialize(size_computation_serializer);
if (size_computation_serializer.size() != 0) {
std::vector<uint8_t> buff(size_computation_serializer.size());
Serializer serializer(buff.data(), buff.size());
frag_meta.loaded_metadata()->rtree().serialize(serializer);

auto vec = kj::Vector<uint8_t>();
vec.addAll(
kj::ArrayPtr<uint8_t>(static_cast<uint8_t*>(buff.data()), buff.size()));
frag_meta_builder->setRtree(vec.asPtr());
}

auto gt_offsets_builder = frag_meta_builder->initGtOffsets();
generic_tile_offsets_to_capnp(
frag_meta.generic_tile_offsets(), gt_offsets_builder);
Expand Down
9 changes: 9 additions & 0 deletions tiledb/sm/serialization/fragment_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ void fragment_meta_sizes_offsets_to_capnp(
const FragmentMetadata& frag_meta,
capnp::FragmentMetadata::Builder* frag_meta_builder);

/**
* Serializes FragmentMetadata's RTree to Cap'n Proto message
*
* @param rtree RTREE to serialize
* @param frag_meta_builder cap'n proto class
*/
void rtree_to_capnp(
const RTree& rtree, capnp::FragmentMetadata::Builder* frag_meta_builder);

/**
* Convert Fragment Metadata to Cap'n Proto message
*
Expand Down

0 comments on commit 3b25115

Please sign in to comment.