Skip to content

Commit cfbdb68

Browse files
wesmxhochy
authored andcommitted
ARROW-322: [C++] Remove ARROW_HDFS option, always build the module
Author: Wes McKinney <wes.mckinney@twosigma.com> Closes #253 from wesm/ARROW-322 and squashes the following commits: e793fd1 [Wes McKinney] Use string() instead of native() for file paths because windows uses utf16 native encoding d0cc376 [Wes McKinney] Add NOMINMAX windows workaround 5e53ddb [Wes McKinney] Visibility fix ea8fb9d [Wes McKinney] Various Win32 compilation fixes 82c4d2d [Wes McKinney] Remove ARROW_HDFS option, always build the module
1 parent ab5f66a commit cfbdb68

7 files changed

Lines changed: 47 additions & 67 deletions

File tree

ci/travis_before_script_cpp.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ CPP_DIR=$TRAVIS_BUILD_DIR/cpp
2626

2727
CMAKE_COMMON_FLAGS="\
2828
-DARROW_BUILD_BENCHMARKS=ON \
29-
-DARROW_PARQUET=OFF \
30-
-DARROW_HDFS=ON \
3129
-DCMAKE_INSTALL_PREFIX=$ARROW_CPP_INSTALL"
3230

3331
if [ $TRAVIS_OS_NAME == "linux" ]; then

cpp/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
7474
"Build the Arrow IPC extensions"
7575
ON)
7676

77-
option(ARROW_HDFS
78-
"Build the Arrow IO extensions for the Hadoop file system"
79-
OFF)
80-
8177
option(ARROW_BOOST_USE_SHARED
8278
"Rely on boost shared libraries where relevant"
8379
ON)

