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 2020/06/24 16:33:14 UTC
[GitHub] [iceberg] rdblue commented on a change in pull request #1124: Add Spark 3 data source classes
rdblue commented on a change in pull request #1124:
URL: https://github.com/apache/iceberg/pull/1124#discussion_r445023516
##########
File path: core/src/main/java/org/apache/iceberg/hadoop/HadoopInputFile.java
##########
@@ -169,6 +174,24 @@ public FileStatus getStat() {
return lazyStat();
}
+ public Path getPath() {
+ return path;
+ }
+
+ public String[] getBlockLocations(long start, long end) {
+ List<String> hosts = Lists.newArrayList();
+ try {
+ for (BlockLocation location : fs.getFileBlockLocations(path, start, end)) {
+ Collections.addAll(hosts, location.getHosts());
+ }
+
+ return hosts.toArray(NO_LOCATION_PREFERENCE);
Review comment:
Yeah, it is odd how this API works, but when you pass in an array with fewer elements than you need, it will allocate a new one for you that is the right size. So we pass in a 0-element array. If you just call `toArray`, Java won't get the type right. The streams API allows passing in an array constructor (`String[]::new`), but it seems awkward to create a stream when there's already a working, although awkward, API call for it.
----------------------------------------------------------------
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.
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