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

Expose GetCompactionReasonString() publicly #6489

Conversation

thepulkitagarwal
Copy link

@thepulkitagarwal thepulkitagarwal commented Mar 6, 2020

For Issue #6471

Add function GetStringFromCompactionReason(...) to get a string value from compaction reason, similar to compression type in listener.h.

@@ -281,6 +281,8 @@ class Compaction {

int GetInputBaseLevel() const;

const char* GetCompactionReasonString() const;
Copy link
Contributor

Choose a reason for hiding this comment

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

In order to be publicly visible (i.e., usable by RocksDB users), the function needs to be declared in a header file under "include/" directory. For example take a look at how GetStringFromCompressionType() is declared:

Status GetStringFromCompressionType(std::string* compression_str,
CompressionType compression_type);
.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I probably shouldn't have provided this example here, as the declaration itself is not substantial. Meanwhile, the example function looks too similar to what our function does so it's tempting to follow its implementation pattern.

@thepulkitagarwal thepulkitagarwal force-pushed the compaction-reason-string branch from 22fde0b to e5cc030 Compare March 9, 2020 16:50
@thepulkitagarwal thepulkitagarwal changed the title [WIP] Expose GetCompactionReasonString() publicly Expose GetCompactionReasonString() publicly Mar 9, 2020
@@ -253,6 +254,25 @@ std::unordered_map<std::string, CompressionType>
{"kZSTD", kZSTD},
{"kZSTDNotFinalCompression", kZSTDNotFinalCompression},
{"kDisableCompressionOption", kDisableCompressionOption}};

std::unordered_map<std::string, CompactionReason>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we shouldn't follow GetStringFromCompressionType()'s implementation pattern - just following the declaration pattern (declaring GetStringFromCompactionReason() in a file under an "include/" directory) is enough. CompactionReason is not an option so its logic doesn't really belong here. We also don't do lookup based on string so the map isn't necessary.

Also if you want to make analogous changes for the other enums in "include/rocksdb/listener.h", that'd be helpful (e.g., TableFileCreationReason).

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure where it should be defined. I thought of putting the definition in compaction.h, but then the other enums' definitions wouldn't fit in there. What file would you suggest for that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like everything declared in include/rocksdb/listener.h so far is defined inline. We could either continue that pattern or create a db/listener.cc file for these definitions. Or, if you have the declarations in include/rocksdb/convenience.h, then the definitions should go in db/convenience.cc.

@cbi42
Copy link
Member

cbi42 commented Nov 21, 2023

Implemented in #11778

@cbi42 cbi42 closed this Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants