From e122c00204e1614e8bbe5e1427ae4c33ff2bba17 Mon Sep 17 00:00:00 2001 From: ZhaoMing Date: Mon, 14 Mar 2022 17:08:13 +0800 Subject: [PATCH] TablePropertiesCollector::AddUserKey() change value to value_or_meta. --- db/table_properties_collector.cc | 10 +++++++--- include/rocksdb/table_properties.h | 15 ++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/db/table_properties_collector.cc b/db/table_properties_collector.cc index cf6bea8ae8..b92cf97d0a 100644 --- a/db/table_properties_collector.cc +++ b/db/table_properties_collector.cc @@ -45,9 +45,13 @@ Status UserKeyTablePropertiesCollector::InternalAdd(const Slice& key, if (!ParseInternalKey(key, &ikey)) { return Status::InvalidArgument("Invalid internal key"); } - - return collector_->AddUserKey(ikey.user_key, value, GetEntryType(ikey.type), - ikey.sequence, file_size); + Slice value_or_meta = value; + if (ikey.type == kEntryMergeIndex || ikey.type == kEntryValueIndex) { + value_or_meta = SeparateHelper::DecodeValueMeta(value); + } + return collector_->AddUserKey(ikey.user_key, value_or_meta, + GetEntryType(ikey.type), ikey.sequence, + file_size); } Status UserKeyTablePropertiesCollector::Finish( diff --git a/include/rocksdb/table_properties.h b/include/rocksdb/table_properties.h index ac16052ac9..ed8d18b63d 100644 --- a/include/rocksdb/table_properties.h +++ b/include/rocksdb/table_properties.h @@ -99,13 +99,18 @@ class TablePropertiesCollector { // AddUserKey() will be called when a new key/value pair is inserted into the // table. - // @params key the user key that is inserted into the table. - // @params value the value that is inserted into the table. - virtual Status AddUserKey(const Slice& key, const Slice& value, - EntryType /*type*/, SequenceNumber /*seq*/, + // @params key the user key that is inserted into the table. + // @params value_or_meta the value that is inserted into the table. + virtual Status AddUserKey(const Slice& key, const Slice& value_or_meta, + EntryType type, SequenceNumber /*seq*/, uint64_t /*file_size*/) { + if (type == kEntryMergeIndex || type == kEntryValueIndex) { + return Status::NotSupported( + "TablePropertiesCollector::AddUserKey() need key value separation " + "support."); + } // For backwards-compatibility. - return Add(key, value); + return Add(key, value_or_meta); } // Finish() will be called when a table has already been built and is ready