Skip to content

Introduce BrotliEncoder#11256

Merged
normanmaurer merged 52 commits intonetty:4.1from
hyperxpro:brotli
Jul 8, 2021
Merged

Introduce BrotliEncoder#11256
normanmaurer merged 52 commits intonetty:4.1from
hyperxpro:brotli

Conversation

@hyperxpro
Copy link
Copy Markdown
Contributor

Motivation:
Currently, Netty only has BrotliDecoder which can decode Brotli encoded data. However, BrotliEncoder is missing which will encode normal data to Brotli encoded data.

Modification:
Added BrotliEncoder

Result:
Fixes #6899.

@hyperxpro hyperxpro force-pushed the brotli branch 2 times, most recently from 0adae1b to faa0621 Compare May 14, 2021 14:59
@hyperxpro
Copy link
Copy Markdown
Contributor Author

\cc @slandelle @idelpivnitskiy

Copy link
Copy Markdown
Member

@normanmaurer normanmaurer left a comment

Choose a reason for hiding this comment

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

Also please add tests

Fix failing test

Revert IDE formatting

Revert IDE formatting

fixes

fix test

Revert more
@slandelle
Copy link
Copy Markdown
Contributor

@hyperxpro Is brotli compression really supposed to be performed on the fly? From what I've experienced so far, compression seems to be really slow and best performed once and for all for static content, then cached.

@hyperxpro
Copy link
Copy Markdown
Contributor Author

@slandelle I agree with your point but Brotli compression speed cost is compensated by the compression ratio. So yeah, we can have it.

Copy link
Copy Markdown
Member

@idelpivnitskiy idelpivnitskiy 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 for the PR @hyperxpro!

+1 for adding tests. For BrotliEncoder it's enough to add a subclass of AbstractEncoderTest. See LzfEncoderTest as an example. But we also need tests for new features of HttpContentCompressor and CompressorHttp2ConnectionEncoder.

Please, also add reference to brotli4j in NOTICE.txt file, and add LICENSE.brotli4j.txt file in license folder. We forgot to do that when we added decoder.

@hyperxpro
Copy link
Copy Markdown
Contributor Author

I will add tests once you guys are okay with new commits.

Copy link
Copy Markdown
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

BrotliEncoder and its test class LGTM! I will leave HTTP-related classes for others to review as I don't have much context on it.

Please, also add tests for HTTP with "br" compression to cover BrotliContentCompressor and CompressorHttp2ConnectionEncoder.

@hyperxpro
Copy link
Copy Markdown
Contributor Author

Error:  Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:testCompile (default-testCompile) on project netty-codec: Compilation failure: Compilation failure: 
Error:  /home/runner/work/netty/netty/codec/src/test/java/io/netty/handler/codec/compression/BrotliEncoderTest.java:[23,7] error: BrotliEncoderTest is not abstract and does not override abstract method createChannel() in AbstractEncoderTest
Error:  /home/runner/work/netty/netty/codec/src/test/java/io/netty/handler/codec/compression/BrotliEncoderTest.java:[26,16] error: initChannel() in BrotliEncoderTest cannot override initChannel() in AbstractEncoderTest
Error:    overridden method is final

@normanmaurer Can you help? The test is same as LzfEncoderTest but it's not compiling.

@kashike
Copy link
Copy Markdown
Contributor

kashike commented Jun 3, 2021

Error:  Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:testCompile (default-testCompile) on project netty-codec: Compilation failure: Compilation failure: 
Error:  /home/runner/work/netty/netty/codec/src/test/java/io/netty/handler/codec/compression/BrotliEncoderTest.java:[23,7] error: BrotliEncoderTest is not abstract and does not override abstract method createChannel() in AbstractEncoderTest
Error:  /home/runner/work/netty/netty/codec/src/test/java/io/netty/handler/codec/compression/BrotliEncoderTest.java:[26,16] error: initChannel() in BrotliEncoderTest cannot override initChannel() in AbstractEncoderTest
Error:    overridden method is final

@normanmaurer Can you help? The test is same as LzfEncoderTest but it's not compiling.

@hyperxpro
https://github.com/netty/netty/pull/11256/files#diff-129844c472b5cf087ae4119467312848077644c9e11f52563e0659d92d5c0df6R25-R28 should be:

            @Override
            protected EmbeddedChannel createChannel() {
                return new EmbeddedChannel(new BrotliEncoder());
            }

ref: https://github.com/netty/netty/blob/master/codec/src/test/java/io/netty/handler/codec/compression/LzfEncoderTest.java#L25-L28

* A {@link CompressionOptions} instance is thread-safe
* and should be shared between multiple instances of Compressor.
*/
public interface CompressionOptions {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if we should maybe move this to the codec module under the compression package... @trustin WDYT ?

@hyperxpro
Copy link
Copy Markdown
Contributor Author

Actual: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccc
Got:    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccc

Never seen something this strange. @normanmaurer Any idea?

Copy link
Copy Markdown
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

I like new style of CompressionOptions

@hyperxpro
Copy link
Copy Markdown
Contributor Author

It's in the last call.

The compression bug is fixed (by using TEXT mode).

@normanmaurer
Copy link
Copy Markdown
Member

@hyperxpro PTAL ... I think moving the options make more sense

@hyperxpro
Copy link
Copy Markdown
Contributor Author

@hyperxpro PTAL ... I think moving the options make more sense

The API looks amazing. Thanks for the change. :)

@normanmaurer normanmaurer merged commit fef761d into netty:4.1 Jul 8, 2021
@normanmaurer
Copy link
Copy Markdown
Member

@hyperxpro thanks a lot!

@hyperxpro
Copy link
Copy Markdown
Contributor Author