cpp/src/arrow/io/CMakeLists.txt

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,50 +45,30 @@ set(ARROW_IO_TEST_LINK_LIBS
4545

4646
set(ARROW_IO_SRCS
4747
file.cc
48+
hdfs.cc
49+
hdfs-internal.cc
4850
interfaces.cc
4951
memory.cc
5052
)
5153

52-
if(ARROW_HDFS)
53-
if(NOT THIRDPARTY_DIR)
54-
message(FATAL_ERROR "THIRDPARTY_DIR not set")
55-
endif()
56-
57-
if (DEFINED ENV{HADOOP_HOME})
58-
set(HADOOP_HOME $ENV{HADOOP_HOME})
59-
if (NOT EXISTS "${HADOOP_HOME}/include/hdfs.h")
60-
message(STATUS "Did not find hdfs.h in expected location, using vendored one")
61-
set(HADOOP_HOME "${THIRDPARTY_DIR}/hadoop")
62-
endif()
63-
else()
54+
# HDFS thirdparty setup
55+
if (DEFINED ENV{HADOOP_HOME})
56+
set(HADOOP_HOME $ENV{HADOOP_HOME})
57+
if (NOT EXISTS "${HADOOP_HOME}/include/hdfs.h")
58+
message(STATUS "Did not find hdfs.h in expected location, using vendored one")
6459
set(HADOOP_HOME "${THIRDPARTY_DIR}/hadoop")
6560
endif()
61+
else()
62+
set(HADOOP_HOME "${THIRDPARTY_DIR}/hadoop")
63+
endif()
6664

67-
set(HDFS_H_PATH "${HADOOP_HOME}/include/hdfs.h")
68-
if (NOT EXISTS ${HDFS_H_PATH})
69-
message(FATAL_ERROR "Did not find hdfs.h at ${HDFS_H_PATH}")
70-
endif()
71-
message(STATUS "Found hdfs.h at: " ${HDFS_H_PATH})
72-
message(STATUS "Building libhdfs shim component")
73-
74-
include_directories(SYSTEM "${HADOOP_HOME}/include")
75-
76-
set(ARROW_HDFS_SRCS
77-
hdfs.cc
78-
hdfs-internal.cc)
79-
80-
set_property(SOURCE ${ARROW_HDFS_SRCS}
81-
APPEND_STRING PROPERTY
82-
COMPILE_FLAGS "-DHAS_HADOOP")
83-
84-
set(ARROW_IO_SRCS
85-
${ARROW_HDFS_SRCS}
86-
${ARROW_IO_SRCS})
87-
88-
ADD_ARROW_TEST(io-hdfs-test)
89-
ARROW_TEST_LINK_LIBRARIES(io-hdfs-test
90-
${ARROW_IO_TEST_LINK_LIBS})
65+
set(HDFS_H_PATH "${HADOOP_HOME}/include/hdfs.h")
66+
if (NOT EXISTS ${HDFS_H_PATH})
67+
message(FATAL_ERROR "Did not find hdfs.h at ${HDFS_H_PATH}")
9168
endif()
69+
message(STATUS "Found hdfs.h at: " ${HDFS_H_PATH})
70+
71+
include_directories(SYSTEM "${HADOOP_HOME}/include")
9272

9373
add_library(arrow_io SHARED
9474
${ARROW_IO_SRCS}
@@ -119,6 +99,10 @@ ADD_ARROW_TEST(io-file-test)
11999
ARROW_TEST_LINK_LIBRARIES(io-file-test
120100
${ARROW_IO_TEST_LINK_LIBS})
121101

102+
ADD_ARROW_TEST(io-hdfs-test)
103+
ARROW_TEST_LINK_LIBRARIES(io-hdfs-test
104+
${ARROW_IO_TEST_LINK_LIBS})
105+
122106
ADD_ARROW_TEST(io-memory-test)
123107
ARROW_TEST_LINK_LIBRARIES(io-memory-test
124108
${ARROW_IO_TEST_LINK_LIBS})

cpp/src/arrow/io/hdfs-internal.cc

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,7 @@
2828
// This software may be modified and distributed under the terms
2929
// of the BSD license. See the LICENSE file for details.
3030

31-
#ifdef HAS_HADOOP
32-
33-
#ifndef _WIN32
34-
#include <dlfcn.h>
35-
#else
36-
#include <windows.h>
37-
#include <winsock2.h>
38-
39-
// TODO(wesm): address when/if we add windows support
40-
// #include <util/syserr_reporting.hpp>
41-
#endif
42-
43-
extern "C" {
44-
#include <hdfs.h>
45-
}
31+
#include "arrow/io/hdfs-internal.h"
4632

4733
#include <iostream>
4834
#include <mutex>
@@ -53,7 +39,6 @@ extern "C" {
5339

5440
#include <boost/filesystem.hpp> // NOLINT
5541

56-
#include "arrow/io/hdfs-internal.h"
5742
#include "arrow/status.h"
5843
#include "arrow/util/visibility.h"
5944

@@ -265,7 +250,8 @@ static inline void* GetLibrarySymbol(void* handle, const char* symbol) {
265250
return dlsym(handle, symbol);
266251
#else
267252

268-
void* ret = reinterpret_cast<void*>(GetProcAddress(handle, symbol));
253+
void* ret = reinterpret_cast<void*>(
254+
GetProcAddress(reinterpret_cast<HINSTANCE>(handle), symbol));
269255
if (ret == NULL) {
270256
// logstream(LOG_INFO) << "GetProcAddress error: "
271257
// << get_last_err_str(GetLastError()) << std::endl;
@@ -537,7 +523,7 @@ Status LibHdfsShim::GetRequiredSymbols() {
537523
return Status::OK();
538524
}
539525

540-
Status ARROW_EXPORT ConnectLibHdfs(LibHdfsShim** driver) {
526+
Status ConnectLibHdfs(LibHdfsShim** driver) {
541527
static std::mutex lock;
542528
std::lock_guard<std::mutex> guard(lock);
543529

@@ -562,7 +548,7 @@ Status ARROW_EXPORT ConnectLibHdfs(LibHdfsShim** driver) {
562548
return shim->GetRequiredSymbols();
563549
}
564550

565-
Status ARROW_EXPORT ConnectLibHdfs3(LibHdfsShim** driver) {
551+
Status ConnectLibHdfs3(LibHdfsShim** driver) {
566552
static std::mutex lock;
567553
std::lock_guard<std::mutex> guard(lock);
568554

@@ -586,5 +572,3 @@ Status ARROW_EXPORT ConnectLibHdfs3(LibHdfsShim** driver) {
586572

587573
} // namespace io
588574
} // namespace arrow
589-
590-
#endif // HAS_HADOOP

cpp/src/arrow/io/hdfs-internal.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,25 @@
1818
#ifndef ARROW_IO_HDFS_INTERNAL
1919
#define ARROW_IO_HDFS_INTERNAL
2020

21+
#ifndef _WIN32
22+
#include <dlfcn.h>
23+
#else
24+
25+
// Windows defines min and max macros that mess up std::min/maxa
26+
#ifndef NOMINMAX
27+
#define NOMINMAX
28+
#endif
29+
#include <winsock2.h>
30+
#include <windows.h>
31+
32+
// TODO(wesm): address when/if we add windows support
33+
// #include <util/syserr_reporting.hpp>
34+
#endif
35+
2136
#include <hdfs.h>
2237

38+
#include "arrow/util/visibility.h"
39+
2340
namespace arrow {
2441

2542
class Status;
@@ -194,8 +211,9 @@ struct LibHdfsShim {
194211
Status GetRequiredSymbols();
195212
};
196213

197-
Status ConnectLibHdfs(LibHdfsShim** driver);
198-
Status ConnectLibHdfs3(LibHdfsShim** driver);
214+
// TODO(wesm): Remove these exports when we are linking statically
215+
Status ARROW_EXPORT ConnectLibHdfs(LibHdfsShim** driver);
216+
Status ARROW_EXPORT ConnectLibHdfs3(LibHdfsShim** driver);
199217

200218
} // namespace io
201219
} // namespace arrow

cpp/src/arrow/io/io-hdfs-test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class TestHdfsClient : public ::testing::Test {
7979

8080
client_ = nullptr;
8181
scratch_dir_ =
82-
boost::filesystem::unique_path("/tmp/arrow-hdfs/scratch-%%%%").native();
82+
boost::filesystem::unique_path("/tmp/arrow-hdfs/scratch-%%%%").string();
8383

8484
loaded_driver_ = false;
8585

cpp/src/arrow/ipc/json-integration-test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Status RunCommand(const std::string& json_path, const std::string& arrow_path,
221221
}
222222

223223
static std::string temp_path() {
224-
return (fs::temp_directory_path() / fs::unique_path()).native();
224+
return (fs::temp_directory_path() / fs::unique_path()).string();
225225
}
226226

227227
class TestJSONIntegration : public ::testing::Test {

0 commit comments

Comments
 (0)