You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@orc.apache.org by "deshanxiao (via GitHub)" <gi...@apache.org> on 2023/12/28 11:00:09 UTC
[PR] ORC-1463: [Java] Support Brotli codec [orc]
deshanxiao opened a new pull request, #1714:
URL: https://github.com/apache/orc/pull/1714
### What changes were proposed in this pull request?
This PR is aimed to add Brotli codec defined by [RFC7932](https://www.ietf.org/rfc/rfc7932.txt).
### Why are the changes needed?
To support more codec in ORC.
### How was this patch tested?
UT and CI pipeline.
This closes #1563
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1463: [Java] Support Brotli codec [orc]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #1714:
URL: https://github.com/apache/orc/pull/1714#issuecomment-1874948501
Oh, this seems to cause more transitive dependencies in addition to `brotli4j.jar`. Are these expected and required ones, @deshanxiao ? Can we remove `service-1.15.0.jar`?
- https://github.com/dongjoon-hyun/spark/pull/9
- native-osx-aarch64/1.15.0//native-osx-aarch64-1.15.0.jar
- service/1.15.0//service-1.15.0.jar
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1463: [Java] Support Brotli codec [orc]
Posted by "williamhyun (via GitHub)" <gi...@apache.org>.
williamhyun commented on PR #1714:
URL: https://github.com/apache/orc/pull/1714#issuecomment-1874971651
Thank you, I will make it optional.
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1463: [Java] Support Brotli codec [orc]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #1714:
URL: https://github.com/apache/orc/pull/1714#issuecomment-1999981224
Yes, it was intentional, @cxzl25 , because it's a new feature from Spark's perspective. We need to focus on Spark perspective to do that like Spark documentation and configs.
Of course, you are welcome always. 😄 Go for it~
> Can I propose a PR that Spark supports ORC brotli ?
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1463: [Java] Support Brotli codec [orc]
Posted by "deshanxiao (via GitHub)" <gi...@apache.org>.
deshanxiao commented on code in PR #1714:
URL: https://github.com/apache/orc/pull/1714#discussion_r1439005034
##########
java/core/src/java/org/apache/orc/impl/BrotliCodec.java:
##########
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.orc.impl;
+
+import com.aayushatharva.brotli4j.Brotli4jLoader;
+import com.aayushatharva.brotli4j.decoder.DecoderJNI;
+import com.aayushatharva.brotli4j.encoder.Encoder;
+import org.apache.orc.CompressionCodec;
+import org.apache.orc.CompressionKind;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class BrotliCodec implements CompressionCodec, DirectDecompressionCodec {
+ // load jni library.
+ static {
+ Brotli4jLoader.ensureAvailability();
+ }
+
+ public BrotliCodec() {
+ }
+
+ static class BrotliOptions implements Options {
+
+ private Encoder.Mode mode = Encoder.Mode.GENERIC;
+ private int quality = -1;
+ private int lgwin = -1;
+
+ BrotliOptions() {
+
+ }
+
+ BrotliOptions(int quality, int lgwin, Encoder.Mode mode) {
+ this.quality = quality;
+ this.lgwin = lgwin;
+ this.mode = mode;
+ }
+
+ @Override
+ public Options copy() {
+ return new BrotliOptions(quality, lgwin, mode);
+ }
+
+ @Override
+ public Options setSpeed(SpeedModifier newValue) {
+ switch (newValue) {
+ case FAST:
+ // best speed + 1.
+ quality = 1;
+ break;
+ case DEFAULT:
+ // best quality. Keep default with default value.
+ quality = -1;
+ break;
+ case FASTEST:
+ // best speed.
+ quality = 0;
+ break;
+ default:
+ break;
+ }
+ return this;
+ }
+
+ @Override
+ public Options setData(DataKind newValue) {
+ switch (newValue) {
+ case BINARY:
+ mode = Encoder.Mode.GENERIC;
+ break;
+ case TEXT:
+ mode = Encoder.Mode.TEXT;
+ break;
+ default:
+ break;
+ }
+ return this;
+ }
+
+ public Encoder.Parameters brotli4jParameter() {
+ return new Encoder.Parameters()
+ .setQuality(quality).setWindow(lgwin).setMode(mode);
+ }
+ }
+
+ private static final BrotliCodec.BrotliOptions DEFAULT_OPTIONS = new BrotliOptions();
+
+ @Override
+ public Options getDefaultOptions() {
+ return DEFAULT_OPTIONS;
+ }
+
+ @Override
+ public boolean compress(
+ ByteBuffer in,
+ ByteBuffer out,
+ ByteBuffer overflow,
+ Options options) throws IOException {
+ BrotliOptions brotliOptions = (BrotliOptions) options;
Review Comment:
Fixed by brotli4j v1.15.0
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1463: [Java] Support Brotli codec [orc]
Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #1714:
URL: https://github.com/apache/orc/pull/1714#issuecomment-1874986314
Thank you! For Spark community, I'll exclude it officially and add a documentation later to guide the users to add that dependency from application side.
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1463: [Java] Support Brotli codec [orc]
Posted by "deshanxiao (via GitHub)" <gi...@apache.org>.
deshanxiao commented on code in PR #1714:
URL: https://github.com/apache/orc/pull/1714#discussion_r1437568857
##########
java/core/src/java/org/apache/orc/impl/BrotliCodec.java:
##########
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.orc.impl;
+
+import com.aayushatharva.brotli4j.Brotli4jLoader;
+import com.aayushatharva.brotli4j.decoder.DecoderJNI;
+import com.aayushatharva.brotli4j.encoder.Encoder;
+import org.apache.orc.CompressionCodec;
+import org.apache.orc.CompressionKind;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class BrotliCodec implements CompressionCodec, DirectDecompressionCodec {
+ // load jni library.
+ static {
+ Brotli4jLoader.ensureAvailability();
+ }
+
+ public BrotliCodec() {
+ }
+
+ static class BrotliOptions implements Options {
+
+ private Encoder.Mode mode = Encoder.Mode.GENERIC;
+ private int quality = -1;
+ private int lgwin = -1;
+
+ BrotliOptions() {
+
+ }
+
+ BrotliOptions(int quality, int lgwin, Encoder.Mode mode) {
+ this.quality = quality;
+ this.lgwin = lgwin;
+ this.mode = mode;
+ }
+
+ @Override
+ public Options copy() {
+ return new BrotliOptions(quality, lgwin, mode);
+ }
+
+ @Override
+ public Options setSpeed(SpeedModifier newValue) {
+ switch (newValue) {
+ case FAST:
+ // best speed + 1.
+ quality = 1;
+ break;
+ case DEFAULT:
+ // best quality. Keep default with default value.
+ quality = -1;
+ break;
+ case FASTEST:
+ // best speed.
+ quality = 0;
+ break;
+ default:
+ break;
+ }
+ return this;
+ }
+
+ @Override
+ public Options setData(DataKind newValue) {
+ switch (newValue) {
+ case BINARY:
+ mode = Encoder.Mode.GENERIC;
+ break;
+ case TEXT:
+ mode = Encoder.Mode.TEXT;
+ break;
+ default:
+ break;
+ }
+ return this;
+ }
+
+ public Encoder.Parameters brotli4jParameter() {
+ return new Encoder.Parameters()
+ .setQuality(quality).setWindow(lgwin).setMode(mode);
+ }
+ }
+
+ private static final BrotliCodec.BrotliOptions DEFAULT_OPTIONS = new BrotliOptions();
+
+ @Override
+ public Options getDefaultOptions() {
+ return DEFAULT_OPTIONS;
+ }
+
+ @Override
+ public boolean compress(
+ ByteBuffer in,
+ ByteBuffer out,
+ ByteBuffer overflow,
+ Options options) throws IOException {
+ BrotliOptions brotliOptions = (BrotliOptions) options;
Review Comment:
After a lot of testing I found out there is a problem that if the input data does not start from 0, this will cause the decompression to fail. So here is an extra copy when dealing with this situation.
I create a issue to Brotli4j: https://github.com/hyperxpro/Brotli4j/issues/126
Since this PR has been merged, it is easy for us to re-implement it if new version of Brotli4j is released. https://github.com/hyperxpro/Brotli4j/pull/124
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1463: [Java] Support Brotli codec [orc]
Posted by "deshanxiao (via GitHub)" <gi...@apache.org>.
deshanxiao commented on code in PR #1714:
URL: https://github.com/apache/orc/pull/1714#discussion_r1437568857
##########
java/core/src/java/org/apache/orc/impl/BrotliCodec.java:
##########
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.orc.impl;
+
+import com.aayushatharva.brotli4j.Brotli4jLoader;
+import com.aayushatharva.brotli4j.decoder.DecoderJNI;
+import com.aayushatharva.brotli4j.encoder.Encoder;
+import org.apache.orc.CompressionCodec;
+import org.apache.orc.CompressionKind;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class BrotliCodec implements CompressionCodec, DirectDecompressionCodec {
+ // load jni library.
+ static {
+ Brotli4jLoader.ensureAvailability();
+ }
+
+ public BrotliCodec() {
+ }
+
+ static class BrotliOptions implements Options {
+
+ private Encoder.Mode mode = Encoder.Mode.GENERIC;
+ private int quality = -1;
+ private int lgwin = -1;
+
+ BrotliOptions() {
+
+ }
+
+ BrotliOptions(int quality, int lgwin, Encoder.Mode mode) {
+ this.quality = quality;
+ this.lgwin = lgwin;
+ this.mode = mode;
+ }
+
+ @Override
+ public Options copy() {
+ return new BrotliOptions(quality, lgwin, mode);
+ }
+
+ @Override
+ public Options setSpeed(SpeedModifier newValue) {
+ switch (newValue) {
+ case FAST:
+ // best speed + 1.
+ quality = 1;
+ break;
+ case DEFAULT:
+ // best quality. Keep default with default value.
+ quality = -1;
+ break;
+ case FASTEST:
+ // best speed.
+ quality = 0;
+ break;
+ default:
+ break;
+ }
+ return this;
+ }
+
+ @Override
+ public Options setData(DataKind newValue) {
+ switch (newValue) {
+ case BINARY:
+ mode = Encoder.Mode.GENERIC;
+ break;
+ case TEXT:
+ mode = Encoder.Mode.TEXT;
+ break;
+ default:
+ break;
+ }
+ return this;
+ }
+
+ public Encoder.Parameters brotli4jParameter() {
+ return new Encoder.Parameters()
+ .setQuality(quality).setWindow(lgwin).setMode(mode);
+ }
+ }
+
+ private static final BrotliCodec.BrotliOptions DEFAULT_OPTIONS = new BrotliOptions();
+
+ @Override
+ public Options getDefaultOptions() {
+ return DEFAULT_OPTIONS;
+ }
+
+ @Override
+ public boolean compress(
+ ByteBuffer in,
+ ByteBuffer out,
+ ByteBuffer overflow,
+ Options options) throws IOException {
+ BrotliOptions brotliOptions = (BrotliOptions) options;
Review Comment:
After a lot of testing I found out there is a problem that if the input data does not start from 0, this will cause the decompression to fail. So here is an extra copy when dealing with this situation.
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1463: [Java] Support Brotli codec [orc]
Posted by "deshanxiao (via GitHub)" <gi...@apache.org>.
deshanxiao commented on PR #1714:
URL: https://github.com/apache/orc/pull/1714#issuecomment-1873658997
Thank you @williamhyun @dongjoon-hyun !
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1463: [Java] Support Brotli codec [orc]
Posted by "cxzl25 (via GitHub)" <gi...@apache.org>.
cxzl25 commented on PR #1714:
URL: https://github.com/apache/orc/pull/1714#issuecomment-1999090583
> For Spark community, I'll exclude it officially and add a documentation later to guide the users to add that dependency from application side.
Currently, the master branch of Spark has used ORC 2.0.0 version and supports brotli compression encoding. (SPARK-44115)
However, due to some hardcode checks in Spark, brotli cannot be used normally.
Can I propose a PR that Spark supports ORC brotli ?
https://github.com/cxzl25/spark/commit/0cd5d03116709ec86d9f96e269200f2d05f799ca
```sql
set spark.sql.orc.compression.codec=BROTLI;
```
```
java.lang.IllegalArgumentException: The value of spark.sql.orc.compression.codec should be one of uncompressed, lz4, lzo, snappy, zlib, none, zstd, but was brotli
```
By the way, `netty-codec` declares brotli-related dependencies for multiple OSs.
https://github.com/netty/netty/blob/3cd364107167600e8eb4b0b85553ed895519e2ed/codec/pom.xml#L91-L125
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1463: [Java] Support Brotli codec [orc]
Posted by "deshanxiao (via GitHub)" <gi...@apache.org>.
deshanxiao commented on code in PR #1714:
URL: https://github.com/apache/orc/pull/1714#discussion_r1437568857
##########
java/core/src/java/org/apache/orc/impl/BrotliCodec.java:
##########
@@ -0,0 +1,215 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.orc.impl;
+
+import com.aayushatharva.brotli4j.Brotli4jLoader;
+import com.aayushatharva.brotli4j.decoder.DecoderJNI;
+import com.aayushatharva.brotli4j.encoder.Encoder;
+import org.apache.orc.CompressionCodec;
+import org.apache.orc.CompressionKind;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class BrotliCodec implements CompressionCodec, DirectDecompressionCodec {
+ // load jni library.
+ static {
+ Brotli4jLoader.ensureAvailability();
+ }
+
+ public BrotliCodec() {
+ }
+
+ static class BrotliOptions implements Options {
+
+ private Encoder.Mode mode = Encoder.Mode.GENERIC;
+ private int quality = -1;
+ private int lgwin = -1;
+
+ BrotliOptions() {
+
+ }
+
+ BrotliOptions(int quality, int lgwin, Encoder.Mode mode) {
+ this.quality = quality;
+ this.lgwin = lgwin;
+ this.mode = mode;
+ }
+
+ @Override
+ public Options copy() {
+ return new BrotliOptions(quality, lgwin, mode);
+ }
+
+ @Override
+ public Options setSpeed(SpeedModifier newValue) {
+ switch (newValue) {
+ case FAST:
+ // best speed + 1.
+ quality = 1;
+ break;
+ case DEFAULT:
+ // best quality. Keep default with default value.
+ quality = -1;
+ break;
+ case FASTEST:
+ // best speed.
+ quality = 0;
+ break;
+ default:
+ break;
+ }
+ return this;
+ }
+
+ @Override
+ public Options setData(DataKind newValue) {
+ switch (newValue) {
+ case BINARY:
+ mode = Encoder.Mode.GENERIC;
+ break;
+ case TEXT:
+ mode = Encoder.Mode.TEXT;
+ break;
+ default:
+ break;
+ }
+ return this;
+ }
+
+ public Encoder.Parameters brotli4jParameter() {
+ return new Encoder.Parameters()
+ .setQuality(quality).setWindow(lgwin).setMode(mode);
+ }
+ }
+
+ private static final BrotliCodec.BrotliOptions DEFAULT_OPTIONS = new BrotliOptions();
+
+ @Override
+ public Options getDefaultOptions() {
+ return DEFAULT_OPTIONS;
+ }
+
+ @Override
+ public boolean compress(
+ ByteBuffer in,
+ ByteBuffer out,
+ ByteBuffer overflow,
+ Options options) throws IOException {
+ BrotliOptions brotliOptions = (BrotliOptions) options;
Review Comment:
After a lot of testing I found out there is a problem that if the input data does not start from 0, this will cause the decompression to fail. So here is an extra copy when dealing with this situation.
I create a issue to Brotli4j:
https://github.com/hyperxpro/Brotli4j/issues/126
Since this PR has been merged, it is easy for us to re-implement it if new version of Brotli4j is released.
https://github.com/hyperxpro/Brotli4j/pull/124
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ORC-1463: [Java] Support Brotli codec [orc]
Posted by "williamhyun (via GitHub)" <gi...@apache.org>.
williamhyun closed pull request #1714: ORC-1463: [Java] Support Brotli codec
URL: https://github.com/apache/orc/pull/1714
--
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: issues-unsubscribe@orc.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org