-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[core] Fix checkstyle for CoreWorkload #897
[core] Fix checkstyle for CoreWorkload #897
Conversation
515652c
to
891da2c
Compare
f634de6
to
7a3b3c8
Compare
debf1b1
to
65410c0
Compare
I checked this with: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just want to maintain the protected
s in the CoreWorkload class since users (like me) may overload it and just tweak a method or two.
@@ -105,14 +83,14 @@ | |||
*/ | |||
public static final String FIELD_COUNT_PROPERTY_DEFAULT = "10"; | |||
|
|||
int fieldcount; | |||
private int fieldcount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the private
s should be protected
s for folks overloading the class (like me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these it would make more sense to add public getters/setters. It would break compatibility for now but would be better long term. I can add the getters/setters and push.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other thought here is to actually get the property value yourself instead of relying on CoreWorkload to populate the variable.
String table = p.getProperty(CoreWorkload.TABLENAME_PROPERTY, CoreWorkload.TABLENAME_PROPERTY_DEFAULT);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But for proper inheritance you don't want to use getters/setters, you want to access the variables directly (plus avoid the function call [which would eventually be inlined, but...])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok thats fair. Let me see what I can do about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found a way to allow protected variables in checkstyle.xml. It allowed me to set the variables to be protected.
@@ -506,14 +483,14 @@ public void init(Properties p) throws WorkloadException { | |||
INSERTION_RETRY_INTERVAL, INSERTION_RETRY_INTERVAL_DEFAULT)); | |||
} | |||
|
|||
public String buildKeyName(long keynum) { | |||
private String buildKeyName(long keynum) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup I'll make this protected.
@@ -523,7 +500,7 @@ public String buildKeyName(long keynum) { | |||
* Builds a value for a randomly chosen field. | |||
*/ | |||
private HashMap<String, ByteIterator> buildSingleValue(String key) { | |||
HashMap<String, ByteIterator> value = new HashMap<String, ByteIterator>(); | |||
HashMap<String, ByteIterator> value = new HashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we going to require JDK7+ for YCSB? Or should the core still maintain JDK5 or 6 compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pom.xml has the maven-compiler-plugin set to 1.7 for source and target. I don't think we are maintaining JDK 6 compatibility anymore. We started trying to add support for JDK 9 already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, sounds good.
@@ -653,7 +635,7 @@ public boolean doTransaction(DB db, Object threadstate) { | |||
* Bucket 1 means incorrect data was returned. | |||
* Bucket 2 means null data was returned when some data was expected. | |||
*/ | |||
protected void verifyRow(String key, HashMap<String, ByteIterator> cells) { | |||
private void verifyRow(String key, HashMap<String, ByteIterator> cells) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected
let overloaders override
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup I'll make this protected.
65410c0
to
1d5ba75
Compare
1d5ba75
to
79fce75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Thanks @manolama! |
Relates to #895