mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-25 22:44:05 +00:00
Expose num entries and deletions of sst files (#4623)
Summary: he ratio of num_deletions to num_entries of a level can be useful to determine if a manual compaction needs to be triggered on a level. Also refer #3980 Pull Request resolved: https://github.com/facebook/rocksdb/pull/4623 Differential Revision: D13045744 Pulled By: sagar0 fbshipit-source-id: 71f3c8e363a8ffd194ec3bb0ed0b69612231f0b3
This commit is contained in:
parent
5945e16dfc
commit
4f0fcb78ae
12
db/c.cc
12
db/c.cc
|
@ -3550,6 +3550,18 @@ const char* rocksdb_livefiles_largestkey(
|
|||
return lf->rep[index].largestkey.data();
|
||||
}
|
||||
|
||||
uint64_t rocksdb_livefiles_entries(
|
||||
const rocksdb_livefiles_t* lf,
|
||||
int index) {
|
||||
return lf->rep[index].num_entries;
|
||||
}
|
||||
|
||||
uint64_t rocksdb_livefiles_deletions(
|
||||
const rocksdb_livefiles_t* lf,
|
||||
int index) {
|
||||
return lf->rep[index].num_deletions;
|
||||
}
|
||||
|
||||
extern void rocksdb_livefiles_destroy(
|
||||
const rocksdb_livefiles_t* lf) {
|
||||
delete lf;
|
||||
|
|
|
@ -4405,6 +4405,8 @@ void VersionSet::GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata) {
|
|||
filemetadata.largestkey = file->largest.user_key().ToString();
|
||||
filemetadata.smallest_seqno = file->fd.smallest_seqno;
|
||||
filemetadata.largest_seqno = file->fd.largest_seqno;
|
||||
filemetadata.num_entries = file->num_entries;
|
||||
filemetadata.num_deletions = file->num_deletions;
|
||||
metadata->push_back(filemetadata);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1422,6 +1422,10 @@ extern ROCKSDB_LIBRARY_API const char* rocksdb_livefiles_smallestkey(
|
|||
const rocksdb_livefiles_t*, int index, size_t* size);
|
||||
extern ROCKSDB_LIBRARY_API const char* rocksdb_livefiles_largestkey(
|
||||
const rocksdb_livefiles_t*, int index, size_t* size);
|
||||
extern ROCKSDB_LIBRARY_API uint64_t rocksdb_livefiles_entries(
|
||||
const rocksdb_livefiles_t*, int index);
|
||||
extern ROCKSDB_LIBRARY_API uint64_t rocksdb_livefiles_deletions(
|
||||
const rocksdb_livefiles_t*, int index);
|
||||
extern ROCKSDB_LIBRARY_API void rocksdb_livefiles_destroy(
|
||||
const rocksdb_livefiles_t*);
|
||||
|
||||
|
|
|
@ -93,6 +93,9 @@ struct SstFileMetaData {
|
|||
std::string largestkey; // Largest user defined key in the file.
|
||||
uint64_t num_reads_sampled; // How many times the file is read.
|
||||
bool being_compacted; // true if the file is currently being compacted.
|
||||
|
||||
uint64_t num_entries;
|
||||
uint64_t num_deletions;
|
||||
};
|
||||
|
||||
// The full set of metadata associated with each SST file.
|
||||
|
|
Loading…
Reference in a new issue