Skip to content
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

Adding support for readFully API #832

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

abmodi
Copy link
Contributor

@abmodi abmodi commented Jul 20, 2022

FSInputStream exposes readFully API to read entire content of file. With this implementation, we avoid unnecessary seeks while reading entire content.

@abmodi
Copy link
Contributor Author

abmodi commented Jul 20, 2022

/gcbrun

@abmodi abmodi requested a review from medb July 20, 2022 23:49
@abmodi abmodi self-assigned this Jul 21, 2022
@codecov
Copy link

codecov bot commented Jul 21, 2022

Codecov Report

Merging #832 (eeec92d) into master (a37b26c) will increase coverage by 0.02%.
The diff coverage is 88.46%.

@@             Coverage Diff              @@
##             master     #832      +/-   ##
============================================
+ Coverage     80.40%   80.43%   +0.02%     
  Complexity     1986     1986              
============================================
  Files           136      136              
  Lines          8989     9012      +23     
  Branches       1040     1042       +2     
============================================
+ Hits           7228     7249      +21     
- Misses         1344     1346       +2     
  Partials        417      417              
Flag Coverage Δ
integrationtest 61.99% <88.46%> (-0.20%) ⬇️
unittest 74.63% <88.46%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...oogle/cloud/hadoop/fs/gcs/GhfsInstrumentation.java 77.47% <80.00%> (+1.44%) ⬆️
...cloud/hadoop/fs/gcs/GoogleHadoopFSInputStream.java 90.80% <90.47%> (-0.50%) ⬇️
...ogle/cloud/hadoop/gcsio/PrefixMappedItemCache.java 70.27% <0.00%> (-2.71%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a37b26c...eeec92d. Read the comment docs.

in.readFully(2, value);
assertThat(in.getPos()).isEqualTo(0);
}
assertThat(value).isEqualTo(expected);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May you add test that demonstrates impact of this change (we have tests that assert number of GCS requests). For example, do we expect that number of the HTTP JSON GCS requests for readFully calls will be reduced after this change?

@@ -124,6 +122,35 @@ public synchronized int read(@Nonnull byte[] buf, int offset, int length) throws
return response;
}

@Override
public void readFully(long position, byte[] buffer, int offset, int length) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR comment mentions that this allows to avoid unnecessary seek. May you also clarify why is this important? Is this because we are sending new GCS request for each seek?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants