Skip to content

Commit

Permalink
Update Stats deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunrd0 authored and KiterLuc committed Feb 15, 2024
1 parent e40bd16 commit 47dcb23
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
3 changes: 2 additions & 1 deletion test/support/src/serialization_wrappers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/

#include "test/support/src/helpers.h"
#include "tiledb/api/c_api/context/context_api_internal.h"
#include "tiledb/sm/c_api/tiledb.h"
#include "tiledb/sm/c_api/tiledb_serialization.h"
#include "tiledb/sm/c_api/tiledb_struct_def.h"
Expand Down Expand Up @@ -205,7 +206,7 @@ void tiledb_subarray_serialize(
// Deserialize
tiledb_subarray_t* deserialized_subarray;
auto layout = (*subarray)->subarray_->layout();
auto stats = (*subarray)->subarray_->stats();
auto stats = ctx->storage_manager()->stats()->create_child("Subarray");
shared_ptr<Logger> dummy_logger = make_shared<Logger>(HERE(), "");

tiledb::test::require_tiledb_ok(
Expand Down
10 changes: 3 additions & 7 deletions tiledb/sm/serialization/query.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,7 @@ Subarray subarray_from_capnp(
}
}

// If cap'n proto object has stats set it on c++ object
Subarray s(array, layout, parent_stats, logger, true);
if (reader.hasStats()) {
auto stats_data = stats_from_capnp(reader.getStats());
subarray->set_stats(stats_data);
}
const auto& stats_data = stats_from_capnp(reader.getStats());

std::vector<unsigned> relevant_fragments;
if (reader.hasRelevantFragments()) {
Expand All @@ -356,7 +351,8 @@ Subarray subarray_from_capnp(
return {
array->opened_array(),
layout,
reader.hasStats() ? s.stats() : parent_stats,
parent_stats,
stats_data,
logger,
range_subset,
is_default,
Expand Down
9 changes: 3 additions & 6 deletions tiledb/sm/subarray/subarray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,16 @@ Subarray::Subarray(
Subarray::Subarray(
const shared_ptr<OpenedArray> opened_array,
Layout layout,
stats::Stats* stats,
stats::Stats* parent_stats,
const stats::StatsData& stats_data,
shared_ptr<Logger> logger,
std::vector<RangeSetAndSuperset> range_subset,
std::vector<bool> is_default,
std::vector<optional<Subarray::LabelRangeSubset>> label_range_subset,
std::unordered_map<std::string, std::vector<Range>> attr_range_subset,
RelevantFragments relevant_fragments,
bool coalesce_ranges)
: stats_(stats)
: stats_(parent_stats->create_child("Subarray", stats_data))
, logger_(std::move(logger))
, array_(opened_array)
, layout_(layout)
Expand Down Expand Up @@ -3103,10 +3104,6 @@ const stats::Stats& Subarray::stats() const {
return *stats_;
}

void Subarray::set_stats(const stats::StatsData& data) {
stats_->populate_with_data(data);
}

tuple<Status, optional<bool>> Subarray::non_overlapping_ranges_for_dim(
const uint64_t dim_idx) {
const auto& ranges = range_subset_[dim_idx].ranges();
Expand Down
16 changes: 5 additions & 11 deletions tiledb/sm/subarray/subarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ class Subarray {
* if the subarray is used for reads, or of the values provided
* by the user for writes).
* @param parent_stats The parent stats to inherit from.
* @param logger The parent logger to clone and use for logging
* @param stats_data The stats data to use for the subarray.
* @param logger The parent logger to clone and use for logging.
* @param range_subset Vector of RangeSetAndSuperset for each dimension.
* @param is_default Vector of boolean indicating if the range is default.
* @param label_range_subset Vector of optional<LabelRangeSubset> for each
Expand All @@ -339,12 +340,13 @@ class Subarray {
* each attribute.
* @param relevant_fragments RelevantFragments object for the subarray.
* @param coalesce_ranges When enabled, ranges will attempt to coalesce
* with existing ranges as they are added
* with existing ranges as they are added.
*/
Subarray(
const shared_ptr<OpenedArray> opened_array,
Layout layout,
stats::Stats* stats,
stats::Stats* parent_stats,
const stats::StatsData& stats_data,
shared_ptr<tiledb::common::Logger> logger,
std::vector<RangeSetAndSuperset> range_subset,
std::vector<bool> is_default,
Expand Down Expand Up @@ -1336,14 +1338,6 @@ class Subarray {
/** Returns `stats_`. */
const stats::Stats& stats() const;

/**
* Populate the owned stats instance with data.
* To be removed when the class will get a C41 constructor.
*
* @param data Data to populate the stats with.
*/
void set_stats(const stats::StatsData& data);

/** Stores a vector of 1D ranges per dimension. */
std::vector<std::vector<uint64_t>> original_range_idx_;

Expand Down

0 comments on commit 47dcb23

Please sign in to comment.