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

BlobInputStream should implement skip #3144

Open
OrangeDog opened this issue Feb 27, 2024 · 5 comments · May be fixed by #3148
Open

BlobInputStream should implement skip #3144

OrangeDog opened this issue Feb 27, 2024 · 5 comments · May be fixed by #3148

Comments

@OrangeDog
Copy link
Contributor

OrangeDog commented Feb 27, 2024

Describe the issue
InputStream has methods skip(long) and skipNBytes(long), which by default read and discard the given number of bytes. BlobInputStream should instead override this to call LargeObject.seek64, which will give better performance.

Driver Version?
42.7.2

@davecramer
Copy link
Member

Thanks for the suggestion.
Pull requests are welcome.

@OrangeDog
Copy link
Contributor Author

I don't see any existing tests for the class. LargeObjectManagerTest does a basic read but that seems to be it?
StrangeInputStream implements skip, but nothing ever calls it.

@vlsi
Copy link
Member

vlsi commented Feb 28, 2024

I guess we do not have specific tests for skip as we used the default implementation.
Sure if we add a custom implementation, we'll need to cover it with tests.

The mix of read + mark + skip + reset might be problematic for testing.

@OrangeDog
Copy link
Contributor Author

You have implemented mark, reset, and close, but there are apparently no tests for those. I am happy to add this feature, but I don't really want the burden of testing the whole thing from scratch. Unless I simply haven't found the tests?

@vlsi
Copy link
Member

vlsi commented Feb 28, 2024

In fact, the current implementation of reset resets the cached data, so there's no much value in testing mix of read/mark/reset calls.

mark/reset is tested in org.postgresql.test.jdbc2.BlobTest#markResetStream

@OrangeDog OrangeDog linked a pull request Feb 29, 2024 that will close this issue
9 tasks
OrangeDog added a commit to OrangeDog/pgjdbc that referenced this issue Mar 5, 2024
Using seek is more efficient than reading and discarding the bytes.
The only behavioural change is it now allows skipping past the natural end of the stream, but the method contract already allows for this. It should not break anything.

Closes pgjdbc#3144
OrangeDog added a commit to OrangeDog/pgjdbc that referenced this issue Mar 18, 2024
Using seek is more efficient than reading and discarding the bytes.
The only behavioural change is it now allows skipping past the natural end of the stream, but the method contract already allows for this. It should not break anything.

Closes pgjdbc#3144
OrangeDog added a commit to OrangeDog/pgjdbc that referenced this issue May 13, 2024
Using seek is more efficient than reading and discarding the bytes.
The only behavioural change is it now allows skipping past the natural end of the stream, but the method contract already allows for this. It should not break anything.

Closes pgjdbc#3144
OrangeDog added a commit to OrangeDog/pgjdbc that referenced this issue May 13, 2024
Using seek is more efficient than reading and discarding the bytes.
The only behavioural change is it now allows skipping past the natural end of the stream, but the method contract already allows for this. It should not break anything.

Closes pgjdbc#3144
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 a pull request may close this issue.

3 participants