iatsuk opened a new pull request, #8967: URL: https://github.com/apache/hadoop/pull/8967
### Description of PR `SFTPInputStream` overrides only `read()`, so bulk reads use the default `InputStream.read(byte[], int, int)` and go to JSch one byte at a time. This method was removed in HADOOP-14566 (seek support). This PR adds `read(byte[], int, int)` again. It passes the whole buffer to the JSch stream and updates `pos`, `nextPos` and the statistics in the same way as `read()`. The arguments are checked with `validatePositionedReadArgs()` like in `S3AInputStream`. As in `fsdatainputstream.md`, a read with `len == 0` returns 0, and a read at EOF returns -1. ### How was this patch tested? - New test `TestSFTPFileSystem#testReadFileInBulk`: reads a 1 MB + 17 bytes random file with 64 KB bulk reads, checks the data, the position, the result at EOF, a backward seek with `readFully()` and the `bytesRead` statistic. - `mvn -pl hadoop-common-project/hadoop-common test -Dtest='TestSFTPFileSystem,TestSFTPContractSeek'`: 32 tests, no failures. `TestSFTPContractSeek` is important here, because `readFully()` and positioned reads now use the new method. Benchmark: sequential read of a 1 GiB file (from `/dev/urandom`) from a local OpenSSH sftp server, with `FileSystem.open()` and `IOUtils.copyBytes(in, OutputStream.nullOutputStream(), 65536, false)`. Corretto 21.0.13, 16 vCPU, runs were interleaved. | Build | Run 1 | Run 2 | Run 3 | Mean | |---|---|---|---|---| | trunk (28c018cdafe) | 6.0 MB/s | 6.0 MB/s | 6.0 MB/s | 6.0 MB/s | | this PR | 530.5 MB/s | 554.7 MB/s | 539.7 MB/s | 541.6 MB/s | The SHA-256 of the data read with the fix is the same as the SHA-256 of the file. ### For code changes: - [x] Does the title of this PR start with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')? - [ ] Object storage: Have the integration tests been executed and the endpoint declared according to the connector-specific documentation? *Not an object store.* - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? *No new dependencies.* - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, `NOTICE-binary` files? *Not applicable.* ### AI Tooling If an AI tool was used: - [x] The PR includes the phrase "Contains content generated by <tool>" where <tool> is the name of the AI tool used. - [x] My use of AI contributions follows the ASF legal policy https://www.apache.org/legal/generative-tooling.html Contains content generated by Claude. I reviewed all the changes manually. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
