Skip to content

Commit

Permalink
Clean-up FragmentMetadata: remove unused methods, add missing const…
Browse files Browse the repository at this point in the history
… qualifiers and return small values by value.
  • Loading branch information
teo-tsirpanis committed Jan 29, 2024
1 parent 6ca3916 commit 7bf109f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 229 deletions.
39 changes: 6 additions & 33 deletions tiledb/sm/fragment/fragment_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1422,10 +1422,6 @@ URI FragmentMetadata::validity_uri(const std::string& name) const {
encoded_name + "_validity" + constants::file_suffix);
}

const std::string& FragmentMetadata::array_schema_name() {
return array_schema_name_;
}

void FragmentMetadata::load_tile_offsets(
const EncryptionKey& encryption_key, std::vector<std::string>& names) {
// Sort 'names' in ascending order of their index. The
Expand Down Expand Up @@ -1705,7 +1701,7 @@ uint64_t FragmentMetadata::tile_size(
}

uint64_t FragmentMetadata::tile_var_size(
const std::string& name, uint64_t tile_idx) {
const std::string& name, uint64_t tile_idx) const {
auto it = idx_map_.find(name);
assert(it != idx_map_.end());
auto idx = it->second;
Expand Down Expand Up @@ -1925,7 +1921,8 @@ uint64_t FragmentMetadata::get_tile_null_count(
return tile_null_counts_[idx][tile_idx];
}

std::vector<uint8_t>& FragmentMetadata::get_min(const std::string& name) {
const std::vector<uint8_t>& FragmentMetadata::get_min(
const std::string& name) const {
auto it = idx_map_.find(name);
assert(it != idx_map_.end());
auto idx = it->second;
Expand All @@ -1947,7 +1944,8 @@ std::vector<uint8_t>& FragmentMetadata::get_min(const std::string& name) {
return fragment_mins_[idx];
}

std::vector<uint8_t>& FragmentMetadata::get_max(const std::string& name) {
const std::vector<uint8_t>& FragmentMetadata::get_max(
const std::string& name) const {
auto it = idx_map_.find(name);
assert(it != idx_map_.end());
auto idx = it->second;
Expand All @@ -1969,7 +1967,7 @@ std::vector<uint8_t>& FragmentMetadata::get_max(const std::string& name) {
return fragment_maxs_[idx];
}

void* FragmentMetadata::get_sum(const std::string& name) {
const void* FragmentMetadata::get_sum(const std::string& name) const {
auto it = idx_map_.find(name);
assert(it != idx_map_.end());
auto idx = it->second;
Expand Down Expand Up @@ -4697,23 +4695,6 @@ void FragmentMetadata::store_footer(const EncryptionKey&) {
resources_->stats().add_counter("write_frag_meta_footer_size", tile.size());
}

void FragmentMetadata::resize_tile_offsets_vectors(uint64_t size) {
tile_offsets_mtx().resize(size);
tile_offsets().resize(size);
}

void FragmentMetadata::resize_tile_var_offsets_vectors(uint64_t size) {
tile_var_offsets_mtx().resize(size);
tile_var_offsets().resize(size);
}

void FragmentMetadata::resize_tile_var_sizes_vectors(uint64_t size) {
tile_var_sizes().resize(size);
}
void FragmentMetadata::resize_tile_validity_offsets_vectors(uint64_t size) {
tile_validity_offsets().resize(size);
}

void FragmentMetadata::clean_up() {
auto fragment_metadata_uri =
fragment_uri_.join_path(constants::fragment_metadata_filename);
Expand Down Expand Up @@ -4750,14 +4731,6 @@ void FragmentMetadata::build_idx_map() {
}
}

void FragmentMetadata::set_schema_name(const std::string& name) {
array_schema_name_ = name;
}

void FragmentMetadata::set_dense(bool dense) {
dense_ = dense;
}

// Explicit template instantiations
template std::vector<std::pair<uint64_t, double>>
FragmentMetadata::compute_overlapping_tile_ids_cov<int8_t>(
Expand Down
202 changes: 10 additions & 192 deletions tiledb/sm/fragment/fragment_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class FragmentMetadata {
return has_delete_meta_;
}

inline bool has_tile_metadata() {
inline bool has_tile_metadata() const {
return version_ >= constants::tile_metadata_min_version;
}

Expand Down Expand Up @@ -762,12 +762,6 @@ class FragmentMetadata {
*/
void set_array_schema(const shared_ptr<const ArraySchema>& array_schema);

/** Sets the array_schema name */
void set_schema_name(const std::string& name);

/** Sets the internal dense_ field*/
void set_dense(bool dense);

/** Returns the number of tiles in the fragment. */
uint64_t tile_num() const;

Expand All @@ -781,7 +775,9 @@ class FragmentMetadata {
URI validity_uri(const std::string& name) const;

/** Return the array schema name. */
const std::string& array_schema_name();
const std::string& array_schema_name() const {
return array_schema_name_;
}

/**
* Retrieves the starting offset of the input tile of the input attribute
Expand Down Expand Up @@ -878,7 +874,7 @@ class FragmentMetadata {
* @param tile_idx The index of the tile in the metadata.
* @return Size.
*/
uint64_t tile_var_size(const std::string& name, uint64_t tile_idx);
uint64_t tile_var_size(const std::string& name, uint64_t tile_idx) const;

/**
* Retrieves the tile min value for a given attribute or dimension and tile
Expand Down Expand Up @@ -930,23 +926,23 @@ class FragmentMetadata {
* @param name The input attribute/dimension.
* @return Value.
*/
std::vector<uint8_t>& get_min(const std::string& name);
const std::vector<uint8_t>& get_min(const std::string& name) const;

/**
* Retrieves the max value for a given attribute or dimension.
*
* @param name The input attribute/dimension.
* @return Value.
*/
std::vector<uint8_t>& get_max(const std::string& name);
const std::vector<uint8_t>& get_max(const std::string& name) const;

/**
* Retrieves the sum value for a given attribute or dimension.
*
* @param name The input attribute/dimension.
* @return Sum.
*/
void* get_sum(const std::string& name);
const void* get_sum(const std::string& name) const;

/**
* Retrieves the null count value for a given attribute or dimension.
Expand Down Expand Up @@ -1110,173 +1106,15 @@ class FragmentMetadata {
*
* @return
*/
const shared_ptr<const ArraySchema>& array_schema() const;

/** File sizes accessor */
std::vector<uint64_t>& file_sizes() {
return file_sizes_;
}

/** File var sizes accessor */
std::vector<uint64_t>& file_var_sizes() {
return file_var_sizes_;
}

/** File validity sizes accessor */
std::vector<uint64_t>& file_validity_sizes() {
return file_validity_sizes_;
}

/** Fragment uri accessor */
URI& fragment_uri() {
return fragment_uri_;
}

/** has_timestamps accessor */
bool& has_timestamps() {
return has_timestamps_;
}

/** has_delete_meta accessor */
bool& has_delete_meta() {
return has_delete_meta_;
}

/** has_consolidated_footer accessor */
bool& has_consolidated_footer() {
return has_consolidated_footer_;
}

/** sparse_tile_num accessor */
uint64_t& sparse_tile_num() {
return sparse_tile_num_;
}

/** tile_index_base accessor */
uint64_t& tile_index_base() {
return tile_index_base_;
}

/** tile_offsets accessor */
std::vector<std::vector<uint64_t>>& tile_offsets() {
return tile_offsets_;
}

/** tile_offsets_mtx accessor */
std::deque<std::mutex>& tile_offsets_mtx() {
return tile_offsets_mtx_;
}

/** tile_var_offsets accessor */
std::vector<std::vector<uint64_t>>& tile_var_offsets() {
return tile_var_offsets_;
}

/** tile_var_offsets_mtx accessor */
std::deque<std::mutex>& tile_var_offsets_mtx() {
return tile_var_offsets_mtx_;
}

/** tile_var_sizes accessor */
std::vector<std::vector<uint64_t>>& tile_var_sizes() {
return tile_var_sizes_;
}

/** tile_validity_offsets accessor */
std::vector<std::vector<uint64_t>>& tile_validity_offsets() {
return tile_validity_offsets_;
}

/** tile_min_buffer accessor */
std::vector<std::vector<uint8_t>>& tile_min_buffer() {
return tile_min_buffer_;
}

/** tile_min_var_buffer accessor */
std::vector<std::vector<char>>& tile_min_var_buffer() {
return tile_min_var_buffer_;
}

/** tile_max_buffer accessor */
std::vector<std::vector<uint8_t>>& tile_max_buffer() {
return tile_max_buffer_;
}

/** tile_max_var_buffer accessor */
std::vector<std::vector<char>>& tile_max_var_buffer() {
return tile_max_var_buffer_;
}

/** tile_sums accessor */
std::vector<std::vector<uint8_t>>& tile_sums() {
return tile_sums_;
}

/** tile_null_counts accessor */
std::vector<std::vector<uint64_t>>& tile_null_counts() {
return tile_null_counts_;
}

/** fragment_mins accessor */
std::vector<std::vector<uint8_t>>& fragment_mins() {
return fragment_mins_;
}

/** fragment_maxs accessor */
std::vector<std::vector<uint8_t>>& fragment_maxs() {
return fragment_maxs_;
}

/** fragment_sums accessor */
std::vector<uint64_t>& fragment_sums() {
return fragment_sums_;
}

/** fragment_null_counts accessor */
std::vector<uint64_t>& fragment_null_counts() {
return fragment_null_counts_;
}

/** version accessor */
uint32_t& version() {
return version_;
}

/** timestamp_range accessor */
std::pair<uint64_t, uint64_t>& timestamp_range() {
return timestamp_range_;
}

/** last_tile_cell_num accessor */
uint64_t& last_tile_cell_num() {
return last_tile_cell_num_;
}

/** non_empty_domain accessor */
NDRange& non_empty_domain() {
return non_empty_domain_;
}

/** rtree accessor */
RTree& rtree() {
return rtree_;
}

/** gt_offsets_ accessor */
inline GenericTileOffsets& generic_tile_offsets() {
return gt_offsets_;
const shared_ptr<const ArraySchema>& array_schema() const {
return array_schema_;
}

/** set the CR pointer during deserialization*/
void set_context_resources(ContextResources* cr) {
resources_ = cr;
}

/** set the memory tracker pointer during deserialization*/
void set_memory_tracker(MemoryTracker* memory_tracker) {
memory_tracker_ = memory_tracker;
}

/** loaded_metadata_.rtree_ accessor */
void set_rtree_loaded() {
loaded_metadata_.rtree_ = true;
Expand All @@ -1287,26 +1125,6 @@ class FragmentMetadata {
loaded_metadata_ = loaded_metadata;
}

/**
* Resize tile offsets related vectors.
*/
void resize_tile_offsets_vectors(uint64_t size);

/**
* Resize tile var offsets related vectors.
*/
void resize_tile_var_offsets_vectors(uint64_t size);

/**
* Resize tile var sizes related vectors.
*/
void resize_tile_var_sizes_vectors(uint64_t size);

/**
* Resize tile validity offsets related vectors.
*/
void resize_tile_validity_offsets_vectors(uint64_t size);

private:
/* ********************************* */
/* PRIVATE ATTRIBUTES */
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/query/readers/dense_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class DenseReader : public ReaderBase, public IQueryStrategy {
if ((type == Datatype::STRING_ASCII || type == Datatype::CHAR) &&
array_schema_.cell_val_num(name) != constants::var_num &&
array_schema_.is_nullable(name)) {
if (frag_md->version() <= 20) {
if (frag_md->format_version() <= 20) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/query/readers/reader_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ bool ReaderBase::need_timestamped_conditions() {
for (auto& delete_and_update_condition : delete_and_update_conditions_) {
auto delete_timestamp =
delete_and_update_condition.condition_timestamp();
auto& frag_timestamps = fragment_metadata_[i]->timestamp_range();
auto frag_timestamps = fragment_metadata_[i]->timestamp_range();
if (delete_timestamp >= frag_timestamps.first &&
delete_timestamp <= frag_timestamps.second) {
make_timestamped_conditions = true;
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/query/readers/sparse_index_reader_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ std::vector<uint64_t> SparseIndexReaderBase::tile_offset_sizes() {

// For fragments with version smaller than 5 we have zipped coords.
// Otherwise we load each dimensions independently.
if (fragment->version() < 5) {
if (fragment->format_version() < 5) {
num = 1;
} else {
for (unsigned d = 0; d < dim_num; ++d) {
Expand Down
2 changes: 1 addition & 1 deletion tiledb/sm/serialization/array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Status array_to_capnp(
// Old fragment with zipped coordinates didn't have a format that
// allow to dynamically load tile offsets and sizes and since they all
// get loaded at array open, we need to serialize them here.
if (fragment_metadata_all[i]->version() <= 2) {
if (fragment_metadata_all[i]->format_version() <= 2) {
fragment_meta_sizes_offsets_to_capnp(
*fragment_metadata_all[i], &fragment_metadata_builder);
}
Expand Down

0 comments on commit 7bf109f

Please sign in to comment.