-
Notifications
You must be signed in to change notification settings - Fork 18
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
Adding Sanitizer interface and implementation #70
Conversation
/** | ||
* Sanitize returns a sanitized version of the input string value. | ||
*/ | ||
public interface Sanitize { |
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 try for a different name. Sanitize
next to Sanitizer
confused me thoroughly
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 Sanitizer
interface matches the uber-go/tally
Sanitizer interface.
The Sanitize
interface is meant to match the uber-go/tally
SanitizeFn interface. Name it SanitizeFn
too?
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 elaborate on what this interface is needed for
|
||
// first check if the provided character is valid | ||
boolean validCurr = | ||
ranges.stream().anyMatch(range -> ch >= range.low() && ch <= range.high()) |
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.
is this operation performance-sensitive? If so, this looks very expensive
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 matches the uber-go/tally
sanitzeFn(). Like the go version, it optimizes allocations by avoiding copying if the all characters are valid. Any suggestions on how to optimize this in Java?
Any progress on this PR? @ravirajj @inetchitailo ? |
@SokolAndrey @andrewmains12 @alexeykudinkin can you help take a look? I am needing this in my project. Thanks so much |
@@ -313,6 +320,14 @@ public Snapshot snapshot() { | |||
return snap; | |||
} | |||
|
|||
private ImmutableMap<String, String> copyAndSanitizeMap(Map<String, String> tags) { |
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.
Let's avoid copying if there are no changes to the map
* @param name the name string | ||
* @return the sanitized name | ||
*/ | ||
String name(String name); |
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 follow the naming convention -- method name should bear a verb in it
/** | ||
* Sanitize returns a sanitized version of the input string value. | ||
*/ | ||
public interface Sanitize { |
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 elaborate on what this interface is needed for
@alexeykudinkin @ravirajj Hello, thanks so much for this. Thanks |
@longquanzheng works for me |
ScopeBulider
can be configured with the standardM3Sanitizer
.