Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -725,12 +725,14 @@ endif()
set(ARROW_SHARED_PRIVATE_LINK_LIBS
${ARROW_STATIC_LINK_LIBS}
${BOOST_SYSTEM_LIBRARY}
${BOOST_THREAD_LIBRARY}
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_REGEX_LIBRARY})

set(ARROW_STATIC_LINK_LIBS
${ARROW_STATIC_LINK_LIBS}
${BOOST_SYSTEM_LIBRARY}
${BOOST_THREAD_LIBRARY}
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_REGEX_LIBRARY})

Expand All @@ -740,6 +742,11 @@ if (NOT MSVC)
${CMAKE_DL_LIBS})
endif()

if (UNIX AND NOT APPLE)
set(ARROW_LINK_LIBS ${ARROW_LINK_LIBS} -lrt)
set(ARROW_STATIC_LINK_LIBS ${ARROW_STATIC_LINK_LIBS} -lrt)
endif()

set(ARROW_TEST_STATIC_LINK_LIBS
arrow_testing_static
arrow_static
Expand All @@ -753,6 +760,7 @@ set(ARROW_TEST_SHARED_LINK_LIBS
${ARROW_LINK_LIBS}
double-conversion_static
${BOOST_SYSTEM_LIBRARY}
${BOOST_THREAD_LIBRARY}
${BOOST_FILESYSTEM_LIBRARY}
${BOOST_REGEX_LIBRARY}
gtest_main_static
Expand Down
22 changes: 18 additions & 4 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,14 @@ if (ARROW_BOOST_VENDORED)
set(BOOST_BUILD_LINK "static")
set(BOOST_STATIC_SYSTEM_LIBRARY
"${BOOST_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}boost_system${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(BOOST_STATIC_THREAD_LIBRARY
"${BOOST_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}boost_thread${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(BOOST_STATIC_FILESYSTEM_LIBRARY
"${BOOST_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}boost_filesystem${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(BOOST_STATIC_REGEX_LIBRARY
"${BOOST_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}boost_regex${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(BOOST_SYSTEM_LIBRARY boost_system_static)
set(BOOST_THREAD_LIBRARY boost_thread_static)
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem_static)
set(BOOST_REGEX_LIBRARY boost_regex_static)

Expand All @@ -377,12 +380,13 @@ if (ARROW_BOOST_VENDORED)
else()
set(BOOST_BUILD_PRODUCTS
${BOOST_STATIC_SYSTEM_LIBRARY}
${BOOST_STATIC_THREAD_LIBRARY}
${BOOST_STATIC_FILESYSTEM_LIBRARY}
${BOOST_STATIC_REGEX_LIBRARY})
set(BOOST_CONFIGURE_COMMAND
"./bootstrap.sh"
"--prefix=${BOOST_PREFIX}"
"--with-libraries=filesystem,regex,system")
"--with-libraries=filesystem,regex,system,thread")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
set(BOOST_BUILD_VARIANT "debug")
else()
Expand Down Expand Up @@ -429,17 +433,20 @@ else()
if (ARROW_BOOST_HEADER_ONLY)
find_package(Boost REQUIRED)
else()
find_package(Boost COMPONENTS regex system filesystem REQUIRED)
find_package(Boost COMPONENTS regex system thread filesystem REQUIRED)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
set(BOOST_SHARED_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY_DEBUG})
set(BOOST_SHARED_THREAD_LIBRARY ${Boost_THREAD_LIBRARY_DEBUG})
set(BOOST_SHARED_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY_DEBUG})
set(BOOST_SHARED_REGEX_LIBRARY ${Boost_REGEX_LIBRARY_DEBUG})
else()
set(BOOST_SHARED_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY_RELEASE})
set(BOOST_SHARED_THREAD_LIBRARY ${Boost_THREAD_LIBRARY_RELEASE})
set(BOOST_SHARED_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY_RELEASE})
set(BOOST_SHARED_REGEX_LIBRARY ${Boost_REGEX_LIBRARY_RELEASE})
endif()
set(BOOST_SYSTEM_LIBRARY boost_system_shared)
set(BOOST_THREAD_LIBRARY boost_thread_shared)
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem_shared)
set(BOOST_REGEX_LIBRARY boost_regex_shared)
endif()
Expand All @@ -450,17 +457,20 @@ else()
if (ARROW_BOOST_HEADER_ONLY)
find_package(Boost REQUIRED)
else()
find_package(Boost COMPONENTS regex system filesystem REQUIRED)
find_package(Boost COMPONENTS regex system thread atomic chrono date_time filesystem REQUIRED)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
set(BOOST_STATIC_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY_DEBUG})
set(BOOST_STATIC_THREAD_LIBRARY ${Boost_THREAD_LIBRARY_DEBUG})
set(BOOST_STATIC_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY_DEBUG})
set(BOOST_STATIC_REGEX_LIBRARY ${Boost_REGEX_LIBRARY_DEBUG})
else()
set(BOOST_STATIC_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY_RELEASE})
set(BOOST_STATIC_THREAD_LIBRARY ${Boost_THREAD_LIBRARY_RELEASE})
set(BOOST_STATIC_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY_RELEASE})
set(BOOST_STATIC_REGEX_LIBRARY ${Boost_REGEX_LIBRARY_RELEASE})
endif()
set(BOOST_SYSTEM_LIBRARY boost_system_static)
set(BOOST_THREAD_LIBRARY boost_thread_static)
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem_static)
set(BOOST_REGEX_LIBRARY boost_regex_static)
endif()
Expand All @@ -475,6 +485,10 @@ if (NOT ARROW_BOOST_HEADER_ONLY)
STATIC_LIB "${BOOST_STATIC_SYSTEM_LIBRARY}"
SHARED_LIB "${BOOST_SHARED_SYSTEM_LIBRARY}")

