Skip to content

Commit f2728ba

Browse files
committed
Clean-up FragmentMetadata: remove unused methods, add missing const qualifiers and return small values by value.
1 parent a2b1933 commit f2728ba

File tree

6 files changed

+20
-233
lines changed

6 files changed

+20
-233
lines changed

tiledb/sm/fragment/fragment_metadata.cc

+6-37
Original file line numberDiff line numberDiff line change
@@ -1421,10 +1421,6 @@ URI FragmentMetadata::validity_uri(const std::string& name) const {
14211421
encoded_name + "_validity" + constants::file_suffix);
14221422
}
14231423

1424-
const std::string& FragmentMetadata::array_schema_name() {
1425-
return array_schema_name_;
1426-
}
1427-
14281424
void FragmentMetadata::load_tile_offsets(
14291425
const EncryptionKey& encryption_key, std::vector<std::string>& names) {
14301426
// Sort 'names' in ascending order of their index. The
@@ -1704,7 +1700,7 @@ uint64_t FragmentMetadata::tile_size(
17041700
}
17051701

17061702
uint64_t FragmentMetadata::tile_var_size(
1707-
const std::string& name, uint64_t tile_idx) {
1703+
const std::string& name, uint64_t tile_idx) const {
17081704
auto it = idx_map_.find(name);
17091705
assert(it != idx_map_.end());
17101706
auto idx = it->second;
@@ -1924,7 +1920,8 @@ uint64_t FragmentMetadata::get_tile_null_count(
19241920
return tile_null_counts_[idx][tile_idx];
19251921
}
19261922

1927-
std::vector<uint8_t>& FragmentMetadata::get_min(const std::string& name) {
1923+
const std::vector<uint8_t>& FragmentMetadata::get_min(
1924+
const std::string& name) const {
19281925
auto it = idx_map_.find(name);
19291926
assert(it != idx_map_.end());
19301927
auto idx = it->second;
@@ -1946,7 +1943,8 @@ std::vector<uint8_t>& FragmentMetadata::get_min(const std::string& name) {
19461943
return fragment_mins_[idx];
19471944
}
19481945

1949-
std::vector<uint8_t>& FragmentMetadata::get_max(const std::string& name) {
1946+
const std::vector<uint8_t>& FragmentMetadata::get_max(
1947+
const std::string& name) const {
19501948
auto it = idx_map_.find(name);
19511949
assert(it != idx_map_.end());
19521950
auto idx = it->second;
@@ -1968,7 +1966,7 @@ std::vector<uint8_t>& FragmentMetadata::get_max(const std::string& name) {
19681966
return fragment_maxs_[idx];
19691967
}
19701968

1971-
void* FragmentMetadata::get_sum(const std::string& name) {
1969+
const void* FragmentMetadata::get_sum(const std::string& name) const {
19721970
auto it = idx_map_.find(name);
19731971
assert(it != idx_map_.end());
19741972
auto idx = it->second;
@@ -4696,23 +4694,6 @@ void FragmentMetadata::store_footer(const EncryptionKey&) {
46964694
resources_->stats().add_counter("write_frag_meta_footer_size", tile.size());
46974695
}
46984696

4699-
void FragmentMetadata::resize_tile_offsets_vectors(uint64_t size) {
4700-
tile_offsets_mtx().resize(size);
4701-
tile_offsets().resize(size);
4702-
}
4703-
4704-
void FragmentMetadata::resize_tile_var_offsets_vectors(uint64_t size) {
4705-
tile_var_offsets_mtx().resize(size);
4706-
tile_var_offsets().resize(size);
4707-
}
4708-
4709-
void FragmentMetadata::resize_tile_var_sizes_vectors(uint64_t size) {
4710-
tile_var_sizes().resize(size);
4711-
}
4712-
void FragmentMetadata::resize_tile_validity_offsets_vectors(uint64_t size) {
4713-
tile_validity_offsets().resize(size);
4714-
}
4715-
47164697
void FragmentMetadata::clean_up() {
47174698
auto fragment_metadata_uri =
47184699
fragment_uri_.join_path(constants::fragment_metadata_filename);
@@ -4721,10 +4702,6 @@ void FragmentMetadata::clean_up() {
47214702
throw_if_not_ok(resources_->vfs().remove_file(fragment_metadata_uri));
47224703
}
47234704

4724-
const shared_ptr<const ArraySchema>& FragmentMetadata::array_schema() const {
4725-
return array_schema_;
4726-
}
4727-
47284705
void FragmentMetadata::build_idx_map() {
47294706
idx_map_.clear();
47304707

@@ -4749,14 +4726,6 @@ void FragmentMetadata::build_idx_map() {
47494726
}
47504727
}
47514728

4752-
void FragmentMetadata::set_schema_name(const std::string& name) {
4753-
array_schema_name_ = name;
4754-
}
4755-
4756-
void FragmentMetadata::set_dense(bool dense) {
4757-
dense_ = dense;
4758-
}
4759-
47604729
// Explicit template instantiations
47614730
template std::vector<std::pair<uint64_t, double>>
47624731
FragmentMetadata::compute_overlapping_tile_ids_cov<int8_t>(

tiledb/sm/fragment/fragment_metadata.h

+10-192
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ class FragmentMetadata {
342342
return has_delete_meta_;
343343
}
344344

345-
inline bool has_tile_metadata() {
345+
inline bool has_tile_metadata() const {
346346
return version_ >= constants::tile_metadata_min_version;
347347
}
348348

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

765-
/** Sets the array_schema name */
766-
void set_schema_name(const std::string& name);
767-
768-
/** Sets the internal dense_ field*/
769-
void set_dense(bool dense);
770-
771765
/** Returns the number of tiles in the fragment. */
772766
uint64_t tile_num() const;
773767

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

783777
/** Return the array schema name. */
784-
const std::string& array_schema_name();
778+
const std::string& array_schema_name() const {
779+
return array_schema_name_;
780+
}
785781

786782
/**
787783
* Retrieves the starting offset of the input tile of the input attribute
@@ -878,7 +874,7 @@ class FragmentMetadata {
878874
* @param tile_idx The index of the tile in the metadata.
879875
* @return Size.
880876
*/
881-
uint64_t tile_var_size(const std::string& name, uint64_t tile_idx);
877+
uint64_t tile_var_size(const std::string& name, uint64_t tile_idx) const;
882878

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

935931
/**
936932
* Retrieves the max value for a given attribute or dimension.
937933
*
938934
* @param name The input attribute/dimension.
939935
* @return Value.
940936
*/
941-
std::vector<uint8_t>& get_max(const std::string& name);
937+
const std::vector<uint8_t>& get_max(const std::string& name) const;
942938

943939
/**
944940
* Retrieves the sum value for a given attribute or dimension.
945941
*
946942
* @param name The input attribute/dimension.
947943
* @return Sum.
948944
*/
949-
void* get_sum(const std::string& name);
945+
const void* get_sum(const std::string& name) const;
950946

951947
/**
952948
* Retrieves the null count value for a given attribute or dimension.
@@ -1110,173 +1106,15 @@ class FragmentMetadata {
11101106
*
11111107
* @return
11121108
*/
1113-
const shared_ptr<const ArraySchema>& array_schema() const;
1114-
1115-
/** File sizes accessor */
1116-
std::vector<uint64_t>& file_sizes() {
1117-
return file_sizes_;
1118-
}
1119-
1120-
/** File var sizes accessor */
1121-
std::vector<uint64_t>& file_var_sizes() {
1122-
return file_var_sizes_;
1123-
}
1124-
1125-
/** File validity sizes accessor */
1126-
std::vector<uint64_t>& file_validity_sizes() {
1127-
return file_validity_sizes_;
1128-
}
1129-
1130-
/** Fragment uri accessor */
1131-
URI& fragment_uri() {
1132-
return fragment_uri_;
1133-
}
1134-
1135-
/** has_timestamps accessor */
1136-
bool& has_timestamps() {
1137-
return has_timestamps_;
1138-
}
1139-
1140-
/** has_delete_meta accessor */
1141-
bool& has_delete_meta() {
1142-
return has_delete_meta_;
1143-
}
1144-
1145-
/** has_consolidated_footer accessor */
1146-
bool& has_consolidated_footer() {
1147-
return has_consolidated_footer_;
1148-
}
1149-
1150-
/** sparse_tile_num accessor */
1151-
uint64_t& sparse_tile_num() {
1152-
return sparse_tile_num_;
1153-
}
1154-
1155-
/** tile_index_base accessor */
1156-
uint64_t& tile_index_base() {
1157-
return tile_index_base_;
1158-
}
1159-
1160-
/** tile_offsets accessor */
1161-
std::vector<std::vector<uint64_t>>& tile_offsets() {
1162-
return tile_offsets_;
1163-
}
1164-
1165-
/** tile_offsets_mtx accessor */
1166-
std::deque<std::mutex>& tile_offsets_mtx() {
1167-
return tile_offsets_mtx_;
1168-
}
1169-
1170-
/** tile_var_offsets accessor */
1171-
std::vector<std::vector<uint64_t>>& tile_var_offsets() {
1172-
return tile_var_offsets_;
1173-
}
1174-
1175-
/** tile_var_offsets_mtx accessor */
1176-
std::deque<std::mutex>& tile_var_offsets_mtx() {
1177-
return tile_var_offsets_mtx_;
1178-
}
1179-
1180-
/** tile_var_sizes accessor */
1181-
std::vector<std::vector<uint64_t>>& tile_var_sizes() {
1182-
return tile_var_sizes_;
1183-
}
1184-
1185-
/** tile_validity_offsets accessor */
1186-
std::vector<std::vector<uint64_t>>& tile_validity_offsets() {
1187-
return tile_validity_offsets_;
1188-
}
1189-
1190-
/** tile_min_buffer accessor */
1191-
std::vector<std::vector<uint8_t>>& tile_min_buffer() {
1192-
return tile_min_buffer_;
1193-
}
1194-
1195-
/** tile_min_var_buffer accessor */
1196-
std::vector<std::vector<char>>& tile_min_var_buffer() {
1197-
return tile_min_var_buffer_;
1198-
}
1199-
1200-
/** tile_max_buffer accessor */
1201-
std::vector<std::vector<uint8_t>>& tile_max_buffer() {
1202-
return tile_max_buffer_;
1203-
}
1204-
1205-
/** tile_max_var_buffer accessor */
1206-
std::vector<std::vector<char>>& tile_max_var_buffer() {
1207-
return tile_max_var_buffer_;
1208-
}
1209-
1210-
/** tile_sums accessor */
1211-
std::vector<std::vector<uint8_t>>& tile_sums() {
1212-
return tile_sums_;
1213-
}
1214-
1215-
/** tile_null_counts accessor */
1216-
std::vector<std::vector<uint64_t>>& tile_null_counts() {
1217-
return tile_null_counts_;
1218-
}
1219-
1220-
/** fragment_mins accessor */
1221-
std::vector<std::vector<uint8_t>>& fragment_mins() {
1222-
return fragment_mins_;
1223-
}
1224-
1225-
/** fragment_maxs accessor */
1226-
std::vector<std::vector<uint8_t>>& fragment_maxs() {
1227-
return fragment_maxs_;
1228-
}
1229-
1230-
/** fragment_sums accessor */
1231-
std::vector<uint64_t>& fragment_sums() {
1232-
return fragment_sums_;
1233-
}
1234-
1235-
/** fragment_null_counts accessor */
1236-
std::vector<uint64_t>& fragment_null_counts() {
1237-
return fragment_null_counts_;
1238-
}
1239-
1240-
/** version accessor */
1241-
uint32_t& version() {
1242-
return version_;
1243-
}
1244-
1245-
/** timestamp_range accessor */
1246-
std::pair<uint64_t, uint64_t>& timestamp_range() {
1247-
return timestamp_range_;
1248-
}
1249-
1250-
/** last_tile_cell_num accessor */
1251-
uint64_t& last_tile_cell_num() {
1252-
return last_tile_cell_num_;
1253-
}
1254-
1255-
/** non_empty_domain accessor */
1256-
NDRange& non_empty_domain() {
1257-
return non_empty_domain_;
1258-
}
1259-
1260-
/** rtree accessor */
1261-
RTree& rtree() {
1262-
return rtree_;
1263-
}
1264-
1265-
/** gt_offsets_ accessor */
1266-
inline GenericTileOffsets& generic_tile_offsets() {
1267-
return gt_offsets_;
1109+
const shared_ptr<const ArraySchema>& array_schema() const {
1110+
return array_schema_;
12681111
}
12691112

12701113
/** set the CR pointer during deserialization*/
12711114
void set_context_resources(ContextResources* cr) {
12721115
resources_ = cr;
12731116
}
12741117

1275-
/** set the memory tracker pointer during deserialization*/
1276-
void set_memory_tracker(MemoryTracker* memory_tracker) {
1277-
memory_tracker_ = memory_tracker;
1278-
}
1279-
12801118
/** loaded_metadata_.rtree_ accessor */
12811119
void set_rtree_loaded() {
12821120
loaded_metadata_.rtree_ = true;
@@ -1287,26 +1125,6 @@ class FragmentMetadata {
12871125
loaded_metadata_ = loaded_metadata;
12881126
}
12891127

1290-
/**
1291-
* Resize tile offsets related vectors.
1292-
*/
1293-
void resize_tile_offsets_vectors(uint64_t size);
1294-
1295-
/**
1296-
* Resize tile var offsets related vectors.
1297-
*/
1298-
void resize_tile_var_offsets_vectors(uint64_t size);
1299-
1300-
/**
1301-
* Resize tile var sizes related vectors.
1302-
*/
1303-
void resize_tile_var_sizes_vectors(uint64_t size);
1304-
1305-
/**
1306-
* Resize tile validity offsets related vectors.
1307-
*/
1308-
void resize_tile_validity_offsets_vectors(uint64_t size);
1309-
13101128
private:
13111129
/* ********************************* */
13121130
/* PRIVATE ATTRIBUTES */

tiledb/sm/query/readers/dense_reader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ class DenseReader : public ReaderBase, public IQueryStrategy {
309309
if ((type == Datatype::STRING_ASCII || type == Datatype::CHAR) &&
310310
array_schema_.cell_val_num(name) != constants::var_num &&
311311
array_schema_.is_nullable(name)) {
312-
if (frag_md->version() <= 20) {
312+
if (frag_md->format_version() <= 20) {
313313
return false;
314314
}
315315
}

tiledb/sm/query/readers/reader_base.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ bool ReaderBase::need_timestamped_conditions() {
227227
for (auto& delete_and_update_condition : delete_and_update_conditions_) {
228228
auto delete_timestamp =
229229
delete_and_update_condition.condition_timestamp();
230-
auto& frag_timestamps = fragment_metadata_[i]->timestamp_range();
230+
auto frag_timestamps = fragment_metadata_[i]->timestamp_range();
231231
if (delete_timestamp >= frag_timestamps.first &&
232232
delete_timestamp <= frag_timestamps.second) {
233233
make_timestamped_conditions = true;

tiledb/sm/query/readers/sparse_index_reader_base.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ std::vector<uint64_t> SparseIndexReaderBase::tile_offset_sizes() {
171171

172172
// For fragments with version smaller than 5 we have zipped coords.
173173
// Otherwise we load each dimensions independently.
174-
if (fragment->version() < 5) {
174+
if (fragment->format_version() < 5) {
175175
num = 1;
176176
} else {
177177
for (unsigned d = 0; d < dim_num; ++d) {

0 commit comments

Comments
 (0)