You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "amogh-jahagirdar (via GitHub)" <gi...@apache.org> on 2024/04/10 01:51:49 UTC
Re: [PR] Core: Lazily compute & cache hashCode in CharSequenceWrapper [iceberg]
amogh-jahagirdar commented on code in PR #10023:
URL: https://github.com/apache/iceberg/pull/10023#discussion_r1558672872
##########
api/src/main/java/org/apache/iceberg/util/CharSequenceWrapper.java:
##########
@@ -29,13 +29,16 @@ public static CharSequenceWrapper wrap(CharSequence seq) {
}
private CharSequence wrapped;
+ // lazily computed & cached hashCode
+ private transient int hashCode = 0;
Review Comment:
Hmm, I'm not sure I'd set a default value of 0, since that technically can be a legit hashCode value for some series of characters no?
I think I'd make this an Integer hashCode and have it be null to identify that nothing is cached yet.
##########
api/src/main/java/org/apache/iceberg/util/CharSequenceWrapper.java:
##########
@@ -29,13 +29,16 @@ public static CharSequenceWrapper wrap(CharSequence seq) {
}
private CharSequence wrapped;
+ // lazily computed & cached hashCode
+ private transient int hashCode = 0;
Review Comment:
But good call making it transient, that's important since it shouldn't be serialized and the cache somehow used across JVMs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org