Skip to content

Commit 635900c

Browse files
committed
support file min_max userkey in EventListener
1 parent fa75757 commit 635900c

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

db/db_impl_compaction_flush.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,8 @@ void DBImpl::NotifyOnFlushCompleted(
638638
info.largest_seqno = file_meta->fd.largest_seqno;
639639
info.table_properties = prop;
640640
info.flush_reason = cfd->GetFlushReason();
641+
info.min_userkey = file_meta->smallest.user_key().ToString();
642+
info.max_userkey = file_meta->largest.user_key().ToString();
641643
for (auto listener : immutable_db_options_.listeners) {
642644
listener->OnFlushCompleted(this, info);
643645
}
@@ -1202,6 +1204,8 @@ void DBImpl::NotifyOnCompactionCompleted(
12021204
auto fn = TableFileName(c->immutable_cf_options()->cf_paths,
12031205
fmd->fd.GetNumber(), fmd->fd.GetPathId());
12041206
info.input_files.push_back(fn);
1207+
info.input_min_max.push_back({fmd->smallest.user_key().ToString(),
1208+
fmd->largest.user_key().ToString()});
12051209
if (info.table_properties.count(fn) == 0) {
12061210
std::shared_ptr<const TableProperties> tp;
12071211
auto s = current->GetTableProperties(&tp, fmd, &fn);
@@ -1218,6 +1222,9 @@ void DBImpl::NotifyOnCompactionCompleted(
12181222
info.output_files.push_back(TableFileName(
12191223
c->immutable_cf_options()->cf_paths, newf.second.fd.GetNumber(),
12201224
newf.second.fd.GetPathId()));
1225+
info.output_min_max.push_back(
1226+
{newf.second.smallest.user_key().ToString(),
1227+
newf.second.largest.user_key().ToString()});
12211228
}
12221229
for (auto listener : immutable_db_options_.listeners) {
12231230
listener->OnCompactionCompleted(this, info);

include/rocksdb/listener.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ struct FlushJobInfo {
239239
TableProperties table_properties;
240240

241241
FlushReason flush_reason;
242+
243+
std::string min_userkey;
244+
245+
std::string max_userkey;
242246
};
243247

244248
struct TableTransientStat {
@@ -277,9 +281,11 @@ struct CompactionJobInfo {
277281
int output_level;
278282
// the names of the compaction input files.
279283
std::vector<std::string> input_files;
284+
std::vector<std::pair<std::string,std::string>> input_min_max;
280285

281286
// the names of the compaction output files.
282287
std::vector<std::string> output_files;
288+
std::vector<std::pair<std::string,std::string>> output_min_max;
283289
// Table properties for input and output tables.
284290
// The map is keyed by values from input_files and output_files.
285291
TablePropertiesCollection table_properties;

0 commit comments

Comments
 (0)