Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listener minmax userkey #227

Open
wants to merge 6 commits into
base: dev.1.4
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
@@ -170,6 +170,13 @@ class TablePropertiesCollectionIteratorImpl
assert(Valid());
return filename_;
}

std::pair<Slice, Slice> boundaries() const override {
assert(Valid());
FileMetaData* f = *iter_;
return {f->smallest.user_key(), f->largest.user_key()};
}

const std::shared_ptr<const TableProperties>& properties() const override {
assert(Valid());
return properties_;
6 changes: 6 additions & 0 deletions db/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
@@ -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<const TableProperties> 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);
7 changes: 7 additions & 0 deletions include/rocksdb/listener.h
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ class TablePropertiesCollectionIterator {

virtual bool Valid() const = 0;
virtual Status status() const = 0;
virtual std::pair<Slice,Slice> 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<std::string> input_files;
std::vector<std::pair<Slice,Slice> input_boundries;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boundaries ,拼写错误?


// the names of the compaction output files.
std::vector<std::string> output_files;
std::vector<std::pair<Slice,Slice>> output_boundries;
// Table properties for input and output tables.
// The map is keyed by values from input_files and output_files.
TablePropertiesCollection table_properties;