arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject arrow git commit: ARROW-1206: [C++] Add finer grained control of compression library support, do not expose symbols which may not be built in compression.h
Date Tue, 11 Jul 2017 18:13:09 GMT
Repository: arrow
Updated Branches:
  refs/heads/master e8c09c625 -> afb192824


ARROW-1206: [C++] Add finer grained control of compression library support, do not expose
symbols which may not be built in compression.h

MSVC will fail to link arrow.dll if one or more of the compression libraries is disabled.
This moves those symbols into their own header files. I also added additional options so any
of the compression libraries can be disabled in user builds. If they are disabled then `arrow::Codec::Create`
will fail with a helpful message

This build will still fail while the parquet-cpp build is broken

Close #810

Author: Wes McKinney <wes.mckinney@twosigma.com>

Closes #832 from wesm/fix-compressors-windows and squashes the following commits:

9c914b3d [Wes McKinney] Put compressor implementations in own headers, options to toggle each
compressor on/off, and add defines so that Codec::Create will work regardless of what compression
library support is built


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/afb19282
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/afb19282
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/afb19282

Branch: refs/heads/master
Commit: afb192824a75ab81fbc8dcd2da56409186bb23e0
Parents: e8c09c6
Author: Wes McKinney <wes.mckinney@twosigma.com>
Authored: Tue Jul 11 14:13:04 2017 -0400
Committer: Wes McKinney <wes.mckinney@twosigma.com>
Committed: Tue Jul 11 14:13:04 2017 -0400

----------------------------------------------------------------------
 cpp/CMakeLists.txt                       | 67 ++++++++++++++++-----
 cpp/src/arrow/util/CMakeLists.txt        |  5 ++
 cpp/src/arrow/util/compression-test.cc   | 32 +++++-----
 cpp/src/arrow/util/compression.cc        | 46 +++++++++++++++
 cpp/src/arrow/util/compression.h         | 85 ---------------------------
 cpp/src/arrow/util/compression_brotli.cc |  2 +-
 cpp/src/arrow/util/compression_brotli.h  | 45 ++++++++++++++
 cpp/src/arrow/util/compression_lz4.cc    |  2 +-
 cpp/src/arrow/util/compression_lz4.h     | 45 ++++++++++++++
 cpp/src/arrow/util/compression_snappy.cc |  2 +-
 cpp/src/arrow/util/compression_snappy.h  | 44 ++++++++++++++
 cpp/src/arrow/util/compression_zlib.cc   |  2 +-
 cpp/src/arrow/util/compression_zlib.h    | 60 +++++++++++++++++++
 cpp/src/arrow/util/compression_zstd.cc   |  2 +-
 cpp/src/arrow/util/compression_zstd.h    | 45 ++++++++++++++
 15 files changed, 365 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 77f1e59..d84611c 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -142,10 +142,22 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
     "Build with SSE4 optimizations"
     OFF)
 
+  option(ARROW_WITH_BROTLI
+    "Build with Brotli compression"
+    ON)
+
   option(ARROW_WITH_LZ4
     "Build with lz4 compression"
     ON)
 
+  option(ARROW_WITH_SNAPPY
+    "Build with Snappy compression"
+    ON)
+
+  option(ARROW_WITH_ZLIB
+    "Build with zlib compression"
+    ON)
+
   option(ARROW_WITH_ZSTD
     "Build with zstd compression"
     ON)
@@ -167,19 +179,21 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
   endif()
 endif()
 
-if(ARROW_BUILD_TESTS)
+if(ARROW_BUILD_TESTS OR ARROW_BUILD_BENCHMARKS)
   set(ARROW_BUILD_STATIC ON)
+  set(ARROW_WITH_BROTLI ON)
   set(ARROW_WITH_LZ4 ON)
+  set(ARROW_WITH_SNAPPY ON)
+  set(ARROW_WITH_ZLIB ON)
   set(ARROW_WITH_ZSTD ON)
-else()
+endif()
+
+if(NOT ARROW_BUILD_TESTS)
   set(NO_TESTS 1)
 endif()
 
 if(NOT ARROW_BUILD_BENCHMARKS)
   set(NO_BENCHMARKS 1)
