diff --git a/db/db_impl.cc b/db/db_impl.cc index d9652d831f..daba9e8f91 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -170,6 +170,13 @@ class TablePropertiesCollectionIteratorImpl assert(Valid()); return filename_; } + + std::pair boundaries() const override { + assert(Valid()); + FileMetaData* f = *iter_; + return {f->smallest.user_key(), f->largest.user_key()}; + } + const std::shared_ptr& properties() const override { assert(Valid()); return properties_; diff --git a/db/db_impl_compaction_flush.cc b/db/db_impl_compaction_flush.cc index cc544b6fc6..3b47b4a2f8 100644 --- a/db/db_impl_compaction_flush.cc +++ b/db/db_impl_compaction_flush.cc @@ -638,6 +638,8 @@ void DBImpl::NotifyOnFlushCompleted( info.largest_seqno = file_meta->fd.largest_seqno; info.table_properties = prop; info.flush_reason = cfd->GetFlushReason(); + info.smallest_userkey = file_meta->smallest.user_key().ToString(); + info.largest_userkey = file_meta->largest.user_key().ToString(); for (auto listener : immutable_db_options_.listeners) { listener->OnFlushCompleted(this, info); } @@ -1202,6 +1204,8 @@ void DBImpl::NotifyOnCompactionCompleted( auto fn = TableFileName(c->immutable_cf_options()->cf_paths, fmd->fd.GetNumber(), fmd->fd.GetPathId()); info.input_files.push_back(fn); + info.input_boundries.push_back( + {fmd->smallest.user_key(), fmd->largest.user_key()}); if (info.table_properties.count(fn) == 0) { std::shared_ptr tp; auto s = current->GetTableProperties(&tp, fmd, &fn); @@ -1218,6 +1222,8 @@ void DBImpl::NotifyOnCompactionCompleted( info.output_files.push_back(TableFileName( c->immutable_cf_options()->cf_paths, newf.second.fd.GetNumber(), newf.second.fd.GetPathId())); + info.output_boundries.push_back( + {newf.second.smallest.user_key(), newf.second.largest.user_key()}); } for (auto listener : immutable_db_options_.listeners) { listener->OnCompactionCompleted(this, info); diff --git a/include/rocksdb/listener.h b/include/rocksdb/listener.h index 3ff0c0b241..3bffff1c34 100644 --- a/include/rocksdb/listener.h +++ b/include/rocksdb/listener.h @@ -37,6 +37,7 @@ class TablePropertiesCollectionIterator { virtual bool Valid() const = 0; virtual Status status() const = 0; + virtual std::pair boundaries() const = 0; public: // No copying allowed @@ -239,6 +240,10 @@ struct FlushJobInfo { TableProperties table_properties; FlushReason flush_reason; + + std::string smallest_userkey; + + std::string largest_userkey; }; struct TableTransientStat { @@ -277,9 +282,11 @@ struct CompactionJobInfo { int output_level; // the names of the compaction input files. std::vector input_files; + std::vector input_boundries; // the names of the compaction output files. std::vector output_files; + std::vector> output_boundries; // Table properties for input and output tables. // The map is keyed by values from input_files and output_files. TablePropertiesCollection table_properties;