ADD_THIRDPARTY_LIB(boost_thread
STATIC_LIB "${BOOST_STATIC_THREAD_LIBRARY}"
SHARED_LIB "${BOOST_SHARED_THREAD_LIBRARY}")

ADD_THIRDPARTY_LIB(boost_filesystem
STATIC_LIB "${BOOST_STATIC_FILESYSTEM_LIBRARY}"
SHARED_LIB "${BOOST_SHARED_FILESYSTEM_LIBRARY}")
Expand All @@ -483,7 +497,7 @@ if (NOT ARROW_BOOST_HEADER_ONLY)
STATIC_LIB "${BOOST_STATIC_REGEX_LIBRARY}"
SHARED_LIB "${BOOST_SHARED_REGEX_LIBRARY}")

SET(ARROW_BOOST_LIBS ${BOOST_SYSTEM_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY})
SET(ARROW_BOOST_LIBS ${BOOST_SYSTEM_LIBRARY} ${BOOST_THREAD_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY})
endif()

include_directories(SYSTEM ${Boost_INCLUDE_DIR})
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/flight/flight-benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Status RunPerformanceTest(const int port) {

std::shared_ptr<ThreadPool> pool;
RETURN_NOT_OK(ThreadPool::Make(FLAGS_num_threads, &pool));
std::vector<std::future<Status>> tasks;
std::vector<Future<Status>> tasks;
for (const auto& endpoint : plan->endpoints()) {
tasks.emplace_back(pool->Submit(ConsumeStream, endpoint));
}
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/arrow/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ endif()
set(ARROW_PYTHON_SHARED_LINK_LIBS
arrow_shared
${PYTHON_OTHER_LIBS}
${BOOST_THREAD_LIBRARY}
${Boost_SYSTEM_LIBRARY}
)

if (WIN32)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/util/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void parallel_memcopy(uint8_t* dst, const uint8_t* src, int64_t nbytes,
// Each thread gets a "chunk" of k blocks.

// Start all parallel memcpy tasks and handle leftovers while threads run.
std::vector<std::future<void*>> futures;
std::vector<Future<void*>> futures;

for (int i = 0; i < num_threads; i++) {
futures.emplace_back(pool->Submit(wrap_memcpy, dst + prefix + i * chunk_size,
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/util/parallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ namespace internal {
template <class FUNCTION>
Status ParallelFor(int num_tasks, FUNCTION&& func) {
auto pool = internal::GetCpuThreadPool();
std::vector<std::future<Status>> futures(num_tasks);

std::vector<Future<Status>> futures(num_tasks);
for (int i = 0; i < num_tasks; ++i) {
futures[i] = pool->Submit(func, i);
}
Expand Down
19 changes: 12 additions & 7 deletions cpp/src/arrow/util/thread-pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@
#include <type_traits>
#include <utility>

#define BOOST_THREAD_PROVIDES_FUTURE
#include <boost/thread.hpp>
#include <boost/thread/future.hpp>

#include "arrow/status.h"
#include "arrow/util/macros.h"
#include "arrow/util/visibility.h"

namespace arrow {

template<class R>
using Future = boost::future<R>;

/// \brief Get the capacity of the global thread pool
///
/// Return the number of worker threads in the thread pool to which
Expand All @@ -64,12 +71,10 @@ namespace detail {
// to std::function.
template <typename R, typename... Args>
struct packaged_task_wrapper {
using PackagedTask = std::packaged_task<R(Args...)>;

explicit packaged_task_wrapper(PackagedTask&& task)
using PackagedTask = boost::packaged_task<R>;
explicit packaged_task_wrapper(PackagedTask&& task)
: task_(std::make_shared<PackagedTask>(std::forward<PackagedTask>(task))) {}

void operator()(Args&&... args) { return (*task_)(std::forward<Args>(args)...); }
void operator()(Args&&... args) { return (*task_)(std::forward<Args>(args)...); }
std::shared_ptr<PackagedTask> task_;
};

Expand Down Expand Up @@ -118,10 +123,10 @@ class ARROW_EXPORT ThreadPool {
// only occurs if the ThreadPool is shutting down).
template <typename Function, typename... Args,
typename Result = typename std::result_of<Function && (Args && ...)>::type>
std::future<Result> Submit(Function&& func, Args&&... args) {
Future<Result> Submit(Function&& func, Args&&... args) {
// Trying to templatize std::packaged_task with Function doesn't seem
// to work, so go through std::bind to simplify the packaged signature
using PackagedTask = std::packaged_task<Result()>;
using PackagedTask = boost::packaged_task<Result>;
auto task = PackagedTask(std::bind(std::forward<Function>(func), args...));
auto fut = task.get_future();

Expand Down
7 changes: 5 additions & 2 deletions cpp/src/arrow/util/utf8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

#include <mutex>

#include <boost/thread.hpp>
#include <boost/thread/future.hpp>

#include "arrow/util/logging.h"
#include "arrow/util/utf8.h"

Expand Down Expand Up @@ -73,10 +76,10 @@ ARROW_EXPORT void CheckUTF8Initialized() {

} // namespace internal

static std::once_flag utf8_initialized;
static boost::once_flag utf8_initialized = BOOST_ONCE_INIT;

void InitializeUTF8() {
std::call_once(utf8_initialized, internal::InitializeLargeTable);
boost::call_once(internal::InitializeLargeTable, utf8_initialized);
}

} // namespace util
Expand Down
5 changes: 3 additions & 2 deletions cpp/src/parquet/arrow/reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ using arrow::BooleanArray;
using arrow::ChunkedArray;
using arrow::Column;
using arrow::Field;
using arrow::Future;
using arrow::Int32Array;
using arrow::ListArray;
using arrow::MemoryPool;
Expand Down Expand Up @@ -501,7 +502,7 @@ Status FileReader::Impl::ReadRowGroup(int row_group_index,
};

if (use_threads_) {
std::vector<std::future<Status>> futures;
std::vector<Future<Status>> futures;
auto pool = ::arrow::internal::GetCpuThreadPool();
for (int i = 0; i < num_columns; i++) {
futures.push_back(pool->Submit(ReadColumnFunc, i));
Expand Down Expand Up @@ -548,7 +549,7 @@ Status FileReader::Impl::ReadTable(const std::vector<int>& indices,
};

if (use_threads_) {
std::vector<std::future<Status>> futures;
std::vector<Future<Status>> futures;
auto pool = ::arrow::internal::GetCpuThreadPool();
for (int i = 0; i < num_fields; i++) {
futures.push_back(pool->Submit(ReadColumnFunc, i));
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/plasma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ set(PLASMA_SRCS
protocol.cc
thirdparty/ae/ae.c)

set(PLASMA_LINK_LIBS arrow_shared)
set(PLASMA_STATIC_LINK_LIBS arrow_static)
set(PLASMA_LINK_LIBS ${ARROW_LINK_LIBS} ${BOOST_THREAD_LIBRARY} arrow_shared)
set(PLASMA_STATIC_LINK_LIBS ${ARROW_STATIC_LINK_LIBS} ${BOOST_THREAD_LIBRARY} arrow_static)

if (ARROW_CUDA)
set(PLASMA_LINK_LIBS ${PLASMA_LINK_LIBS} arrow_cuda_shared)
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/plasma/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ bool PlasmaClient::Impl::ComputeObjectHashParallel(XXH64_state_t* hash_state,
// | num_threads * chunk_size | suffix |, where chunk_size = k * block_size.
// Each thread gets a "chunk" of k blocks, except the suffix thread.

std::vector<std::future<void>> futures;
std::vector<arrow::Future<void>> futures;
for (int i = 0; i < num_threads; i++) {
futures.push_back(pool->Submit(
ComputeBlockHash, reinterpret_cast<uint8_t*>(data_address) + i * chunk_size,
Expand Down
9 changes: 8 additions & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,12 @@ find_package(PythonLibsNew REQUIRED)
find_package(NumPy REQUIRED)
include(UseCython)

find_package(Boost COMPONENTS system thread atomic chrono date_time filesystem regex REQUIRED)

include_directories(SYSTEM
${NUMPY_INCLUDE_DIRS}
${PYTHON_INCLUDE_DIRS}
${Boost_INCLUDE_DIR}
src)

############################################################
Expand Down Expand Up @@ -332,10 +335,14 @@ if (PYARROW_BUNDLE_ARROW_CPP)
# disable autolinking in boost
add_definitions(-DBOOST_ALL_NO_LIB)
endif()
find_package(Boost COMPONENTS system filesystem regex REQUIRED)
find_package(Boost COMPONENTS system thread atomic chrono date_time filesystem regex REQUIRED)
bundle_boost_lib(Boost_REGEX_LIBRARY)
bundle_boost_lib(Boost_FILESYSTEM_LIBRARY)
bundle_boost_lib(Boost_SYSTEM_LIBRARY)
bundle_boost_lib(Boost_THREAD_LIBRARY)
bundle_boost_lib(Boost_ATOMIC_LIBRARY)
bundle_boost_lib(Boost_CHRONO_LIBRARY)
bundle_boost_lib(Boost_DATE_TIME_LIBRARY)
endif()

bundle_zlib()
Expand Down
4 changes: 2 additions & 2 deletions python/manylinux1/scripts/build_boost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ mkdir /arrow_boost
pushd /boost_${BOOST_VERSION_UNDERSCORE}
./bootstrap.sh
./b2 tools/bcp
./dist/bin/bcp --namespace=arrow_boost --namespace-alias filesystem date_time system regex build algorithm locale format variant /arrow_boost
./dist/bin/bcp --namespace=arrow_boost --namespace-alias filesystem date_time system thread atomic chrono regex build algorithm locale format variant /arrow_boost
popd

pushd /arrow_boost
ls -l
./bootstrap.sh
./bjam dll-path="'\$ORIGIN/'" cxxflags='-std=c++11 -fPIC' cflags=-fPIC linkflags="-std=c++11" variant=release link=shared --prefix=/arrow_boost_dist --with-filesystem --with-date_time --with-system --with-regex install
./bjam dll-path="'\$ORIGIN/'" cxxflags='-std=c++11 -fPIC' cflags=-fPIC linkflags="-std=c++11" variant=release link=shared --prefix=/arrow_boost_dist --with-filesystem --with-date_time --with-system --with-thread --with-atomic --with-chrono --with-regex install
popd
rm -rf boost_${BOOST_VERSION_UNDERSCORE}.tar.gz boost_${BOOST_VERSION_UNDERSCORE} arrow_boost
# Boost always install header-only parts but they also take up quite some space.
Expand Down
7 changes: 0 additions & 7 deletions python/pyarrow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ def parse_git(root, **kwargs):

import pyarrow.compat as compat

# Workaround for https://issues.apache.org/jira/browse/ARROW-2657
# and https://issues.apache.org/jira/browse/ARROW-2920
if _sys.platform in ('linux', 'linux2'):
compat.import_tensorflow_extension()
compat.import_pytorch_extension()


from pyarrow.lib import cpu_count, set_cpu_count
from pyarrow.lib import (null, bool_,
int8, int16, int32, int64,
Expand Down
Loading