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

Filesource compression support #5255

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

joelmarty
Copy link
Contributor

Description

Add support for compressed files in file source.

Issues Resolved

Fixes #5245

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
  • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Joël Marty <[email protected]>
Signed-off-by: Joël Marty <[email protected]>
Signed-off-by: Joël Marty <[email protected]>
Signed-off-by: Joël Marty <[email protected]>
@joelmarty joelmarty force-pushed the filesource-compression-support branch from c877f08 to 710dd13 Compare December 11, 2024 17:31
Signed-off-by: Joël Marty <[email protected]>
@joelmarty joelmarty force-pushed the filesource-compression-support branch from 74e0c6d to 4684124 Compare December 12, 2024 09:21
@@ -290,21 +321,18 @@ void setUp() {

@Test
void start_will_parse_codec_with_correct_inputStream() throws IOException {
createObjectUnderTest().start(buffer);
final FileInputStream decompressedStream = new FileInputStream(TEST_FILE_PATH_PLAIN);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rewrote the test: previous implementation worked by testing equality between the bytes produced by the source and the bytes produced by reading the file directly.
The test now checks that the codec is called with the inputstream returned by the decompression engine.

Copy link
Member

Choose a reason for hiding this comment

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

Rather than changing the whole test, could you just mock the DecompressionEngine to return exactly the bytes given?

Perhaps an alternative is to keep both tests.

Copy link
Contributor Author

@joelmarty joelmarty Dec 16, 2024

Choose a reason for hiding this comment

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

I cannot keep the test as it is: the test relies on the previous implementation's behavior: it tries to read from the input stream created in FileSource.CodecFileStrategy#start but because this stream is created in a try-with-resource (see FileSource.java L181), it is closed when the test tries to read it again on FileSourceTest.java L303.
In other words, the test used to work because the input stream was never properly closed in the previous implementation of the WithCodec strategy. I could reintroduce what I believe is a bug to keep the test as-is, but IMHO it would make more sense to validate the test is equivalent to the previous implementation.

Copy link
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

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

Thank you @joelmarty for this contribution! I have one comment on the tests, but the rest looks good.

@@ -290,21 +321,18 @@ void setUp() {

@Test
void start_will_parse_codec_with_correct_inputStream() throws IOException {
createObjectUnderTest().start(buffer);
final FileInputStream decompressedStream = new FileInputStream(TEST_FILE_PATH_PLAIN);
Copy link
Member

Choose a reason for hiding this comment

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

Rather than changing the whole test, could you just mock the DecompressionEngine to return exactly the bytes given?

Perhaps an alternative is to keep both tests.

@@ -10,3 +10,7 @@ Foundation (http://www.apache.org/).

This product includes software developed by
Joda.org (http://www.joda.org/).

This product includes software developed by
Copy link
Member

Choose a reason for hiding this comment

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

Is this a requirement from your company? We don't require contributors to add to this.

Copy link
Member

Choose a reason for hiding this comment

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

Please see if your company requires this. If not, it would be best to remove this change.

In the meantime, I'm also checking with the OpenSearch project to determine if this is an acceptable change or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, they asked me to make this change. According to our OSS team, it's how the company can retain the copyright for my contributions as an employee.
I am not sure whether the notice file is the appropriate place to capture this, the information I found after some search tends to say it is not.
I think it is better to get some guidance.

@@ -10,3 +10,7 @@ Foundation (http://www.apache.org/).

This product includes software developed by
Joda.org (http://www.joda.org/).

This product includes software developed by
Copy link
Member

Choose a reason for hiding this comment

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

Please see if your company requires this. If not, it would be best to remove this change.

In the meantime, I'm also checking with the OpenSearch project to determine if this is an acceptable change or not.

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.

Support compressed file sources
3 participants