1 | // Licensed to the Apache Software Foundation (ASF) under one |
---|---|
2 | // or more contributor license agreements. See the NOTICE file |
3 | // distributed with this work for additional information |
4 | // regarding copyright ownership. The ASF licenses this file |
5 | // to you under the Apache License, Version 2.0 (the |
6 | // "License"); you may not use this file except in compliance |
7 | // with the License. You may obtain a copy of the License at |
8 | // |
9 | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | // |
11 | // Unless required by applicable law or agreed to in writing, |
12 | // software distributed under the License is distributed on an |
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | // KIND, either express or implied. See the License for the |
15 | // specific language governing permissions and limitations |
16 | // under the License. |
17 | |
18 | #include "arrow/util/compression.h" |
19 | |
20 | #include <memory> |
21 | |
22 | #ifdef ARROW_WITH_BROTLI |
23 | #include "arrow/util/compression_brotli.h" |
24 | #endif |
25 | |
26 | #ifdef ARROW_WITH_SNAPPY |
27 | #include "arrow/util/compression_snappy.h" |
28 | #endif |
29 | |
30 | #ifdef ARROW_WITH_LZ4 |
31 | #include "arrow/util/compression_lz4.h" |
32 | #endif |
33 | |
34 | #ifdef ARROW_WITH_ZLIB |
35 | #include "arrow/util/compression_zlib.h" |
36 | #endif |
37 | |
38 | #ifdef ARROW_WITH_ZSTD |
39 | #include "arrow/util/compression_zstd.h" |
40 | #endif |
41 | |
42 | #ifdef ARROW_WITH_BZ2 |
43 | #include "arrow/util/compression_bz2.h" |
44 | #endif |
45 | |
46 | #include "arrow/status.h" |
47 | |
48 | namespace arrow { |
49 | namespace util { |
50 | |
51 | Compressor::~Compressor() {} |
52 | |
53 | Decompressor::~Decompressor() {} |
54 | |
55 | Codec::~Codec() {} |
56 | |
57 | Status Codec::Create(Compression::type codec_type, std::unique_ptr<Codec>* result) { |
58 | switch (codec_type) { |
59 | case Compression::UNCOMPRESSED: |
60 | break; |
61 | case Compression::SNAPPY: |
62 | #ifdef ARROW_WITH_SNAPPY |
63 | result->reset(new SnappyCodec()); |
64 | break; |
65 | #else |
66 | return Status::NotImplemented("Snappy codec support not built"); |
67 | #endif |
68 | case Compression::GZIP: |
69 | #ifdef ARROW_WITH_ZLIB |
70 | result->reset(new GZipCodec()); |
71 | break; |
72 | #else |
73 | return Status::NotImplemented("Gzip codec support not built"); |
74 | #endif |
75 | case Compression::LZO: |
76 | return Status::NotImplemented("LZO codec not implemented"); |
77 | case Compression::BROTLI: |
78 | #ifdef ARROW_WITH_BROTLI |
79 | result->reset(new BrotliCodec()); |
80 | break; |
81 | #else |
82 | return Status::NotImplemented("Brotli codec support not built"); |
83 | #endif |
84 | case Compression::LZ4: |
85 | #ifdef ARROW_WITH_LZ4 |
86 | result->reset(new Lz4Codec()); |
87 | break; |
88 | #else |
89 | return Status::NotImplemented("LZ4 codec support not built"); |
90 | #endif |
91 | case Compression::ZSTD: |
92 | #ifdef ARROW_WITH_ZSTD |
93 | result->reset(new ZSTDCodec()); |
94 | break; |
95 | #else |
96 | return Status::NotImplemented("ZSTD codec support not built"); |
97 | #endif |
98 | case Compression::BZ2: |
99 | #ifdef ARROW_WITH_BZ2 |
100 | result->reset(new BZ2Codec()); |
101 | break; |
102 | #else |
103 | return Status::NotImplemented("BZ2 codec support not built"); |
104 | #endif |
105 | default: |
106 | return Status::Invalid("Unrecognized codec"); |
107 | } |
108 | return Status::OK(); |
109 | } |
110 | |
111 | } // namespace util |
112 | } // namespace arrow |
113 |