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/27 08:11:13 UTC
[GitHub] [iceberg] singhpk234 opened a new pull request, #5864: Core: Avoid extra getFileStatus call in HadoopInputFile
singhpk234 opened a new pull request, #5864:
URL: https://github.com/apache/iceberg/pull/5864
### About the change
In case we call both exists() & getLength() we make a redundant call to `getFileStatus` as `fs.exists(path)` internally checks
```java
/** Check if exists.
* @param f source file
*/
public boolean exists(Path f) throws IOException {
try {
return getFileStatus(f) != null;
} catch (FileNotFoundException e) {
return false;
}
}
```
So we could getFileStatus directly and cache it via lazyStat() in `stat` prop and in `getLength` & subsequent calls directly return it.
Note : This similar opt exists in S3InputFile as well as we cache the results in `getObjectMetadata` call https://github.com/apache/iceberg/blob/b9bbcfb0e4d8f2605d3c6fb2543cefdd5d09524d/aws/src/main/java/org/apache/iceberg/aws/s3/BaseS3File.java#L70
----
### Testing Done
Existing UT's
--
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] szehon-ho commented on pull request #5864: Core: Avoid extra getFileStatus call in HadoopInputFile
Posted by GitBox <gi...@apache.org>.
szehon-ho commented on PR #5864:
URL: https://github.com/apache/iceberg/pull/5864#issuecomment-1261235721
Thanks @singhpk234 for change, and @jackye1995 for extra review
--
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] szehon-ho commented on a diff in pull request #5864: Core: Avoid extra getFileStatus call in HadoopInputFile
Posted by GitBox <gi...@apache.org>.
szehon-ho commented on code in PR #5864:
URL: https://github.com/apache/iceberg/pull/5864#discussion_r981565003
##########
core/src/main/java/org/apache/iceberg/hadoop/HadoopInputFile.java:
##########
@@ -160,6 +160,8 @@ private FileStatus lazyStat() {
if (stat == null) {
try {
this.stat = fs.getFileStatus(path);
+ } catch (FileNotFoundException e) {
+ throw new NotFoundException(e, "Path does not exist: %s", path);
Review Comment:
Nit: maybe more correct: "File does not exist"?
--
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] singhpk234 commented on a diff in pull request #5864: Core: Avoid extra getFileStatus call in HadoopInputFile
Posted by GitBox <gi...@apache.org>.
singhpk234 commented on code in PR #5864:
URL: https://github.com/apache/iceberg/pull/5864#discussion_r981553246
##########
core/src/main/java/org/apache/iceberg/hadoop/HadoopInputFile.java:
##########
@@ -224,9 +224,13 @@ public String location() {
@Override
public boolean exists() {
try {
- return fs.exists(path);
- } catch (IOException e) {
- throw new RuntimeIOException(e, "Failed to check existence for file: %s", path);
+ return lazyStat() != null;
+ } catch (RuntimeIOException re) {
+ if (re.getCause() instanceof FileNotFoundException) {
Review Comment:
I think it makes sense :) , made the corresponding changes !
--
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] szehon-ho merged pull request #5864: Core: Avoid extra getFileStatus call in HadoopInputFile
Posted by GitBox <gi...@apache.org>.
szehon-ho merged PR #5864:
URL: https://github.com/apache/iceberg/pull/5864
--
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] singhpk234 commented on a diff in pull request #5864: Core: Avoid extra getFileStatus call in HadoopInputFile
Posted by GitBox <gi...@apache.org>.
singhpk234 commented on code in PR #5864:
URL: https://github.com/apache/iceberg/pull/5864#discussion_r981553246
##########
core/src/main/java/org/apache/iceberg/hadoop/HadoopInputFile.java:
##########
@@ -224,9 +224,13 @@ public String location() {
@Override
public boolean exists() {
try {
- return fs.exists(path);
- } catch (IOException e) {
- throw new RuntimeIOException(e, "Failed to check existence for file: %s", path);
+ return lazyStat() != null;
+ } catch (RuntimeIOException re) {
+ if (re.getCause() instanceof FileNotFoundException) {
Review Comment:
I think it makes sense :) , we kind of have similar handling for NoSuchKey exception. made the corresponding changes !
--
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] singhpk234 commented on a diff in pull request #5864: Core: Avoid extra getFileStatus call in HadoopInputFile
Posted by GitBox <gi...@apache.org>.
singhpk234 commented on code in PR #5864:
URL: https://github.com/apache/iceberg/pull/5864#discussion_r981553246
##########
core/src/main/java/org/apache/iceberg/hadoop/HadoopInputFile.java:
##########
@@ -224,9 +224,13 @@ public String location() {
@Override
public boolean exists() {
try {
- return fs.exists(path);
- } catch (IOException e) {
- throw new RuntimeIOException(e, "Failed to check existence for file: %s", path);
+ return lazyStat() != null;
+ } catch (RuntimeIOException re) {
+ if (re.getCause() instanceof FileNotFoundException) {
Review Comment:
I think it makes sense :), made the corresponding changes !
--
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] szehon-ho commented on a diff in pull request #5864: Core: Avoid extra getFileStatus call in HadoopInputFile
Posted by GitBox <gi...@apache.org>.
szehon-ho commented on code in PR #5864:
URL: https://github.com/apache/iceberg/pull/5864#discussion_r981520111
##########
core/src/main/java/org/apache/iceberg/hadoop/HadoopInputFile.java:
##########
@@ -224,9 +224,13 @@ public String location() {
@Override
public boolean exists() {
try {
- return fs.exists(path);
- } catch (IOException e) {
- throw new RuntimeIOException(e, "Failed to check existence for file: %s", path);
+ return lazyStat() != null;
+ } catch (RuntimeIOException re) {
+ if (re.getCause() instanceof FileNotFoundException) {
Review Comment:
Question, what do you think, about making lazyStat() catch FileNotFoundException specifically and throwing Iceberg's NotFoundException in that case? Then here we can catch directly NotFoundException?
--
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] singhpk234 commented on pull request #5864: Core: Avoid extra getFileStatus call in HadoopInputFile
Posted by GitBox <gi...@apache.org>.
singhpk234 commented on PR #5864:
URL: https://github.com/apache/iceberg/pull/5864#issuecomment-1259908220
> but what do you think to add a quick test in HadoopFileIOTest?
exists() coverage is covered in `TestStructuredStreamingRead3` and `TestDropTable`, but it defintely makes sense to add one in HadoopFileIO as well. made the changes.
--
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