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
Show file tree
Hide file tree
Changes from 5 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
8 changes: 8 additions & 0 deletions db/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ class TablePropertiesCollectionIteratorImpl
assert(Valid());
return filename_;
}

std::pair<std::string, std::string> fileRange() const override {
Copy link
Collaborator

Choose a reason for hiding this comment

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

std::pair<Slice, Slice> boundaries() const override {

assert(Valid());
FileMetaData* f = *iter_;
return {f->smallest.user_key().ToString(),
f->largest.user_key().ToString()};
}

const std::shared_ptr<const TableProperties>& properties() const override {
assert(Valid());
return properties_;
Expand Down
8 changes: 8 additions & 0 deletions db/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -1202,6 +1204,9 @@ 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_files_boundries_user_key.push_back(
Copy link
Collaborator

Choose a reason for hiding this comment

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

boundaries ?

{fmd->smallest.user_key().ToString(),
fmd->largest.user_key().ToString()});
if (info.table_properties.count(fn) == 0) {
std::shared_ptr<const TableProperties> tp;
auto s = current->GetTableProperties(&tp, fmd, &fn);
Expand All @@ -1218,6 +1223,9 @@ 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_files_boundries_user_key.push_back(
{newf.second.smallest.user_key().ToString(),
newf.second.largest.user_key().ToString()});
}
for (auto listener : immutable_db_options_.listeners) {
listener->OnCompactionCompleted(this, info);
Expand Down
7 changes: 7 additions & 0 deletions include/rocksdb/listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TablePropertiesCollectionIterator {

virtual bool Valid() const = 0;
virtual Status status() const = 0;
virtual std::pair<std::string,std::string> fileRange() const = 0;

public:
// No copying allowed
Expand Down Expand Up @@ -239,6 +240,10 @@ struct FlushJobInfo {
TableProperties table_properties;

FlushReason flush_reason;

std::string smallest_userkey;

std::string largest_userkey;
};

struct TableTransientStat {
Expand Down Expand Up @@ -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<std::string,std::string>> input_files_boundries_user_key;

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