You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/09/09 10:26:03 UTC
[GitHub] [iceberg] linfey90 opened a new pull request, #5733: Api: Optimize the code
linfey90 opened a new pull request, #5733:
URL: https://github.com/apache/iceberg/pull/5733
A little optimized code
--
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
[GitHub] [iceberg] linfey90 commented on a diff in pull request #5733: Api: Optimize the code
Posted by GitBox <gi...@apache.org>.
linfey90 commented on code in PR #5733:
URL: https://github.com/apache/iceberg/pull/5733#discussion_r990739016
##########
api/src/main/java/org/apache/iceberg/PartitionSpec.java:
##########
@@ -67,10 +67,7 @@ private PartitionSpec(
Schema schema, int specId, List<PartitionField> fields, int lastAssignedFieldId) {
this.schema = schema;
this.specId = specId;
- this.fields = new PartitionField[fields.size()];
- for (int i = 0; i < this.fields.length; i += 1) {
- this.fields[i] = fields.get(i);
- }
+ this.fields = fields.toArray(new PartitionField[fields.size()]);
Review Comment:
I got it, thanks very much!
--
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
[GitHub] [iceberg] Fokko merged pull request #5733: Api: Optimize the code
Posted by GitBox <gi...@apache.org>.
Fokko merged PR #5733:
URL: https://github.com/apache/iceberg/pull/5733
--
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
[GitHub] [iceberg] Fokko commented on pull request #5733: Api: Optimize the code
Posted by GitBox <gi...@apache.org>.
Fokko commented on PR #5733:
URL: https://github.com/apache/iceberg/pull/5733#issuecomment-1275706256
Thanks @linfey90 ππ»
--
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
[GitHub] [iceberg] nastra commented on a diff in pull request #5733: Api: Optimize the code
Posted by GitBox <gi...@apache.org>.
nastra commented on code in PR #5733:
URL: https://github.com/apache/iceberg/pull/5733#discussion_r989198389
##########
api/src/main/java/org/apache/iceberg/PartitionSpec.java:
##########
@@ -67,10 +67,7 @@ private PartitionSpec(
Schema schema, int specId, List<PartitionField> fields, int lastAssignedFieldId) {
this.schema = schema;
this.specId = specId;
- this.fields = new PartitionField[fields.size()];
- for (int i = 0; i < this.fields.length; i += 1) {
- this.fields[i] = fields.get(i);
- }
+ this.fields = fields.toArray(new PartitionField[fields.size()]);
Review Comment:
nit: `this.fields = fields.toArray(new PartitionField[0]);` is slightly better/better according to https://shipilev.net/blog/2016/arrays-wisdom-ancients/#_new_reflective_array
> Bottom line: toArray(new T[0]) seems faster, safer, and contractually cleaner, and therefore should be the default choice now. Future VM optimizations may close this performance gap for toArray(new T[size]), rendering the current "believed to be optimal" usages on par with an actually optimal one. [Further](https://bugs.openjdk.java.net/browse/JDK-8060192) [improvements](http://mail.openjdk.java.net/pipermail/valhalla-spec-experts/2015-December/000047.html) in toArray APIs would follow the same logic as toArray(new T[0])βββthe collection itself should create the appropriate storage.
--
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