-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-28627 REST ScannerModel doesn't support includeStartRow/includeStopRow(addendum) #6499
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
Conversation
@@ -143,6 +145,13 @@ public void setIncludeStartRow(boolean includeStartRow) { | |||
this.includeStartRow = includeStartRow; | |||
} | |||
|
|||
private static class IncludeStartRowFIlter { |
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.
Typo, should be IncludeStartRowFilter
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.
updated
@@ -121,8 +121,10 @@ public class ScannerModel implements ProtobufMessageHandler, Serializable { | |||
private boolean cacheBlocks = true; | |||
private int limit = -1; | |||
|
|||
@JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = IncludeStartRowFIlter.class) |
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.
Why do we need the filter for this and not for the stopRow ?
Wouldn't JsonInclude.Include.NON_DEFAULT work here the same ?
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.
Also, a Unit test to check this serialization behaviour would be helpful.
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.
To make sure that it survives any later refactors, etc.
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 like there is already a test, it just needs to be updated.
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.
Why do we need the filter for this and not for the stopRow ?
JsonInclude.Include.NON_DEFAULT --> this annotation serialize the attribute only if the attribute value is different from it's default value , ex: for boolean variables if the value is false(default) it will not get serialized, if the value is true it gets serialized.
Since includeStopRow is false by default we can use this annotation, where as includeStartRow is true by default, so we can't use this annotation because when the value is set to false this attribute will not get serialized and it will be giving wrong results in the response of scan request.
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 like there is already a test, it just needs to be updated.
updated
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, I get it. I thought that the default referred to the enclosing type, not to the boolean primitive.
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.
Please see my comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cd1d831
to
58f8494
Compare
review comments are fixed, pls check |
58f8494
to
d7935ba
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
d7935ba
to
074f161
Compare
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@stoty review comments are addressed and the build is okay, please review the changes again |
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.
Basically fine, but could be more readable, please see my comments.
private static class IncludeStartRowFilter { | ||
@Override | ||
public boolean equals(Object value) { | ||
return Boolean.TRUE.equals(value); |
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.
Since this code is not performance critial, we could just check for the type and avoid the suppression:
if(value instanceOf Boolean) {
return Boolean.TRUE.equals(value);
} else {
return false;
}
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.
according to the documents EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS checks if we are doing an instanceof check on any thing other than the current class. in this case it is IncludeStartRowFilter.
the equals() implementation of Boolean class as below.
Since it is trying to check instanceof Boolean which is not in the Hierachy of IncludeStartRowFilter find bugs is reporting it as voilation.
I had tried your suggestion before, but it still fails due to above reason.
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.
Don't you love static checkers ?
OK, let's leave it like this.
return Boolean.TRUE.equals(value); | ||
} | ||
|
||
@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.
This is confusing, and I don't think this is necessary.
hashCode() is never called for for this object according to the docs.
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.
This is confusing, and I don't think this is necessary.
hashCode() is never called for for this object according to the docs.
hashCode is never called, I have added this dummy hashCode implementation as the spotbugs was complaining about the rule:
we can either supress the check or add a dummy hashCode implementation.
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.
In that case add the suppression instead.
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.
it's less bad.
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.
PR is updated with this change
…StopRow (addendum)
074f161
to
db05432
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.
+1 LGTM
Thank you
…StopRow (addendum) (apache#6499) Signed-off-by: Istvan Toth <stoty@apache.org>
HBASE-28627 REST ScannerModel doesn't support includeStartRow/includeStopRow(addendum)