-
Notifications
You must be signed in to change notification settings - Fork 4k
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
THRIFT-2877 Generate hashCode using primitives, static utility methods #448
Conversation
Ah, I used Java 8 only methods. I'll fix this and reopen later. |
b436a7e
to
0e54f3f
Compare
Hi @roshan, sorry for the delay, I've just discovered this.
Does this involve any code-level transplant, like copy-paste ? |
Ha, thanks for that @nsuke . I only used the JDK 8 methods so we could keep |
@roshan great, thanks for working on it after such a long break. If the JDK-identical return values are important, we may probably ask https://issues.apache.org/jira/browse/LEGAL if it's feasible first, but it's not the case, I suppose ? |
My 2 nonbinding cents: No reasonable client should care about hashCode values, only that the values meet the hashCode contract (this is true of any language). I don't think preserving them should ever be a goal. A second comment, not as helpful since it requires work, is that we should enshrine perf improvements using a tool like jmh. We use this in Apache Aurora for example to ensure we have a shared history of performance improvements and regressions. |
a168c7b
to
a5f81a2
Compare
…hods The TBaseHelper.hashCode methods are the Java 8 implementations of hashCode for those types.
a5f81a2
to
c79377c
Compare
@nsuke, I switched it so we now consider a For what it's worth, though, the previous @jsirois That's a good idea. Unfortunately, I don't have the time at the moment to do that :( |
break; | ||
default: | ||
throw "compiler error: the following base type has no hashcode generator: " + | ||
t_base_type::t_base_name(((t_base_type*)t)->get_base()); |
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.
We can take this opportunity to stop throwing string here.
As I believe it should never happen (right ?), std::logic_error would be appropriate.
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.
Just a style nit, could you indent switch block in the same way as the other part of this file (less indentation) ?
@roshan I've added comments on minor points. Other than that I think we're good to proceed 👍 |
Thanks for the comments, @nsuke . I will squash after builds pass. |
260ec2a
to
8ea6669
Compare
…hods Client: Java Author: Roshan George <roshan@arjie.com> The TBaseHelper.hashCode methods are the Java 8 implementations of hashCode for those types. This closes apache#448
…hods Client: Java Author: Roshan George <roshan@arjie.com> The TBaseHelper.hashCode methods are the Java 8 implementations of hashCode for those types. This closes apache#448
…hods Client: Java Author: Roshan George <roshan@arjie.com> The TBaseHelper.hashCode methods are the Java 8 implementations of hashCode for those types. This closes apache#448
This is pretty much the List.hashCode() except without any list. It takes about a third the time on some rudimentary benchmarks. I tried it out with
generating this hashCode().
Populating these structs with some values has it match the AbstractList.hashCode() result but maybe we could try a different multiplicative factor.
Sorry about the other one #447. I rebased to one commit, but couldn't seem to reuse the old PR (it compiled locally on gcc but failed on clang).