mirror of
https://github.com/apache/arrow.git
synced 2026-10-28 16:47:19 +08:00
Add function to determine if support for codec is available
This commit is contained in:
1 parent
12100b2a9c
commit
b454874bf9
3 files changed
+54
No files matched your search
@@ -164,5 +164,52 @@ Status Codec::Create(Compression::type codec_type, int compression_level,
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
bool Codec::IsAvailable(Compression::type codec_type) {
|
||||
switch (codec_type) {
|
||||
case Compression::UNCOMPRESSED:
|
||||
return true;
|
||||
case Compression::SNAPPY:
|
||||
#ifdef ARROW_WITH_SNAPPY
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
case Compression::GZIP:
|
||||
#ifdef ARROW_WITH_ZLIB
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
case Compression::LZO:
|
||||
return false;
|
||||
case Compression::BROTLI:
|
||||
#ifdef ARROW_WITH_BROTLI
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
case Compression::LZ4:
|
||||
#ifdef ARROW_WITH_LZ4
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
case Compression::ZSTD:
|
||||
#ifdef ARROW_WITH_ZSTD
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
case Compression::BZ2:
|
||||
#ifdef ARROW_WITH_BZ2
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace arrow
|
||||
@@ -116,6 +116,9 @@ class ARROW_EXPORT Codec {
|
||||
static Status Create(Compression::type codec, int compression_level,
|
||||
std::unique_ptr<Codec>* out);
|
||||
|
||||
/// \brief Return true if support for indicated codec has been enabled
|
||||
static bool IsAvailable(Compression::type codec);
|
||||
|
||||
/// \brief One-shot decompression function
|
||||
///
|
||||
/// output_buffer_len must be correct and therefore be obtained in advance.
|
||||
|
||||
@@ -382,6 +382,10 @@ TEST(TestCodecMisc, SpecifyCompressionLevel) {
|
||||
std::vector<uint8_t> data = MakeRandomData(2000);
|
||||
for (const auto& combination : combinations) {
|
||||
const auto compression = combination.codec;
|
||||
if (!Codec::IsAvailable(compression)) {
|
||||
// Support for this codec hasn't been built
|
||||
continue;
|
||||
}
|
||||
const auto level = combination.level;
|
||||
const auto expect_success = combination.expect_success;
|
||||
std::unique_ptr<Codec> c1, c2;
|
||||
|
||||
Reference in new issue
Block a user