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#pragma once
19
20#include <cstdint>
21#include <memory>
22
23#include "arrow/buffer.h" // IWYU pragma: export
24#include "arrow/io/interfaces.h" // IWYU pragma: export
25#include "arrow/io/memory.h" // IWYU pragma: export
26#include "arrow/memory_pool.h" // IWYU pragma: export
27#include "arrow/status.h" // IWYU pragma: export
28#include "arrow/util/bit_util.h" // IWYU pragma: export
29#include "arrow/util/compression.h" // IWYU pragma: export
30#include "arrow/util/macros.h" // IWYU pragma: export
31#include "arrow/util/string_view.h" // IWYU pragma: export
32
33#if defined(_WIN32) || defined(__CYGWIN__)
34
35#if defined(_MSC_VER)
36#pragma warning(push)
37// Disable warning for STL types usage in DLL interface
38// https://web.archive.org/web/20130317015847/http://connect.microsoft.com/VisualStudio/feedback/details/696593/vc-10-vs-2010-basic-string-exports
39#pragma warning(disable : 4275 4251)
40// Disable diamond inheritance warnings
41#pragma warning(disable : 4250)
42// Disable macro redefinition warnings
43#pragma warning(disable : 4005)
44// Disable extern before exported template warnings
45#pragma warning(disable : 4910)
46#else
47#pragma GCC diagnostic ignored "-Wattributes"
48#endif
49
50#ifdef PARQUET_STATIC
51#define PARQUET_EXPORT
52#elif defined(PARQUET_EXPORTING)
53#define PARQUET_EXPORT __declspec(dllexport)
54#else
55#define PARQUET_EXPORT __declspec(dllimport)
56#endif
57
58#define PARQUET_NO_EXPORT
59
60#else // Not Windows
61#ifndef PARQUET_EXPORT
62#define PARQUET_EXPORT __attribute__((visibility("default")))
63#endif
64#ifndef PARQUET_NO_EXPORT
65#define PARQUET_NO_EXPORT __attribute__((visibility("hidden")))
66#endif
67#endif // Non-Windows
68
69// This is a complicated topic, some reading on it:
70// http://www.codesynthesis.com/~boris/blog/2010/01/18/dll-export-cxx-templates/
71#if defined(_MSC_VER) || defined(__clang__)
72#define PARQUET_TEMPLATE_CLASS_EXPORT
73#define PARQUET_TEMPLATE_EXPORT PARQUET_EXPORT
74#else
75#define PARQUET_TEMPLATE_CLASS_EXPORT PARQUET_EXPORT
76#define PARQUET_TEMPLATE_EXPORT
77#endif
78
79#define PARQUET_DISALLOW_COPY_AND_ASSIGN ARROW_DISALLOW_COPY_AND_ASSIGN
80
81#define PARQUET_NORETURN ARROW_NORETURN
82#define PARQUET_DEPRECATED ARROW_DEPRECATED
83
84// If ARROW_VALGRIND set when compiling unit tests, also define
85// PARQUET_VALGRIND
86#ifdef ARROW_VALGRIND
87#define PARQUET_VALGRIND
88#endif
89
90namespace parquet {
91
92namespace BitUtil = ::arrow::BitUtil;
93
94using Buffer = ::arrow::Buffer;
95using Codec = ::arrow::util::Codec;
96using Compression = ::arrow::Compression;
97using MemoryPool = ::arrow::MemoryPool;
98using MutableBuffer = ::arrow::MutableBuffer;
99using ResizableBuffer = ::arrow::ResizableBuffer;
100using ResizableBuffer = ::arrow::ResizableBuffer;
101using ArrowInputFile = ::arrow::io::RandomAccessFile;
102using ArrowInputStream = ::arrow::io::InputStream;
103using ArrowOutputStream = ::arrow::io::OutputStream;
104using string_view = ::arrow::util::string_view;
105
106constexpr int64_t kDefaultOutputStreamSize = 1024;
107
108PARQUET_EXPORT
109std::shared_ptr<::arrow::io::BufferOutputStream> CreateOutputStream(
110 ::arrow::MemoryPool* pool = ::arrow::default_memory_pool());
111
112PARQUET_EXPORT
113std::shared_ptr<ResizableBuffer> AllocateBuffer(
114 ::arrow::MemoryPool* pool = ::arrow::default_memory_pool(), int64_t size = 0);
115
116} // namespace parquet
117