/src/rocksdb/table/table_properties.cc
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | | // This source code is licensed under both the GPLv2 (found in the |
3 | | // COPYING file in the root directory) and Apache 2.0 License |
4 | | // (found in the LICENSE.Apache file in the root directory). |
5 | | |
6 | | #include "rocksdb/table_properties.h" |
7 | | |
8 | | #include "db/seqno_to_time_mapping.h" |
9 | | #include "port/malloc.h" |
10 | | #include "port/port.h" |
11 | | #include "rocksdb/env.h" |
12 | | #include "rocksdb/unique_id.h" |
13 | | #include "rocksdb/utilities/options_type.h" |
14 | | #include "table/table_properties_internal.h" |
15 | | #include "table/unique_id_impl.h" |
16 | | #include "util/random.h" |
17 | | #include "util/string_util.h" |
18 | | |
19 | | namespace ROCKSDB_NAMESPACE { |
20 | | |
21 | | const uint32_t TablePropertiesCollectorFactory::Context::kUnknownColumnFamily = |
22 | | std::numeric_limits<int32_t>::max(); |
23 | | |
24 | | namespace { |
25 | | void AppendProperty(std::string& props, const std::string& key, |
26 | | const std::string& value, const std::string& prop_delim, |
27 | 0 | const std::string& kv_delim) { |
28 | 0 | props.append(key); |
29 | 0 | props.append(kv_delim); |
30 | 0 | props.append(value); |
31 | 0 | props.append(prop_delim); |
32 | 0 | } |
33 | | |
34 | | template <class TValue> |
35 | | void AppendProperty(std::string& props, const std::string& key, |
36 | | const TValue& value, const std::string& prop_delim, |
37 | 0 | const std::string& kv_delim) { |
38 | 0 | AppendProperty(props, key, std::to_string(value), prop_delim, kv_delim); |
39 | 0 | } Unexecuted instantiation: table_properties.cc:void rocksdb::(anonymous namespace)::AppendProperty<unsigned long>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: table_properties.cc:void rocksdb::(anonymous namespace)::AppendProperty<double>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, double const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) |
40 | | } // namespace |
41 | | |
42 | | std::string TableProperties::ToString(const std::string& prop_delim, |
43 | 0 | const std::string& kv_delim) const { |
44 | 0 | std::string result; |
45 | 0 | result.reserve(1024); |
46 | | |
47 | | // Basic Info |
48 | 0 | AppendProperty(result, "# data blocks", num_data_blocks, prop_delim, |
49 | 0 | kv_delim); |
50 | 0 | AppendProperty(result, "# entries", num_entries, prop_delim, kv_delim); |
51 | 0 | AppendProperty(result, "# deletions", num_deletions, prop_delim, kv_delim); |
52 | 0 | AppendProperty(result, "# merge operands", num_merge_operands, prop_delim, |
53 | 0 | kv_delim); |
54 | 0 | AppendProperty(result, "# range deletions", num_range_deletions, prop_delim, |
55 | 0 | kv_delim); |
56 | |
|
57 | 0 | AppendProperty(result, "raw key size", raw_key_size, prop_delim, kv_delim); |
58 | 0 | AppendProperty(result, "raw average key size", |
59 | 0 | num_entries != 0 ? 1.0 * raw_key_size / num_entries : 0.0, |
60 | 0 | prop_delim, kv_delim); |
61 | 0 | AppendProperty(result, "raw value size", raw_value_size, prop_delim, |
62 | 0 | kv_delim); |
63 | 0 | AppendProperty(result, "raw average value size", |
64 | 0 | num_entries != 0 ? 1.0 * raw_value_size / num_entries : 0.0, |
65 | 0 | prop_delim, kv_delim); |
66 | |
|
67 | 0 | AppendProperty(result, "data block size", data_size, prop_delim, kv_delim); |
68 | 0 | char index_block_size_str[80]; |
69 | 0 | snprintf(index_block_size_str, sizeof(index_block_size_str), |
70 | 0 | "index block size (user-key? %d, delta-value? %d)", |
71 | 0 | static_cast<int>(index_key_is_user_key), |
72 | 0 | static_cast<int>(index_value_is_delta_encoded)); |
73 | 0 | AppendProperty(result, index_block_size_str, index_size, prop_delim, |
74 | 0 | kv_delim); |
75 | 0 | if (index_partitions != 0) { |
76 | 0 | AppendProperty(result, "# index partitions", index_partitions, prop_delim, |
77 | 0 | kv_delim); |
78 | 0 | AppendProperty(result, "top-level index size", top_level_index_size, |
79 | 0 | prop_delim, kv_delim); |
80 | 0 | } |
81 | 0 | AppendProperty(result, "filter block size", filter_size, prop_delim, |
82 | 0 | kv_delim); |
83 | 0 | AppendProperty(result, "# entries for filter", num_filter_entries, prop_delim, |
84 | 0 | kv_delim); |
85 | 0 | AppendProperty(result, "(estimated) table size", |
86 | 0 | data_size + index_size + filter_size, prop_delim, kv_delim); |
87 | |
|
88 | 0 | AppendProperty( |
89 | 0 | result, "filter policy name", |
90 | 0 | filter_policy_name.empty() ? std::string("N/A") : filter_policy_name, |
91 | 0 | prop_delim, kv_delim); |
92 | |
|
93 | 0 | AppendProperty(result, "prefix extractor name", |
94 | 0 | prefix_extractor_name.empty() ? std::string("N/A") |
95 | 0 | : prefix_extractor_name, |
96 | 0 | prop_delim, kv_delim); |
97 | |
|
98 | 0 | AppendProperty(result, "column family ID", |
99 | 0 | column_family_id == |
100 | 0 | ROCKSDB_NAMESPACE::TablePropertiesCollectorFactory:: |
101 | 0 | Context::kUnknownColumnFamily |
102 | 0 | ? std::string("N/A") |
103 | 0 | : std::to_string(column_family_id), |
104 | 0 | prop_delim, kv_delim); |
105 | 0 | AppendProperty( |
106 | 0 | result, "column family name", |
107 | 0 | column_family_name.empty() ? std::string("N/A") : column_family_name, |
108 | 0 | prop_delim, kv_delim); |
109 | |
|
110 | 0 | AppendProperty(result, "comparator name", |
111 | 0 | comparator_name.empty() ? std::string("N/A") : comparator_name, |
112 | 0 | prop_delim, kv_delim); |
113 | 0 | AppendProperty(result, "user defined timestamps persisted", |
114 | 0 | user_defined_timestamps_persisted ? std::string("true") |
115 | 0 | : std::string("false"), |
116 | 0 | prop_delim, kv_delim); |
117 | 0 | AppendProperty(result, "largest sequence number in file", key_largest_seqno, |
118 | 0 | prop_delim, kv_delim); |
119 | |
|
120 | 0 | AppendProperty( |
121 | 0 | result, "merge operator name", |
122 | 0 | merge_operator_name.empty() ? std::string("N/A") : merge_operator_name, |
123 | 0 | prop_delim, kv_delim); |
124 | |
|
125 | 0 | AppendProperty(result, "property collectors names", |
126 | 0 | property_collectors_names.empty() ? std::string("N/A") |
127 | 0 | : property_collectors_names, |
128 | 0 | prop_delim, kv_delim); |
129 | |
|
130 | 0 | AppendProperty( |
131 | 0 | result, "SST file compression algo", |
132 | 0 | compression_name.empty() ? std::string("N/A") : compression_name, |
133 | 0 | prop_delim, kv_delim); |
134 | |
|
135 | 0 | AppendProperty( |
136 | 0 | result, "SST file compression options", |
137 | 0 | compression_options.empty() ? std::string("N/A") : compression_options, |
138 | 0 | prop_delim, kv_delim); |
139 | |
|
140 | 0 | AppendProperty(result, "creation time", creation_time, prop_delim, kv_delim); |
141 | |
|
142 | 0 | AppendProperty(result, "time stamp of earliest key", oldest_key_time, |
143 | 0 | prop_delim, kv_delim); |
144 | 0 | AppendProperty(result, "time stamp of newest key", newest_key_time, |
145 | 0 | prop_delim, kv_delim); |
146 | |
|
147 | 0 | AppendProperty(result, "file creation time", file_creation_time, prop_delim, |
148 | 0 | kv_delim); |
149 | |
|
150 | 0 | AppendProperty(result, "slow compression estimated data size", |
151 | 0 | slow_compression_estimated_data_size, prop_delim, kv_delim); |
152 | 0 | AppendProperty(result, "fast compression estimated data size", |
153 | 0 | fast_compression_estimated_data_size, prop_delim, kv_delim); |
154 | | |
155 | | // DB identity and DB session ID |
156 | 0 | AppendProperty(result, "DB identity", db_id, prop_delim, kv_delim); |
157 | 0 | AppendProperty(result, "DB session identity", db_session_id, prop_delim, |
158 | 0 | kv_delim); |
159 | 0 | AppendProperty(result, "DB host id", db_host_id, prop_delim, kv_delim); |
160 | 0 | AppendProperty(result, "original file number", orig_file_number, prop_delim, |
161 | 0 | kv_delim); |
162 | | |
163 | | // Unique ID, when available |
164 | 0 | std::string id; |
165 | 0 | Status s = GetUniqueIdFromTableProperties(*this, &id); |
166 | 0 | AppendProperty(result, "unique ID", |
167 | 0 | s.ok() ? UniqueIdToHumanString(id) : "N/A", prop_delim, |
168 | 0 | kv_delim); |
169 | |
|
170 | 0 | SeqnoToTimeMapping seq_time_mapping; |
171 | 0 | s = seq_time_mapping.DecodeFrom(seqno_to_time_mapping); |
172 | 0 | AppendProperty(result, "Sequence number to time mapping", |
173 | 0 | s.ok() ? seq_time_mapping.ToHumanString() : "N/A", prop_delim, |
174 | 0 | kv_delim); |
175 | |
|
176 | 0 | return result; |
177 | 0 | } |
178 | | |
179 | 0 | void TableProperties::Add(const TableProperties& tp) { |
180 | 0 | data_size += tp.data_size; |
181 | 0 | index_size += tp.index_size; |
182 | 0 | index_partitions += tp.index_partitions; |
183 | 0 | top_level_index_size += tp.top_level_index_size; |
184 | 0 | index_key_is_user_key += tp.index_key_is_user_key; |
185 | 0 | index_value_is_delta_encoded += tp.index_value_is_delta_encoded; |
186 | 0 | filter_size += tp.filter_size; |
187 | 0 | raw_key_size += tp.raw_key_size; |
188 | 0 | raw_value_size += tp.raw_value_size; |
189 | 0 | num_data_blocks += tp.num_data_blocks; |
190 | 0 | num_entries += tp.num_entries; |
191 | 0 | num_filter_entries += tp.num_filter_entries; |
192 | 0 | num_deletions += tp.num_deletions; |
193 | 0 | num_merge_operands += tp.num_merge_operands; |
194 | 0 | num_range_deletions += tp.num_range_deletions; |
195 | 0 | slow_compression_estimated_data_size += |
196 | 0 | tp.slow_compression_estimated_data_size; |
197 | 0 | fast_compression_estimated_data_size += |
198 | 0 | tp.fast_compression_estimated_data_size; |
199 | 0 | } |
200 | | |
201 | | std::map<std::string, uint64_t> |
202 | 0 | TableProperties::GetAggregatablePropertiesAsMap() const { |
203 | 0 | std::map<std::string, uint64_t> rv; |
204 | 0 | rv["data_size"] = data_size; |
205 | 0 | rv["index_size"] = index_size; |
206 | 0 | rv["index_partitions"] = index_partitions; |
207 | 0 | rv["top_level_index_size"] = top_level_index_size; |
208 | 0 | rv["filter_size"] = filter_size; |
209 | 0 | rv["raw_key_size"] = raw_key_size; |
210 | 0 | rv["raw_value_size"] = raw_value_size; |
211 | 0 | rv["num_data_blocks"] = num_data_blocks; |
212 | 0 | rv["num_entries"] = num_entries; |
213 | 0 | rv["num_filter_entries"] = num_filter_entries; |
214 | 0 | rv["num_deletions"] = num_deletions; |
215 | 0 | rv["num_merge_operands"] = num_merge_operands; |
216 | 0 | rv["num_range_deletions"] = num_range_deletions; |
217 | 0 | rv["slow_compression_estimated_data_size"] = |
218 | 0 | slow_compression_estimated_data_size; |
219 | 0 | rv["fast_compression_estimated_data_size"] = |
220 | 0 | fast_compression_estimated_data_size; |
221 | 0 | return rv; |
222 | 0 | } |
223 | | |
224 | | // WARNING: manual update to this function is needed |
225 | | // whenever a new string property is added to TableProperties |
226 | | // to reduce approximation error. |
227 | | // |
228 | | // TODO: eliminate the need of manually updating this function |
229 | | // for new string properties |
230 | 0 | std::size_t TableProperties::ApproximateMemoryUsage() const { |
231 | 0 | std::size_t usage = 0; |
232 | 0 | #ifdef ROCKSDB_MALLOC_USABLE_SIZE |
233 | 0 | usage += malloc_usable_size((void*)this); |
234 | | #else |
235 | | usage += sizeof(*this); |
236 | | #endif // ROCKSDB_MALLOC_USABLE_SIZE |
237 | |
|
238 | 0 | std::size_t string_props_mem_usage = |
239 | 0 | db_id.size() + db_session_id.size() + db_host_id.size() + |
240 | 0 | column_family_name.size() + filter_policy_name.size() + |
241 | 0 | comparator_name.size() + merge_operator_name.size() + |
242 | 0 | prefix_extractor_name.size() + property_collectors_names.size() + |
243 | 0 | compression_name.size() + compression_options.size(); |
244 | 0 | usage += string_props_mem_usage; |
245 | |
|
246 | 0 | for (auto iter = user_collected_properties.begin(); |
247 | 0 | iter != user_collected_properties.end(); ++iter) { |
248 | 0 | usage += (iter->first.size() + iter->second.size()); |
249 | 0 | } |
250 | |
|
251 | 0 | return usage; |
252 | 0 | } |
253 | | |
254 | | const std::string TablePropertiesNames::kDbId = "rocksdb.creating.db.identity"; |
255 | | const std::string TablePropertiesNames::kDbSessionId = |
256 | | "rocksdb.creating.session.identity"; |
257 | | const std::string TablePropertiesNames::kDbHostId = |
258 | | "rocksdb.creating.host.identity"; |
259 | | const std::string TablePropertiesNames::kOriginalFileNumber = |
260 | | "rocksdb.original.file.number"; |
261 | | const std::string TablePropertiesNames::kDataSize = "rocksdb.data.size"; |
262 | | const std::string TablePropertiesNames::kIndexSize = "rocksdb.index.size"; |
263 | | const std::string TablePropertiesNames::kIndexPartitions = |
264 | | "rocksdb.index.partitions"; |
265 | | const std::string TablePropertiesNames::kTopLevelIndexSize = |
266 | | "rocksdb.top-level.index.size"; |
267 | | const std::string TablePropertiesNames::kIndexKeyIsUserKey = |
268 | | "rocksdb.index.key.is.user.key"; |
269 | | const std::string TablePropertiesNames::kIndexValueIsDeltaEncoded = |
270 | | "rocksdb.index.value.is.delta.encoded"; |
271 | | const std::string TablePropertiesNames::kFilterSize = "rocksdb.filter.size"; |
272 | | const std::string TablePropertiesNames::kRawKeySize = "rocksdb.raw.key.size"; |
273 | | const std::string TablePropertiesNames::kRawValueSize = |
274 | | "rocksdb.raw.value.size"; |
275 | | const std::string TablePropertiesNames::kNumDataBlocks = |
276 | | "rocksdb.num.data.blocks"; |
277 | | const std::string TablePropertiesNames::kNumEntries = "rocksdb.num.entries"; |
278 | | const std::string TablePropertiesNames::kNumFilterEntries = |
279 | | "rocksdb.num.filter_entries"; |
280 | | const std::string TablePropertiesNames::kDeletedKeys = "rocksdb.deleted.keys"; |
281 | | const std::string TablePropertiesNames::kMergeOperands = |
282 | | "rocksdb.merge.operands"; |
283 | | const std::string TablePropertiesNames::kNumRangeDeletions = |
284 | | "rocksdb.num.range-deletions"; |
285 | | const std::string TablePropertiesNames::kFilterPolicy = "rocksdb.filter.policy"; |
286 | | const std::string TablePropertiesNames::kFormatVersion = |
287 | | "rocksdb.format.version"; |
288 | | const std::string TablePropertiesNames::kFixedKeyLen = |
289 | | "rocksdb.fixed.key.length"; |
290 | | const std::string TablePropertiesNames::kColumnFamilyId = |
291 | | "rocksdb.column.family.id"; |
292 | | const std::string TablePropertiesNames::kColumnFamilyName = |
293 | | "rocksdb.column.family.name"; |
294 | | const std::string TablePropertiesNames::kComparator = "rocksdb.comparator"; |
295 | | const std::string TablePropertiesNames::kMergeOperator = |
296 | | "rocksdb.merge.operator"; |
297 | | const std::string TablePropertiesNames::kPrefixExtractorName = |
298 | | "rocksdb.prefix.extractor.name"; |
299 | | const std::string TablePropertiesNames::kPropertyCollectors = |
300 | | "rocksdb.property.collectors"; |
301 | | const std::string TablePropertiesNames::kCompression = "rocksdb.compression"; |
302 | | const std::string TablePropertiesNames::kCompressionOptions = |
303 | | "rocksdb.compression_options"; |
304 | | const std::string TablePropertiesNames::kCreationTime = "rocksdb.creation.time"; |
305 | | const std::string TablePropertiesNames::kOldestKeyTime = |
306 | | "rocksdb.oldest.key.time"; |
307 | | const std::string TablePropertiesNames::kNewestKeyTime = |
308 | | "rocksdb.newest.key.time"; |
309 | | const std::string TablePropertiesNames::kFileCreationTime = |
310 | | "rocksdb.file.creation.time"; |
311 | | const std::string TablePropertiesNames::kSlowCompressionEstimatedDataSize = |
312 | | "rocksdb.sample_for_compression.slow.data.size"; |
313 | | const std::string TablePropertiesNames::kFastCompressionEstimatedDataSize = |
314 | | "rocksdb.sample_for_compression.fast.data.size"; |
315 | | const std::string TablePropertiesNames::kSequenceNumberTimeMapping = |
316 | | "rocksdb.seqno.time.map"; |
317 | | const std::string TablePropertiesNames::kTailStartOffset = |
318 | | "rocksdb.tail.start.offset"; |
319 | | const std::string TablePropertiesNames::kUserDefinedTimestampsPersisted = |
320 | | "rocksdb.user.defined.timestamps.persisted"; |
321 | | const std::string TablePropertiesNames::kKeyLargestSeqno = |
322 | | "rocksdb.key.largest.seqno"; |
323 | | |
324 | | static std::unordered_map<std::string, OptionTypeInfo> |
325 | | table_properties_type_info = { |
326 | | {"orig_file_number", |
327 | | {offsetof(struct TableProperties, orig_file_number), |
328 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
329 | | OptionTypeFlags::kNone}}, |
330 | | {"data_size", |
331 | | {offsetof(struct TableProperties, data_size), OptionType::kUInt64T, |
332 | | OptionVerificationType::kNormal, OptionTypeFlags::kNone}}, |
333 | | {"index_size", |
334 | | {offsetof(struct TableProperties, index_size), OptionType::kUInt64T, |
335 | | OptionVerificationType::kNormal, OptionTypeFlags::kNone}}, |
336 | | {"index_partitions", |
337 | | {offsetof(struct TableProperties, index_partitions), |
338 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
339 | | OptionTypeFlags::kNone}}, |
340 | | {"top_level_index_size", |
341 | | {offsetof(struct TableProperties, top_level_index_size), |
342 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
343 | | OptionTypeFlags::kNone}}, |
344 | | {"index_key_is_user_key", |
345 | | {offsetof(struct TableProperties, index_key_is_user_key), |
346 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
347 | | OptionTypeFlags::kNone}}, |
348 | | {"index_value_is_delta_encoded", |
349 | | {offsetof(struct TableProperties, index_value_is_delta_encoded), |
350 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
351 | | OptionTypeFlags::kNone}}, |
352 | | {"filter_size", |
353 | | {offsetof(struct TableProperties, filter_size), OptionType::kUInt64T, |
354 | | OptionVerificationType::kNormal, OptionTypeFlags::kNone}}, |
355 | | {"raw_key_size", |
356 | | {offsetof(struct TableProperties, raw_key_size), OptionType::kUInt64T, |
357 | | OptionVerificationType::kNormal, OptionTypeFlags::kNone}}, |
358 | | {"raw_value_size", |
359 | | {offsetof(struct TableProperties, raw_value_size), |
360 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
361 | | OptionTypeFlags::kNone}}, |
362 | | {"num_data_blocks", |
363 | | {offsetof(struct TableProperties, num_data_blocks), |
364 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
365 | | OptionTypeFlags::kNone}}, |
366 | | {"num_entries", |
367 | | {offsetof(struct TableProperties, num_entries), OptionType::kUInt64T, |
368 | | OptionVerificationType::kNormal, OptionTypeFlags::kNone}}, |
369 | | {"num_filter_entries", |
370 | | {offsetof(struct TableProperties, num_filter_entries), |
371 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
372 | | OptionTypeFlags::kNone}}, |
373 | | {"num_deletions", |
374 | | {offsetof(struct TableProperties, num_deletions), OptionType::kUInt64T, |
375 | | OptionVerificationType::kNormal, OptionTypeFlags::kNone}}, |
376 | | {"num_merge_operands", |
377 | | {offsetof(struct TableProperties, num_merge_operands), |
378 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
379 | | OptionTypeFlags::kNone}}, |
380 | | {"num_range_deletions", |
381 | | {offsetof(struct TableProperties, num_range_deletions), |
382 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
383 | | OptionTypeFlags::kNone}}, |
384 | | {"format_version", |
385 | | {offsetof(struct TableProperties, format_version), |
386 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
387 | | OptionTypeFlags::kNone}}, |
388 | | {"fixed_key_len", |
389 | | {offsetof(struct TableProperties, fixed_key_len), OptionType::kUInt64T, |
390 | | OptionVerificationType::kNormal, OptionTypeFlags::kNone}}, |
391 | | {"column_family_id", |
392 | | {offsetof(struct TableProperties, column_family_id), |
393 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
394 | | OptionTypeFlags::kNone}}, |
395 | | {"creation_time", |
396 | | {offsetof(struct TableProperties, creation_time), OptionType::kUInt64T, |
397 | | OptionVerificationType::kNormal, OptionTypeFlags::kNone}}, |
398 | | {"oldest_key_time", |
399 | | {offsetof(struct TableProperties, oldest_key_time), |
400 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
401 | | OptionTypeFlags::kNone}}, |
402 | | {"newest_key_time", |
403 | | {offsetof(struct TableProperties, newest_key_time), |
404 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
405 | | OptionTypeFlags::kNone}}, |
406 | | {"file_creation_time", |
407 | | {offsetof(struct TableProperties, file_creation_time), |
408 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
409 | | OptionTypeFlags::kNone}}, |
410 | | {"slow_compression_estimated_data_size", |
411 | | {offsetof(struct TableProperties, |
412 | | slow_compression_estimated_data_size), |
413 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
414 | | OptionTypeFlags::kNone}}, |
415 | | {"fast_compression_estimated_data_size", |
416 | | {offsetof(struct TableProperties, |
417 | | fast_compression_estimated_data_size), |
418 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
419 | | OptionTypeFlags::kNone}}, |
420 | | {"external_sst_file_global_seqno_offset", |
421 | | {offsetof(struct TableProperties, |
422 | | external_sst_file_global_seqno_offset), |
423 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
424 | | OptionTypeFlags::kNone}}, |
425 | | {"tail_start_offset", |
426 | | {offsetof(struct TableProperties, tail_start_offset), |
427 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
428 | | OptionTypeFlags::kNone}}, |
429 | | {"user_defined_timestamps_persisted", |
430 | | {offsetof(struct TableProperties, user_defined_timestamps_persisted), |
431 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
432 | | OptionTypeFlags::kNone}}, |
433 | | {"key_largest_seqno", |
434 | | {offsetof(struct TableProperties, key_largest_seqno), |
435 | | OptionType::kUInt64T, OptionVerificationType::kNormal, |
436 | | OptionTypeFlags::kNone}}, |
437 | | {"db_id", |
438 | | {offsetof(struct TableProperties, db_id), OptionType::kEncodedString}}, |
439 | | {"db_session_id", |
440 | | {offsetof(struct TableProperties, db_session_id), |
441 | | OptionType::kEncodedString}}, |
442 | | {"db_host_id", |
443 | | {offsetof(struct TableProperties, db_host_id), |
444 | | OptionType::kEncodedString}}, |
445 | | {"column_family_name", |
446 | | {offsetof(struct TableProperties, column_family_name), |
447 | | OptionType::kEncodedString}}, |
448 | | {"filter_policy_name", |
449 | | {offsetof(struct TableProperties, filter_policy_name), |
450 | | OptionType::kEncodedString}}, |
451 | | {"comparator_name", |
452 | | {offsetof(struct TableProperties, comparator_name), |
453 | | OptionType::kEncodedString}}, |
454 | | {"merge_operator_name", |
455 | | {offsetof(struct TableProperties, merge_operator_name), |
456 | | OptionType::kEncodedString}}, |
457 | | {"prefix_extractor_name", |
458 | | {offsetof(struct TableProperties, prefix_extractor_name), |
459 | | OptionType::kEncodedString}}, |
460 | | {"property_collectors_names", |
461 | | {offsetof(struct TableProperties, property_collectors_names), |
462 | | OptionType::kEncodedString}}, |
463 | | {"compression_name", |
464 | | {offsetof(struct TableProperties, compression_name), |
465 | | OptionType::kEncodedString}}, |
466 | | {"compression_options", |
467 | | {offsetof(struct TableProperties, compression_options), |
468 | | OptionType::kEncodedString}}, |
469 | | {"seqno_to_time_mapping", |
470 | | {offsetof(struct TableProperties, seqno_to_time_mapping), |
471 | | OptionType::kEncodedString}}, |
472 | | {"user_collected_properties", |
473 | | OptionTypeInfo::StringMap( |
474 | | offsetof(struct TableProperties, user_collected_properties), |
475 | | OptionVerificationType::kNormal, OptionTypeFlags::kNone)}, |
476 | | {"readable_properties", |
477 | | OptionTypeInfo::StringMap( |
478 | | offsetof(struct TableProperties, readable_properties), |
479 | | OptionVerificationType::kNormal, OptionTypeFlags::kNone)}, |
480 | | }; |
481 | | |
482 | | Status TableProperties::Serialize(const ConfigOptions& opts, |
483 | 0 | std::string* output) const { |
484 | 0 | return OptionTypeInfo::SerializeType(opts, table_properties_type_info, this, |
485 | 0 | output); |
486 | 0 | } |
487 | | Status TableProperties::Parse(const ConfigOptions& opts, |
488 | | const std::string& serialized, |
489 | 0 | TableProperties* table_properties) { |
490 | 0 | return OptionTypeInfo::ParseType(opts, serialized, table_properties_type_info, |
491 | 0 | table_properties); |
492 | 0 | } |
493 | | bool TableProperties::AreEqual(const ConfigOptions& opts, |
494 | | const TableProperties* other_table_properties, |
495 | 0 | std::string* mismatch) const { |
496 | 0 | return OptionTypeInfo::TypesAreEqual(opts, table_properties_type_info, this, |
497 | 0 | other_table_properties, mismatch); |
498 | 0 | } |
499 | | |
500 | | #ifndef NDEBUG |
501 | | // WARNING: TEST_SetRandomTableProperties assumes the following layout of |
502 | | // TableProperties |
503 | | // |
504 | | // struct TableProperties { |
505 | | // int64_t orig_file_number = 0; |
506 | | // ... |
507 | | // ... int64_t properties only |
508 | | // ... |
509 | | // std::string db_id; |
510 | | // ... |
511 | | // ... std::string properties only |
512 | | // ... |
513 | | // std::string compression_options; |
514 | | // UserCollectedProperties user_collected_properties; |
515 | | // ... |
516 | | // ... Other extra properties: non-int64_t/non-std::string properties only |
517 | | // ... |
518 | | // } |
519 | | void TEST_SetRandomTableProperties(TableProperties* props) { |
520 | | Random* r = Random::GetTLSInstance(); |
521 | | uint64_t* pu = &props->orig_file_number; |
522 | | assert(static_cast<void*>(pu) == static_cast<void*>(props)); |
523 | | std::string* ps = &props->db_id; |
524 | | const uint64_t* const pu_end = reinterpret_cast<const uint64_t*>(ps); |
525 | | // Use the last string property's address instead of |
526 | | // the first extra property (e.g `user_collected_properties`)'s address |
527 | | // in the for-loop to avoid advancing pointer to pointing to |
528 | | // potential non-zero padding bytes between these two addresses due to |
529 | | // user_collected_properties's alignment requirement |
530 | | const std::string* const ps_end_inclusive = &props->compression_options; |
531 | | |
532 | | for (; pu < pu_end; ++pu) { |
533 | | *pu = r->Next64(); |
534 | | } |
535 | | assert(static_cast<void*>(pu) == static_cast<void*>(ps)); |
536 | | for (; ps <= ps_end_inclusive; ++ps) { |
537 | | *ps = r->RandomBinaryString(13); |
538 | | } |
539 | | } |
540 | | #endif |
541 | | |
542 | | } // namespace ROCKSDB_NAMESPACE |