Skip to content

Commit 995abdc

Browse files
committed
ARROW-7531: [C++] Reduce header inclusion cost slightly
Remove inclusion of heavyweights "arrow/api.h" and "arrow/builder.h", among other changes. This seems to reduce CPU build time by about 3%. Closes apache#8511 from pitrou/ARROW-7531-header-reduction Authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
1 parent eccdd48 commit 995abdc

72 files changed

Lines changed: 138 additions & 133 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cpp/src/arrow/array/array_binary_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#include <gtest/gtest.h>
2626

2727
#include "arrow/array.h"
28+
#include "arrow/array/builder_binary.h"
2829
#include "arrow/buffer.h"
29-
#include "arrow/builder.h"
3030
#include "arrow/memory_pool.h"
3131
#include "arrow/status.h"
3232
#include "arrow/testing/gtest_common.h"

cpp/src/arrow/array/array_dict_test.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
#include <gtest/gtest.h>
2626

2727
#include "arrow/array.h"
28-
#include "arrow/builder.h"
28+
#include "arrow/array/builder_decimal.h"
29+
#include "arrow/array/builder_dict.h"
30+
#include "arrow/array/builder_nested.h"
2931
#include "arrow/memory_pool.h"
3032
#include "arrow/status.h"
3133
#include "arrow/testing/gtest_common.h"

cpp/src/arrow/array/array_list_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include <gtest/gtest.h>
2424

2525
#include "arrow/array.h"
26+
#include "arrow/array/builder_nested.h"
2627
#include "arrow/buffer.h"
27-
#include "arrow/builder.h"
2828
#include "arrow/status.h"
2929
#include "arrow/testing/gtest_common.h"
3030
#include "arrow/testing/gtest_util.h"

cpp/src/arrow/array/array_struct_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <vector>
2424

2525
#include "arrow/array.h"
26-
#include "arrow/builder.h"
26+
#include "arrow/array/builder_nested.h"
2727
#include "arrow/status.h"
2828
#include "arrow/testing/gtest_common.h"
2929
#include "arrow/testing/gtest_util.h"

cpp/src/arrow/array/array_test.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
// under the License.
1717

1818
#include <algorithm>
19-
#include <array>
2019
#include <cmath>
2120
#include <cstdint>
2221
#include <cstring>
23-
#include <iterator>
2422
#include <limits>
2523
#include <memory>
2624
#include <numeric>
@@ -43,9 +41,7 @@
4341
#include "arrow/array/util.h"
4442
#include "arrow/buffer.h"
4543
#include "arrow/buffer_builder.h"
46-
#include "arrow/builder.h"
4744
#include "arrow/compare.h"
48-
#include "arrow/memory_pool.h"
4945
#include "arrow/result.h"
5046
#include "arrow/scalar.h"
5147
#include "arrow/status.h"

cpp/src/arrow/array/array_union_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <gtest/gtest.h>
2121

2222
#include "arrow/array.h"
23+
#include "arrow/array/builder_nested.h"
24+
#include "arrow/array/builder_union.h"
2325
// TODO ipc shouldn't be included here
2426
#include "arrow/ipc/test_common.h"
2527
#include "arrow/testing/gtest_util.h"

cpp/src/arrow/array/builder_base.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "arrow/buffer.h"
3030
#include "arrow/buffer_builder.h"
3131
#include "arrow/status.h"
32-
#include "arrow/type.h"
32+
#include "arrow/type_fwd.h"
3333
#include "arrow/util/macros.h"
3434
#include "arrow/util/visibility.h"
3535

@@ -247,4 +247,24 @@ class ARROW_EXPORT ArrayBuilder {
247247
ARROW_DISALLOW_COPY_AND_ASSIGN(ArrayBuilder);
248248
};
249249

250+
/// \brief Construct an empty ArrayBuilder corresponding to the data
251+
/// type
252+
/// \param[in] pool the MemoryPool to use for allocations
253+
/// \param[in] type the data type to create the builder for
254+
/// \param[out] out the created ArrayBuilder
255+
ARROW_EXPORT
256+
Status MakeBuilder(MemoryPool* pool, const std::shared_ptr<DataType>& type,
257+
std::unique_ptr<ArrayBuilder>* out);
258+
259+
/// \brief Construct an empty DictionaryBuilder initialized optionally
260+
/// with a pre-existing dictionary
261+
/// \param[in] pool the MemoryPool to use for allocations
262+
/// \param[in] type the dictionary type to create the builder for
263+
/// \param[in] dictionary the initial dictionary, if any. May be nullptr
264+
/// \param[out] out the created ArrayBuilder
265+
ARROW_EXPORT
266+
Status MakeDictionaryBuilder(MemoryPool* pool, const std::shared_ptr<DataType>& type,
267+
const std::shared_ptr<Array>& dictionary,
268+
std::unique_ptr<ArrayBuilder>* out);
269+
250270
} // namespace arrow

cpp/src/arrow/array/concatenate_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
#include <gtest/gtest.h>
3232

3333
#include "arrow/array.h"
34+
#include "arrow/array/builder_binary.h"
3435
#include "arrow/array/concatenate.h"
3536
#include "arrow/buffer.h"
36-
#include "arrow/builder.h"
3737
#include "arrow/status.h"
3838
#include "arrow/testing/gtest_common.h"
3939
#include "arrow/testing/random.h"

cpp/src/arrow/array/diff_test.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
// under the License.
1717

1818
#include <algorithm>
19-
#include <array>
2019
#include <cstdint>
2120
#include <cstring>
22-
#include <iterator>
2321
#include <limits>
2422
#include <memory>
2523
#include <numeric>
@@ -31,8 +29,6 @@
3129

3230
#include "arrow/array.h"
3331
#include "arrow/array/diff.h"
34-
#include "arrow/buffer.h"
35-
#include "arrow/builder.h"
3632
#include "arrow/compute/api.h"
3733
#include "arrow/status.h"
3834
#include "arrow/testing/gtest_common.h"

cpp/src/arrow/builder.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,3 @@
3030
#include "arrow/array/builder_union.h" // IWYU pragma: keep
3131
#include "arrow/status.h"
3232
#include "arrow/util/visibility.h"
33-
34-
namespace arrow {
35-
36-
class DataType;
37-
class MemoryPool;
38-
39-
/// \brief Construct an empty ArrayBuilder corresponding to the data
40-
/// type
41-
/// \param[in] pool the MemoryPool to use for allocations
42-
/// \param[in] type the data type to create the builder for
43-
/// \param[out] out the created ArrayBuilder
44-
ARROW_EXPORT
45-
Status MakeBuilder(MemoryPool* pool, const std::shared_ptr<DataType>& type,
46-
std::unique_ptr<ArrayBuilder>* out);
47-
48-
/// \brief Construct an empty DictionaryBuilder initialized optionally
49-
/// with a pre-existing dictionary
50-
/// \param[in] pool the MemoryPool to use for allocations
51-
/// \param[in] type the dictionary type to create the builder for
52-
/// \param[in] dictionary the initial dictionary, if any. May be nullptr
53-
/// \param[out] out the created ArrayBuilder
54-
ARROW_EXPORT
55-
Status MakeDictionaryBuilder(MemoryPool* pool, const std::shared_ptr<DataType>& type,
56-
const std::shared_ptr<Array>& dictionary,
57-
std::unique_ptr<ArrayBuilder>* out);
58-
59-
} // namespace arrow

0 commit comments

Comments
 (0)