Thanks a lot to everyone who participated in this PR and gave their feedback. :)

@hyperxpro hyperxpro deleted the brotli branch July 8, 2021 09:52
normanmaurer added a commit that referenced this pull request Jul 8, 2021
Motivation:
Currently, Netty only has BrotliDecoder which can decode Brotli encoded data. However, BrotliEncoder is missing which will encode normal data to Brotli encoded data.

Modification:
Added BrotliEncoder and CompressionOption

Result:
Fixes #6899.

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
}

/**
* @see BrotliOptions#DEFAULT
Copy link
Copy Markdown
Member

@trustin trustin Jul 8, 2021

Choose a reason for hiding this comment

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

This, as well as other member references in this class's Javadoc, won't be linked properly in generated Javadoc because they are not public. We need to write a proper first sentence, such as:

 * Returns the {@link BrotliOptions} with the default compression settings.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@trustin want to do a PR ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will do it as I've upcoming PR to enable Brotli tests on Windows.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @hyperxpro 🙇

@trustin
Copy link
Copy Markdown
Member

trustin commented Jul 8, 2021

Thanks a lot for your hard work, @hyperxpro! Looking great indeed. Too bad we're not at Java 8 yet, though 😅

normanmaurer pushed a commit that referenced this pull request Jul 13, 2021
…11482)

Motivation:
In #11256, We introduced `Iterable` as a parameter but later in review, it was removed. But we forgot to change `compressionOptionsIterable` to just `compressionOptions`.

Modification:
Changed `compressionOptionsIterable` to `compressionOptions`.

Result:
Correct ObjectUtil message
normanmaurer pushed a commit that referenced this pull request Jul 13, 2021
…11482)

Motivation:
In #11256, We introduced `Iterable` as a parameter but later in review, it was removed. But we forgot to change `compressionOptionsIterable` to just `compressionOptions`.

Modification:
Changed `compressionOptionsIterable` to `compressionOptions`.

Result:
Correct ObjectUtil message
raidyue pushed a commit to raidyue/netty that referenced this pull request Jul 8, 2022
Motivation:
Currently, Netty only has BrotliDecoder which can decode Brotli encoded data. However, BrotliEncoder is missing which will encode normal data to Brotli encoded data.

Modification:
Added BrotliEncoder and CompressionOption

Result:
Fixes netty#6899.

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
raidyue pushed a commit to raidyue/netty that referenced this pull request Jul 8, 2022
…etty#11482)

Motivation:
In netty#11256, We introduced `Iterable` as a parameter but later in review, it was removed. But we forgot to change `compressionOptionsIterable` to just `compressionOptions`.

Modification:
Changed `compressionOptionsIterable` to `compressionOptions`.

Result:
Correct ObjectUtil message
dongjoon-hyun added a commit to apache/spark that referenced this pull request Dec 5, 2025
…` license

### What changes were proposed in this pull request?

This PR aims to update `NOTICE-binary` with `Netty` 4.2.7 license.
- https://github.com/netty/netty/blob/netty-4.2.7.Final/NOTICE.txt

### Why are the changes needed?

It seems that we updated `Netty Notice` at Apache Spark `3.0.0-preview` with `Netty 4.1.30.Final`.
- #25544

Since there are many changes like the following, we need to update it by simply copying and pasting.
- Netty 4.1.38.Final
  - netty/netty#9344
- Netty 4.1.44.Final
  - netty/netty#9161
- Netty 4.1.54.Final
  - netty/netty#10773
- Netty 4.1.66.Final
  - netty/netty#11256
  - netty/netty#11437
- Netty 4.1.108.Final
  - netty/netty#13864
- Netty 4.2.1.Final
  - netty/netty#14979
- Netty 4.2.7.Final
  - netty/netty#15658

Additionally, I also double-checked newly added transitive license through ASF [LEGAL-700](https://issues.apache.org/jira/browse/LEGAL-700). We are good to go.

- **Apple Public Source License 2.0**
  - https://spdx.org/licenses/APSL-2.0.html

### Does this PR introduce _any_ user-facing change?

No behavior change.

### How was this patch tested?

Manual review.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #53335 from dongjoon-hyun/SPARK-54602.

Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
dongjoon-hyun added a commit to apache/spark that referenced this pull request Dec 5, 2025
…` license

### What changes were proposed in this pull request?

This PR aims to update `NOTICE-binary` with `Netty` 4.2.7 license.
- https://github.com/netty/netty/blob/netty-4.2.7.Final/NOTICE.txt

### Why are the changes needed?

It seems that we updated `Netty Notice` at Apache Spark `3.0.0-preview` with `Netty 4.1.30.Final`.
- #25544

Since there are many changes like the following, we need to update it by simply copying and pasting.
- Netty 4.1.38.Final
  - netty/netty#9344
- Netty 4.1.44.Final
  - netty/netty#9161
- Netty 4.1.54.Final
  - netty/netty#10773
- Netty 4.1.66.Final
  - netty/netty#11256
  - netty/netty#11437
- Netty 4.1.108.Final
  - netty/netty#13864
- Netty 4.2.1.Final
  - netty/netty#14979
- Netty 4.2.7.Final
  - netty/netty#15658

Additionally, I also double-checked newly added transitive license through ASF [LEGAL-700](https://issues.apache.org/jira/browse/LEGAL-700). We are good to go.

- **Apple Public Source License 2.0**
  - https://spdx.org/licenses/APSL-2.0.html

### Does this PR introduce _any_ user-facing change?

No behavior change.

### How was this patch tested?

Manual review.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #53335 from dongjoon-hyun/SPARK-54602.

Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit 191ce4c)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
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 Brotli

8 participants