// 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. // Compressed stream implementations #pragma once #include #include #include "arrow/io/concurrency.h" #include "arrow/io/interfaces.h" #include "arrow/util/visibility.h" namespace arrow { class MemoryPool; class Status; namespace util { class Codec; } // namespace util namespace io { class ARROW_EXPORT CompressedOutputStream : public OutputStream { public: ~CompressedOutputStream() override; /// \brief Create a compressed output stream wrapping the given output stream. static Result> Make( util::Codec* codec, const std::shared_ptr& raw, MemoryPool* pool = default_memory_pool()); // OutputStream interface /// \brief Close the compressed output stream. This implicitly closes the /// underlying raw output stream. Status Close() override; Status Abort() override; bool closed() const override; Result Tell() const override; Status Write(const void* data, int64_t nbytes) override; /// \cond FALSE using Writable::Write; /// \endcond Status Flush() override; /// \brief Return the underlying raw output stream. std::shared_ptr raw() const; private: ARROW_DISALLOW_COPY_AND_ASSIGN(CompressedOutputStream); CompressedOutputStream() = default; class ARROW_NO_EXPORT Impl; std::unique_ptr impl_; }; class ARROW_EXPORT CompressedInputStream : public internal::InputStreamConcurrencyWrapper { public: ~CompressedInputStream() override; /// \brief Create a compressed input stream wrapping the given input stream. static Result> Make( util::Codec* codec, const std::shared_ptr& raw, MemoryPool* pool = default_memory_pool()); // InputStream interface bool closed() const override; /// \brief Return the underlying raw input stream. std::shared_ptr raw() const; private: friend InputStreamConcurrencyWrapper; ARROW_DISALLOW_COPY_AND_ASSIGN(CompressedInputStream); CompressedInputStream() = default; /// \brief Close the compressed input stream. This implicitly closes the /// underlying raw input stream. Status DoClose(); Status DoAbort() override; Result DoTell() const; Result DoRead(int64_t nbytes, void* out); Result> DoRead(int64_t nbytes); class ARROW_NO_EXPORT Impl; std::unique_ptr impl_; }; } // namespace io } // namespace arrow