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

Implement Parse and Translate methods that return readers #34

Merged
merged 2 commits into from
Sep 2, 2021

Conversation

tmaxmax
Copy link
Contributor

@tmaxmax tmaxmax commented Sep 2, 2021

Related: #33

Always reading the response body into memory results in unnecessary and
undesired allocations, especially when sending large documents to Tika
for parsing.
The call method, which is called for all API requests, doesn't copy the
response anymore. Instead, callString copies it for the methods that
return strings and callUnmarshal does its own buffering using the JSON
decoder.
This commit also creates a new method, ParseReader, which allows users
of the client to omit copying the response, but instead receive its
reader directly, which they are responsible to close.
As with ParseReader, a TranslateReader is provided for the same reasons.
Copy link
Member

@tbpg tbpg left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you!

@tbpg tbpg merged commit ffdbbef into google:master Sep 2, 2021
@tmaxmax tmaxmax deleted the no-copy-requests branch September 2, 2021 20:19
@tmaxmax
Copy link
Contributor Author

tmaxmax commented Sep 2, 2021

Shouldn't changes be tagged? The last tag is from 2019.

@tbpg
Copy link
Member

tbpg commented Sep 21, 2021

I tagged a new release (v0.2.0).

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.

2 participants