-else()
-  set(ARROW_WITH_LZ4 ON)
-  set(ARROW_WITH_ZSTD ON)
 endif()
 
 if(ARROW_HDFS)
@@ -544,17 +558,28 @@ endif()
 # Linker and Dependencies
 ############################################################
 
-set(ARROW_STATIC_LINK_LIBS
-  brotli_dec
-  brotli_enc
-  brotli_common
-  snappy
-  zlib)
+set(ARROW_STATIC_LINK_LIBS)
+
+if (ARROW_WITH_BROTLI)
+  SET(ARROW_STATIC_LINK_LIBS
+    brotli_dec
+    brotli_enc
+    brotli_common
+    ${ARROW_STATIC_LINK_LIBS})
+endif()
 
 if (ARROW_WITH_LZ4)
   SET(ARROW_STATIC_LINK_LIBS lz4_static ${ARROW_STATIC_LINK_LIBS})
 endif()
 
+if (ARROW_WITH_SNAPPY)
+  SET(ARROW_STATIC_LINK_LIBS snappy ${ARROW_STATIC_LINK_LIBS})
+endif()
+
+if (ARROW_WITH_ZLIB)
+  SET(ARROW_STATIC_LINK_LIBS zlib ${ARROW_STATIC_LINK_LIBS})
+endif()
+
 if (ARROW_WITH_ZSTD)
   SET(ARROW_STATIC_LINK_LIBS zstd_static ${ARROW_STATIC_LINK_LIBS})
 endif()
@@ -683,19 +708,33 @@ set(ARROW_SRCS
 
   src/arrow/util/bit-util.cc
   src/arrow/util/compression.cc
-  src/arrow/util/compression_brotli.cc
-  src/arrow/util/compression_snappy.cc
-  src/arrow/util/compression_zlib.cc
   src/arrow/util/cpu-info.cc
   src/arrow/util/decimal.cc
   src/arrow/util/key_value_metadata.cc
 )
 
+if (ARROW_WITH_BROTLI)
+  add_definitions(-DARROW_WITH_BROTLI)
+  SET(ARROW_SRCS src/arrow/util/compression_brotli.cc ${ARROW_SRCS})
+endif()
+
 if (ARROW_WITH_LZ4)
+  add_definitions(-DARROW_WITH_LZ4)
   SET(ARROW_SRCS src/arrow/util/compression_lz4.cc ${ARROW_SRCS})
 endif()
 
+if (ARROW_WITH_SNAPPY)
+  add_definitions(-DARROW_WITH_SNAPPY)
+  SET(ARROW_SRCS src/arrow/util/compression_snappy.cc ${ARROW_SRCS})
+endif()
+
+if (ARROW_WITH_ZLIB)
+  add_definitions(-DARROW_WITH_ZLIB)
+  SET(ARROW_SRCS src/arrow/util/compression_zlib.cc ${ARROW_SRCS})
+endif()
+
 if (ARROW_WITH_ZSTD)
+  add_definitions(-DARROW_WITH_ZSTD)
   SET(ARROW_SRCS src/arrow/util/compression_zstd.cc ${ARROW_SRCS})
 endif()
 

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/CMakeLists.txt b/cpp/src/arrow/util/CMakeLists.txt
index bc1eeb2..8c1a23d 100644
--- a/cpp/src/arrow/util/CMakeLists.txt
+++ b/cpp/src/arrow/util/CMakeLists.txt
@@ -26,6 +26,11 @@ install(FILES
   bpacking.h
   compiler-util.h
   compression.h
+  compression_brotli.h
+  compression_lz4.h
+  compression_snappy.h
+  compression_zlib.h
+  compression_zstd.h
   cpu-info.h
   key_value_metadata.h
   hash-util.h

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression-test.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression-test.cc b/cpp/src/arrow/util/compression-test.cc
index 56dcc2a..f7739fc 100644
--- a/cpp/src/arrow/util/compression-test.cc
+++ b/cpp/src/arrow/util/compression-test.cc
@@ -29,69 +29,71 @@ using std::vector;
 
 namespace arrow {
 
-template <typename T>
+template <Compression::type CODEC>
 void CheckCodecRoundtrip(const vector<uint8_t>& data) {
   // create multiple compressors to try to break them
-  T c1;
-  T c2;
+  std::unique_ptr<Codec> c1, c2;
 
-  int max_compressed_len = static_cast<int>(c1.MaxCompressedLen(data.size(), &data[0]));
+  ASSERT_OK(Codec::Create(CODEC, &c1));
+  ASSERT_OK(Codec::Create(CODEC, &c2));
+
+  int max_compressed_len = static_cast<int>(c1->MaxCompressedLen(data.size(), &data[0]));
   std::vector<uint8_t> compressed(max_compressed_len);
   std::vector<uint8_t> decompressed(data.size());
 
   // compress with c1
   int64_t actual_size;
-  ASSERT_OK(c1.Compress(
+  ASSERT_OK(c1->Compress(
       data.size(), &data[0], max_compressed_len, &compressed[0], &actual_size));
   compressed.resize(actual_size);
 
   // decompress with c2
-  ASSERT_OK(c2.Decompress(
+  ASSERT_OK(c2->Decompress(
       compressed.size(), &compressed[0], decompressed.size(), &decompressed[0]));
 
   ASSERT_EQ(data, decompressed);
 
   // compress with c2
   int64_t actual_size2;
-  ASSERT_OK(c2.Compress(
+  ASSERT_OK(c2->Compress(
       data.size(), &data[0], max_compressed_len, &compressed[0], &actual_size2));
   ASSERT_EQ(actual_size2, actual_size);
 
   // decompress with c1
-  ASSERT_OK(c1.Decompress(
+  ASSERT_OK(c1->Decompress(
       compressed.size(), &compressed[0], decompressed.size(), &decompressed[0]));
 
   ASSERT_EQ(data, decompressed);
 }
 
-template <typename T>
+template <Compression::type CODEC>
 void CheckCodec() {
   int sizes[] = {10000, 100000};
   for (int data_size : sizes) {
     vector<uint8_t> data(data_size);
     test::random_bytes(data_size, 1234, data.data());
-    CheckCodecRoundtrip<T>(data);
+    CheckCodecRoundtrip<CODEC>(data);
   }
 }
 
 TEST(TestCompressors, Snappy) {
-  CheckCodec<SnappyCodec>();
+  CheckCodec<Compression::SNAPPY>();
 }
 
 TEST(TestCompressors, Brotli) {
-  CheckCodec<BrotliCodec>();
+  CheckCodec<Compression::BROTLI>();
 }
 
 TEST(TestCompressors, GZip) {
-  CheckCodec<GZipCodec>();
+  CheckCodec<Compression::GZIP>();
 }
 
 TEST(TestCompressors, ZSTD) {
-  CheckCodec<ZSTDCodec>();
+  CheckCodec<Compression::ZSTD>();
 }
 
 TEST(TestCompressors, Lz4) {
-  CheckCodec<Lz4Codec>();
+  CheckCodec<Compression::LZ4>();
 }
 
 }  // namespace arrow

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression.cc b/cpp/src/arrow/util/compression.cc
index 4681488..b4e5373 100644
--- a/cpp/src/arrow/util/compression.cc
+++ b/cpp/src/arrow/util/compression.cc
@@ -22,6 +22,26 @@
 #include <sstream>
 #include <string>
 
+#ifdef ARROW_WITH_BROTLI
+#include "arrow/util/compression_brotli.h"
+#endif
+
+#ifdef ARROW_WITH_SNAPPY
+#include "arrow/util/compression_snappy.h"
+#endif
+
+#ifdef ARROW_WITH_LZ4
+#include "arrow/util/compression_lz4.h"
+#endif
+
+#ifdef ARROW_WITH_ZLIB
+#include "arrow/util/compression_zlib.h"
+#endif
+
+#ifdef ARROW_WITH_ZSTD
+#include "arrow/util/compression_zstd.h"
+#endif
+
 #include "arrow/status.h"
 #include "arrow/util/logging.h"
 
@@ -34,15 +54,41 @@ Status Codec::Create(Compression::type codec_type, std::unique_ptr<Codec>*
resul
     case Compression::UNCOMPRESSED:
       break;
     case Compression::SNAPPY:
+#ifdef ARROW_WITH_SNAPPY
       result->reset(new SnappyCodec());
+#else
+      return Status::NotImplemented("Snappy codec support not built");
+#endif
       break;
     case Compression::GZIP:
+#ifdef ARROW_WITH_ZLIB
       result->reset(new GZipCodec());
+#else
+      return Status::NotImplemented("Gzip codec support not built");
+#endif
       break;
     case Compression::LZO:
       return Status::NotImplemented("LZO codec not implemented");
     case Compression::BROTLI:
+#ifdef ARROW_WITH_BROTLI
       result->reset(new BrotliCodec());
+#else
+      return Status::NotImplemented("Brotli codec support not built");
+#endif
+      break;
+    case Compression::LZ4:
+#ifdef ARROW_WITH_LZ4
+      result->reset(new Lz4Codec());
+#else
+      return Status::NotImplemented("LZ4 codec support not built");
+#endif
+      break;
+    case Compression::ZSTD:
+#ifdef ARROW_WITH_ZSTD
+      result->reset(new ZSTDCodec());
+#else
+      return Status::NotImplemented("ZSTD codec support not built");
+#endif
       break;
     default:
       return Status::Invalid("Unrecognized codec");

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression.h b/cpp/src/arrow/util/compression.h
index d382153..19c6117 100644
--- a/cpp/src/arrow/util/compression.h
+++ b/cpp/src/arrow/util/compression.h
@@ -47,91 +47,6 @@ class ARROW_EXPORT Codec {
   virtual const char* name() const = 0;
 };
 
-// Snappy codec.
-class ARROW_EXPORT SnappyCodec : public Codec {
- public:
-  Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_len,
-      uint8_t* output_buffer) override;
-
-  Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len,
-      uint8_t* output_buffer, int64_t* output_length) override;
-
-  int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override;
-
-  const char* name() const override { return "snappy"; }
-};
-
-// Brotli codec.
-class ARROW_EXPORT BrotliCodec : public Codec {
- public:
-  Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_len,
-      uint8_t* output_buffer) override;
-
-  Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len,
-      uint8_t* output_buffer, int64_t* output_length) override;
-
-  int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override;
-
-  const char* name() const override { return "brotli"; }
-};
-
-// GZip codec.
-class ARROW_EXPORT GZipCodec : public Codec {
- public:
-  /// Compression formats supported by the zlib library
-  enum Format {
-    ZLIB,
-    DEFLATE,
-    GZIP,
-  };
-
-  explicit GZipCodec(Format format = GZIP);
-  virtual ~GZipCodec();
-
-  Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_len,
-      uint8_t* output_buffer) override;
-
-  Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len,
-      uint8_t* output_buffer, int64_t* output_length) override;
-
-  int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override;
-
-  const char* name() const override;
-
- private:
-  // The gzip compressor is stateful
-  class GZipCodecImpl;
-  std::unique_ptr<GZipCodecImpl> impl_;
-};
-
-// ZSTD codec.
-class ARROW_EXPORT ZSTDCodec : public Codec {
- public:
-  Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_len,
-      uint8_t* output_buffer) override;
-
-  Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len,
-      uint8_t* output_buffer, int64_t* output_length) override;
-
-  int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override;
-
-  const char* name() const override { return "zstd"; }
-};
-
-// Lz4 codec.
-class ARROW_EXPORT Lz4Codec : public Codec {
- public:
-  Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_len,
-      uint8_t* output_buffer) override;
-
-  Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len,
-      uint8_t* output_buffer, int64_t* output_length) override;
-
-  int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override;
-
-  const char* name() const override { return "lz4"; }
-};
-
 }  // namespace arrow
 
 #endif

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression_brotli.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_brotli.cc b/cpp/src/arrow/util/compression_brotli.cc
index f5f9f57..c03573b 100644
--- a/cpp/src/arrow/util/compression_brotli.cc
+++ b/cpp/src/arrow/util/compression_brotli.cc
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "arrow/util/compression.h"
+#include "arrow/util/compression_brotli.h"
 
 #include <cstdint>
 #include <memory>

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression_brotli.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_brotli.h b/cpp/src/arrow/util/compression_brotli.h
new file mode 100644
index 0000000..08bd337
--- /dev/null
+++ b/cpp/src/arrow/util/compression_brotli.h
@@ -0,0 +1,45 @@
+// 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.
+
+#ifndef ARROW_UTIL_COMPRESSION_BROTLI_H
+#define ARROW_UTIL_COMPRESSION_BROTLI_H
+
+#include <cstdint>
+#include <memory>
+
+#include "arrow/status.h"
+#include "arrow/util/compression.h"
+
+namespace arrow {
+
+// Brotli codec.
+class ARROW_EXPORT BrotliCodec : public Codec {
+ public:
+  Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_len,
+      uint8_t* output_buffer) override;
+
+  Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len,
+      uint8_t* output_buffer, int64_t* output_length) override;
+
+  int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override;
+
+  const char* name() const override { return "brotli"; }
+};
+
+}  // namespace arrow
+
+#endif  // ARROW_UTIL_COMPRESSION_BROTLI_H

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression_lz4.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_lz4.cc b/cpp/src/arrow/util/compression_lz4.cc
index 27094f1..65eaa08 100644
--- a/cpp/src/arrow/util/compression_lz4.cc
+++ b/cpp/src/arrow/util/compression_lz4.cc
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "arrow/util/compression.h"
+#include "arrow/util/compression_lz4.h"
 
 #include <cstdint>
 #include <memory>

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression_lz4.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_lz4.h b/cpp/src/arrow/util/compression_lz4.h
new file mode 100644
index 0000000..9668fec
--- /dev/null
+++ b/cpp/src/arrow/util/compression_lz4.h
@@ -0,0 +1,45 @@
+// 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.
+
+#ifndef ARROW_UTIL_COMPRESSION_LZ4_H
+#define ARROW_UTIL_COMPRESSION_LZ4_H
+
+#include <cstdint>
+#include <memory>
+
+#include "arrow/status.h"
+#include "arrow/util/compression.h"
+
+namespace arrow {
+
+// Lz4 codec.
+class ARROW_EXPORT Lz4Codec : public Codec {
+ public:
+  Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_len,
+      uint8_t* output_buffer) override;
+
+  Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len,
+      uint8_t* output_buffer, int64_t* output_length) override;
+
+  int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override;
+
+  const char* name() const override { return "lz4"; }
+};
+
+}  // namespace arrow
+
+#endif  // ARROW_UTIL_COMPRESSION_LZ4_H

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression_snappy.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_snappy.cc b/cpp/src/arrow/util/compression_snappy.cc
index ab418b0..db2b673 100644
--- a/cpp/src/arrow/util/compression_snappy.cc
+++ b/cpp/src/arrow/util/compression_snappy.cc
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "arrow/util/compression.h"
+#include "arrow/util/compression_snappy.h"
 
 // Work around warning caused by Snappy include
 #ifdef DISALLOW_COPY_AND_ASSIGN

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression_snappy.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_snappy.h b/cpp/src/arrow/util/compression_snappy.h
new file mode 100644
index 0000000..25281e1
--- /dev/null
+++ b/cpp/src/arrow/util/compression_snappy.h
@@ -0,0 +1,44 @@
+// 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.
+
+#ifndef ARROW_UTIL_COMPRESSION_SNAPPY_H
+#define ARROW_UTIL_COMPRESSION_SNAPPY_H
+
+#include <cstdint>
+#include <memory>
+
+#include "arrow/status.h"
+#include "arrow/util/compression.h"
+
+namespace arrow {
+
+class ARROW_EXPORT SnappyCodec : public Codec {
+ public:
+  Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_len,
+      uint8_t* output_buffer) override;
+
+  Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len,
+      uint8_t* output_buffer, int64_t* output_length) override;
+
+  int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override;
+
+  const char* name() const override { return "snappy"; }
+};
+
+}  // namespace arrow
+
+#endif  // ARROW_UTIL_COMPRESSION_SNAPPY_H

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression_zlib.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_zlib.cc b/cpp/src/arrow/util/compression_zlib.cc
index 934ea1b..3ff33b8 100644
--- a/cpp/src/arrow/util/compression_zlib.cc
+++ b/cpp/src/arrow/util/compression_zlib.cc
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "arrow/util/compression.h"
+#include "arrow/util/compression_zlib.h"
 
 #include <cstdint>
 #include <memory>

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression_zlib.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_zlib.h b/cpp/src/arrow/util/compression_zlib.h
new file mode 100644
index 0000000..517a061
--- /dev/null
+++ b/cpp/src/arrow/util/compression_zlib.h
@@ -0,0 +1,60 @@
+// 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.
+
+#ifndef ARROW_UTIL_COMPRESSION_ZLIB_H
+#define ARROW_UTIL_COMPRESSION_ZLIB_H
+
+#include <cstdint>
+#include <memory>
+
+#include "arrow/status.h"
+#include "arrow/util/compression.h"
+
+namespace arrow {
+
+// GZip codec.
+class ARROW_EXPORT GZipCodec : public Codec {
+ public:
+  /// Compression formats supported by the zlib library
+  enum Format {
+    ZLIB,
+    DEFLATE,
+    GZIP,
+  };
+
+  explicit GZipCodec(Format format = GZIP);
+  virtual ~GZipCodec();
+
+  Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_len,
+      uint8_t* output_buffer) override;
+
+  Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len,
+      uint8_t* output_buffer, int64_t* output_length) override;
+
+  int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override;
+
+  const char* name() const override;
+
+ private:
+  // The gzip compressor is stateful
+  class GZipCodecImpl;
+  std::unique_ptr<GZipCodecImpl> impl_;
+};
+
+}  // namespace arrow
+
+#endif  // ARROW_UTIL_COMPRESSION_ZLIB_H

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression_zstd.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_zstd.cc b/cpp/src/arrow/util/compression_zstd.cc
index a03a3fc..5511cb9 100644
--- a/cpp/src/arrow/util/compression_zstd.cc
+++ b/cpp/src/arrow/util/compression_zstd.cc
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "arrow/util/compression.h"
+#include "arrow/util/compression_zstd.h"
 
 #include <cstdint>
 #include <memory>

http://git-wip-us.apache.org/repos/asf/arrow/blob/afb19282/cpp/src/arrow/util/compression_zstd.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/util/compression_zstd.h b/cpp/src/arrow/util/compression_zstd.h
new file mode 100644
index 0000000..2356d58
--- /dev/null
+++ b/cpp/src/arrow/util/compression_zstd.h
@@ -0,0 +1,45 @@
+// 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.
+
+#ifndef ARROW_UTIL_COMPRESSION_ZSTD_H
+#define ARROW_UTIL_COMPRESSION_ZSTD_H
+
+#include <cstdint>
+#include <memory>
+
+#include "arrow/status.h"
+#include "arrow/util/compression.h"
+
+namespace arrow {
+
+// ZSTD codec.
+class ARROW_EXPORT ZSTDCodec : public Codec {
+ public:
+  Status Decompress(int64_t input_len, const uint8_t* input, int64_t output_len,
+      uint8_t* output_buffer) override;
+
+  Status Compress(int64_t input_len, const uint8_t* input, int64_t output_buffer_len,
+      uint8_t* output_buffer, int64_t* output_length) override;
+
+  int64_t MaxCompressedLen(int64_t input_len, const uint8_t* input) override;
+
+  const char* name() const override { return "zstd"; }
+};
+
+}  // namespace arrow
+
+#endif  // ARROW_UTIL_COMPRESSION_ZSTD_H


Mime
View raw message