forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PARQUET-769: Add support for Brotli compression
Author: Uwe L. Korn <uwelk@xhochy.com> Closes apache#194 from xhochy/PARQUET-769 and squashes the following commits: aad390f [Uwe L. Korn] Pass buffer sizes also as in parameter 9847171 [Uwe L. Korn] make format 855250d [Uwe L. Korn] make format 40e93de [Uwe L. Korn] Add FindBrotli 47b9d03 [Uwe L. Korn] PARQUET-769: Add support for Brotli compression Change-Id: I2f6b1c03f0b7e7d83f64d0e34859eb09f2702838
- Loading branch information
Showing
7 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// 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. | ||
|
||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <brotli/decode.h> | ||
#include <brotli/encode.h> | ||
|
||
#include "parquet/compression/codec.h" | ||
#include "parquet/exception.h" | ||
|
||
namespace parquet { | ||
|
||
void BrotliCodec::Decompress( | ||
int64_t input_len, const uint8_t* input, int64_t output_len, uint8_t* output_buffer) { | ||
size_t output_size = output_len; | ||
if (BrotliDecoderDecompress(input_len, input, &output_size, output_buffer) != | ||
BROTLI_DECODER_RESULT_SUCCESS) { | ||
throw parquet::ParquetException("Corrupt brotli compressed data."); | ||
} | ||
} | ||
|
||
int64_t BrotliCodec::MaxCompressedLen(int64_t input_len, const uint8_t* input) { | ||
return BrotliEncoderMaxCompressedSize(input_len); | ||
} | ||
|
||
int64_t BrotliCodec::Compress(int64_t input_len, const uint8_t* input, | ||
int64_t output_buffer_len, uint8_t* output_buffer) { | ||
size_t output_len = output_buffer_len; | ||
// TODO: Make quality configurable. We use 8 as a default as it is the best | ||
// trade-off for Parquet workload | ||
if (BrotliEncoderCompress(8, BROTLI_DEFAULT_WINDOW, BROTLI_DEFAULT_MODE, input_len, | ||
input, &output_len, output_buffer) == BROTLI_FALSE) { | ||
throw parquet::ParquetException("Brotli compression failure."); | ||
} | ||
return output_len; | ||
} | ||
|
||
} // namespace parquet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters