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

support getUsage and getPinnedUsage in JavaAPI for Cache #7925

Closed
wants to merge 5 commits into from

Conversation

pheecian
Copy link

@pheecian pheecian commented Feb 3, 2021

support getUsage and getPinnedUsage in JavaAPI for Cache
also fix a typo in LRUCacheTest.java that the highPriPoolRatio is not valid(set 5, I guess it means 0.05)

@pheecian
Copy link
Author

pheecian commented Feb 3, 2021

these 2 methods are mentioned in https://github.com/facebook/rocksdb/wiki/Memory-usage-in-RocksDB

java/rocksjni/cache.cc Outdated Show resolved Hide resolved
@@ -10,4 +10,16 @@
protected Cache(final long nativeHandle) {
super(nativeHandle);
}
public long getUsage() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add Javadoc to each public method.

Copy link
Author

Choose a reason for hiding this comment

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

ok

Copy link
Collaborator

Choose a reason for hiding this comment

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

The sentence in the Javadoc description paragraph should start with a capital letter please.

Copy link
Author

Choose a reason for hiding this comment

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

ok

try(final Cache lruCache = new LRUCache(capacity,
numShardBits, strictCapacityLimit, highPriPoolRatio)) {
//no op
lruCache.getUsage();
Copy link
Collaborator

Choose a reason for hiding this comment

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

These need JUnit assertions on them please.

Copy link
Author

Choose a reason for hiding this comment

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

ok

lruCache.getUsage();
lruCache.getPinnedUsage();
} catch (Exception e) {
assert (false);
Copy link
Collaborator

@adamretter adamretter Feb 3, 2021

Choose a reason for hiding this comment

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

You can simply have the exception thrown by the method, this will then fail the test

Copy link
Author

Choose a reason for hiding this comment

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

ok

Copy link
Collaborator

@adamretter adamretter left a comment

Choose a reason for hiding this comment

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

Thanks. A few small tweaks please.

@ajkr
Copy link
Contributor

ajkr commented Mar 9, 2021

Hi @adamretter, are you satisfied with the updates after your last review?

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ajkr
Copy link
Contributor

ajkr commented Mar 16, 2021

@adamretter are your comments all addressed now?

try(final Cache lruCache = new LRUCache(capacity,
numShardBits, strictCapacityLimit, highPriPoolRatio)) {
//no op
assert (lruCache.getUsage() >= 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

There need to be test based assertions rather than system assertions. See the other tests for examples

Copy link
Author

Choose a reason for hiding this comment

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

ok

@@ -10,4 +10,16 @@
protected Cache(final long nativeHandle) {
super(nativeHandle);
}
public long getUsage() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The sentence in the Javadoc description paragraph should start with a capital letter please.

@adamretter
Copy link
Collaborator

@ajkr sorry I didn't see your request of me 1 week ago. Looks much better, just really needs to use the correct assertions in the test now

@facebook-github-bot
Copy link
Contributor

@pheecian has updated the pull request. You must reimport the pull request before landing.

@pheecian
Copy link
Author

@adamretter made code refined, would you please review it again?

@adamretter adamretter self-requested a review March 17, 2021 10:28
Copy link
Collaborator

@adamretter adamretter left a comment

Choose a reason for hiding this comment

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

Thanks. Looks good to me now.

@mrambacher @ajkr Ready for merge I think

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@ajkr merged this pull request in c603f2f.

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.

None yet

4 participants