Skip to content

Commit 6fa6319

Browse files
committed
ARROW-28: Draft C++ shared memory IPC workflow and related refactoring /
scaffolding / cleaning.
1 parent 093f9bd commit 6fa6319

87 files changed

Lines changed: 3087 additions & 805 deletions

Some content is hidden

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

ci/travis_before_script_cpp.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ echo $GTEST_HOME
1919

2020
: ${ARROW_CPP_INSTALL=$TRAVIS_BUILD_DIR/cpp-install}
2121

22-
cmake -DARROW_BUILD_BENCHMARKS=ON -DCMAKE_INSTALL_PREFIX=$ARROW_CPP_INSTALL -DCMAKE_CXX_FLAGS="-Werror" $CPP_DIR
22+
CMAKE_COMMON_FLAGS="-DARROW_BUILD_BENCHMARKS=ON -DCMAKE_INSTALL_PREFIX=$ARROW_CPP_INSTALL"
23+
24+
if [ $TRAVIS_OS_NAME == "linux" ]; then
25+
cmake -DARROW_TEST_MEMCHECK=on $CMAKE_COMMON_FLAGS -DCMAKE_CXX_FLAGS="-Werror" $CPP_DIR
26+
else
27+
cmake $CMAKE_COMMON_FLAGS -DCMAKE_CXX_FLAGS="-Werror" $CPP_DIR
28+
fi
29+
2330
make -j4
2431
make install
2532

ci/travis_script_cpp.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ pushd $CPP_BUILD_DIR
88

99
make lint
1010

11-
if [ $TRAVIS_OS_NAME == "linux" ]; then
12-
valgrind --tool=memcheck --leak-check=yes --error-exitcode=1 ctest -L unittest
13-
else
14-
ctest -L unittest
15-
fi
11+
ctest -L unittest
1612

1713
popd

cpp/CMakeLists.txt

Lines changed: 65 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
5151
option(ARROW_PARQUET
5252
"Build the Parquet adapter and link to libparquet"
5353
OFF)
54-
54+
option(ARROW_TEST_MEMCHECK
55+
"Run the test suite using valgrind --tool=memcheck"
56+
OFF)
5557
option(ARROW_BUILD_TESTS
5658
"Build the Arrow googletest unit tests"
5759
ON)
@@ -60,6 +62,10 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
6062
"Build the Arrow micro benchmarks"
6163
OFF)
6264

65+
option(ARROW_IPC
66+
"Build the Arrow IPC extensions"
67+
ON)
68+
6369
endif()
6470

6571
if(NOT ARROW_BUILD_TESTS)
@@ -260,17 +266,17 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_OUTPUT_ROOT_DIRECTORY}")
260266
include_directories(src)
261267

262268
############################################################
263-
# Benchmarking
269+
# Benchmarking
264270
############################################################
265271
# Add a new micro benchmark, with or without an executable that should be built.
266272
# If benchmarks are enabled then they will be run along side unit tests with ctest.
267-
# 'make runbenchmark' and 'make unittest' to build/run only benchmark or unittests,
273+
# 'make runbenchmark' and 'make unittest' to build/run only benchmark or unittests,
268274
# respectively.
269275
#
270276
# REL_BENCHMARK_NAME is the name of the benchmark app. It may be a single component
271277
# (e.g. monotime-benchmark) or contain additional components (e.g.
272278
# net/net_util-benchmark). Either way, the last component must be a globally
273-
# unique name.
279+
# unique name.
274280

275281
# The benchmark will registered as unit test with ctest with a label
276282
# of 'benchmark'.
@@ -281,7 +287,7 @@ function(ADD_ARROW_BENCHMARK REL_BENCHMARK_NAME)
281287
return()
282288
endif()
283289
get_filename_component(BENCHMARK_NAME ${REL_BENCHMARK_NAME} NAME_WE)
284-
290+
285291
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${REL_BENCHMARK_NAME}.cc)
286292
# This benchmark has a corresponding .cc file, set it up as an executable.
287293
set(BENCHMARK_PATH "${EXECUTABLE_OUTPUT_PATH}/${BENCHMARK_NAME}")
@@ -294,7 +300,7 @@ function(ADD_ARROW_BENCHMARK REL_BENCHMARK_NAME)
294300
set(BENCHMARK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${REL_BENCHMARK_NAME})
295301
set(NO_COLOR "")
296302
endif()
297-
303+
298304
add_test(${BENCHMARK_NAME}
299305
${BUILD_SUPPORT_DIR}/run-test.sh ${CMAKE_BINARY_DIR} benchmark ${BENCHMARK_PATH} ${NO_COLOR})
300306
set_tests_properties(${BENCHMARK_NAME} PROPERTIES LABELS "benchmark")
@@ -345,9 +351,18 @@ function(ADD_ARROW_TEST REL_TEST_NAME)
345351
set(TEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${REL_TEST_NAME})
346352
endif()
347353

348-
add_test(${TEST_NAME}
349-
${BUILD_SUPPORT_DIR}/run-test.sh ${CMAKE_BINARY_DIR} test ${TEST_PATH})
354+
if (ARROW_TEST_MEMCHECK)
355+
SET_PROPERTY(TARGET ${TEST_NAME}
356+
APPEND_STRING PROPERTY
357+
COMPILE_FLAGS " -DARROW_VALGRIND")
358+
add_test(${TEST_NAME}
359+
valgrind --tool=memcheck --leak-check=full --error-exitcode=1 ${TEST_PATH})
360+
else()
361+
add_test(${TEST_NAME}
362+
${BUILD_SUPPORT_DIR}/run-test.sh ${CMAKE_BINARY_DIR} test ${TEST_PATH})
363+
endif()
350364
set_tests_properties(${TEST_NAME} PROPERTIES LABELS "unittest")
365+
351366
if(ARGN)
352367
set_tests_properties(${TEST_NAME} PROPERTIES ${ARGN})
353368
endif()
@@ -403,7 +418,7 @@ if ("$ENV{GTEST_HOME}" STREQUAL "")
403418
set(GTest_HOME ${THIRDPARTY_DIR}/googletest-release-1.7.0)
404419
endif()
405420

406-
## Google Benchmark
421+
## Google Benchmark
407422
if ("$ENV{GBENCHMARK_HOME}" STREQUAL "")
408423
set(GBENCHMARK_HOME ${THIRDPARTY_DIR}/installed)
409424
endif()
@@ -487,24 +502,10 @@ if (UNIX)
487502
add_custom_target(lint ${BUILD_SUPPORT_DIR}/cpplint.py
488503
--verbose=2
489504
--linelength=90
490-
--filter=-whitespace/comments,-readability/todo,-build/header_guard,-build/c++11
491-
`find ${CMAKE_CURRENT_SOURCE_DIR}/src -name \\*.cc -or -name \\*.h`)
505+
--filter=-whitespace/comments,-readability/todo,-build/header_guard,-build/c++11,-runtime/references
506+
`find ${CMAKE_CURRENT_SOURCE_DIR}/src -name \\*.cc -or -name \\*.h | sed -e '/_generated/g'`)
492507
endif (UNIX)
493508
494-
#----------------------------------------------------------------------
495-
# Parquet adapter
496-
497-
if(ARROW_PARQUET)
498-
find_package(Parquet REQUIRED)
499-
include_directories(SYSTEM ${PARQUET_INCLUDE_DIR})
500-
ADD_THIRDPARTY_LIB(parquet
501-
STATIC_LIB ${PARQUET_STATIC_LIB}
502-
SHARED_LIB ${PARQUET_SHARED_LIB})
503-
504-
add_subdirectory(src/arrow/parquet)
505-
list(APPEND LINK_LIBS arrow_parquet parquet)
506-
endif()
507-
508509
############################################################
509510
# Subdirectories
510511
############################################################
@@ -515,15 +516,18 @@ set(LIBARROW_LINK_LIBS
515516
set(ARROW_SRCS
516517
src/arrow/array.cc
517518
src/arrow/builder.cc
519+
src/arrow/column.cc
520+
src/arrow/schema.cc
521+
src/arrow/table.cc
518522
src/arrow/type.cc
519523
520-
src/arrow/table/column.cc
521-
src/arrow/table/schema.cc
522-
src/arrow/table/table.cc
524+
# IPC / Shared memory library; to be turned into an optional component
525+
src/arrow/ipc/adapter.cc
526+
src/arrow/ipc/memory.cc
527+
src/arrow/ipc/metadata.cc
528+
src/arrow/ipc/metadata-internal.cc
523529
524530
src/arrow/types/construct.cc
525-
src/arrow/types/floating.cc
526-
src/arrow/types/integer.cc
527531
src/arrow/types/json.cc
528532
src/arrow/types/list.cc
529533
src/arrow/types/primitive.cc
@@ -559,9 +563,39 @@ target_link_libraries(arrow ${LIBARROW_LINK_LIBS})
559563
560564
add_subdirectory(src/arrow)
561565
add_subdirectory(src/arrow/util)
562-
add_subdirectory(src/arrow/table)
563566
add_subdirectory(src/arrow/types)
564567
565568
install(TARGETS arrow
566569
LIBRARY DESTINATION lib
567570
ARCHIVE DESTINATION lib)
571+
572+
#----------------------------------------------------------------------
573+
# Parquet adapter library
574+
575+
if(ARROW_PARQUET)
576+
find_package(Parquet REQUIRED)
577+
include_directories(SYSTEM ${PARQUET_INCLUDE_DIR})
578+
ADD_THIRDPARTY_LIB(parquet
579+
STATIC_LIB ${PARQUET_STATIC_LIB}
580+
SHARED_LIB ${PARQUET_SHARED_LIB})
581+
582+
add_subdirectory(src/arrow/parquet)
583+
list(APPEND LINK_LIBS arrow_parquet parquet)
584+
endif()
585+
586+
#----------------------------------------------------------------------
587+
# IPC library
588+
589+
## Flatbuffers
590+
if(ARROW_IPC)
591+
find_package(Flatbuffers REQUIRED)
592+
message(STATUS "Flatbuffers include dir: ${FLATBUFFERS_INCLUDE_DIR}")
593+
message(STATUS "Flatbuffers static library: ${FLATBUFFERS_STATIC_LIB}")
594+
message(STATUS "Flatbuffers compiler: ${FLATBUFFERS_COMPILER}")
595+
include_directories(SYSTEM ${FLATBUFFERS_INCLUDE_DIR})
596+
add_library(flatbuffers STATIC IMPORTED)
597+
set_target_properties(flatbuffers PROPERTIES
598+
IMPORTED_LOCATION ${FLATBUFFERS_STATIC_LIB})
599+
600+
add_subdirectory(src/arrow/ipc)
601+
endif()
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
#
14+
# Tries to find Flatbuffers headers and libraries.
15+
#
16+
# Usage of this module as follows:
17+
#
18+
# find_package(Flatbuffers)
19+
#
20+
# Variables used by this module, they can change the default behaviour and need
21+
# to be set before calling find_package:
22+
#
23+
# Flatbuffers_HOME -
24+
# When set, this path is inspected instead of standard library locations as
25+
# the root of the Flatbuffers installation. The environment variable
26+
# FLATBUFFERS_HOME overrides this veriable.
27+
#
28+
# This module defines
29+
# FLATBUFFERS_INCLUDE_DIR, directory containing headers
30+
# FLATBUFFERS_LIBS, directory containing flatbuffers libraries
31+
# FLATBUFFERS_STATIC_LIB, path to libflatbuffers.a
32+
# FLATBUFFERS_FOUND, whether flatbuffers has been found
33+
34+
if( NOT "$ENV{FLATBUFFERS_HOME}" STREQUAL "")
35+
file( TO_CMAKE_PATH "$ENV{FLATBUFFERS_HOME}" _native_path )
36+
list( APPEND _flatbuffers_roots ${_native_path} )
37+
elseif ( Flatbuffers_HOME )
38+
list( APPEND _flatbuffers_roots ${Flatbuffers_HOME} )
39+
endif()
40+
41+
# Try the parameterized roots, if they exist
42+
if ( _flatbuffers_roots )
43+
find_path( FLATBUFFERS_INCLUDE_DIR NAMES flatbuffers/flatbuffers.h
44+
PATHS ${_flatbuffers_roots} NO_DEFAULT_PATH
45+
PATH_SUFFIXES "include" )
46+
find_library( FLATBUFFERS_LIBRARIES NAMES flatbuffers
47+
PATHS ${_flatbuffers_roots} NO_DEFAULT_PATH
48+
PATH_SUFFIXES "lib" )
49+
else ()
50+
find_path( FLATBUFFERS_INCLUDE_DIR NAMES flatbuffers/flatbuffers.h )
51+
find_library( FLATBUFFERS_LIBRARIES NAMES flatbuffers )
52+
endif ()
53+
54+
find_program(FLATBUFFERS_COMPILER flatc
55+
$ENV{FLATBUFFERS_HOME}/bin
56+
/usr/local/bin
57+
/usr/bin
58+
NO_DEFAULT_PATH
59+
)
60+
61+
if (FLATBUFFERS_INCLUDE_DIR AND FLATBUFFERS_LIBRARIES)
62+
set(FLATBUFFERS_FOUND TRUE)
63+
get_filename_component( FLATBUFFERS_LIBS ${FLATBUFFERS_LIBRARIES} PATH )
64+
set(FLATBUFFERS_LIB_NAME libflatbuffers)
65+
set(FLATBUFFERS_STATIC_LIB ${FLATBUFFERS_LIBS}/${FLATBUFFERS_LIB_NAME}.a)
66+
else ()
67+
set(FLATBUFFERS_FOUND FALSE)
68+
endif ()
69+
70+
if (FLATBUFFERS_FOUND)
71+
if (NOT Flatbuffers_FIND_QUIETLY)
72+
message(STATUS "Found the Flatbuffers library: ${FLATBUFFERS_LIBRARIES}")
73+
endif ()
74+
else ()
75+
if (NOT Flatbuffers_FIND_QUIETLY)
76+
set(FLATBUFFERS_ERR_MSG "Could not find the Flatbuffers library. Looked in ")
77+
if ( _flatbuffers_roots )
78+
set(FLATBUFFERS_ERR_MSG "${FLATBUFFERS_ERR_MSG} in ${_flatbuffers_roots}.")
79+
else ()
80+
set(FLATBUFFERS_ERR_MSG "${FLATBUFFERS_ERR_MSG} system search paths.")
81+
endif ()
82+
if (Flatbuffers_FIND_REQUIRED)
83+
message(FATAL_ERROR "${FLATBUFFERS_ERR_MSG}")
84+
else (Flatbuffers_FIND_REQUIRED)
85+
message(STATUS "${FLATBUFFERS_ERR_MSG}")
86+
endif (Flatbuffers_FIND_REQUIRED)
87+
endif ()
88+
endif ()
89+
90+
mark_as_advanced(
91+
FLATBUFFERS_INCLUDE_DIR
92+
FLATBUFFERS_LIBS
93+
FLATBUFFERS_STATIC_LIB
94+
FLATBUFFERS_COMPILER
95+
)

cpp/setup_build_env.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
SOURCE_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)
44

5-
./thirdparty/download_thirdparty.sh || { echo "download_thirdparty.sh failed" ; return; }
6-
./thirdparty/build_thirdparty.sh || { echo "build_thirdparty.sh failed" ; return; }
5+
./thirdparty/download_thirdparty.sh || { echo "download_thirdparty.sh failed" ; return; }
6+
./thirdparty/build_thirdparty.sh || { echo "build_thirdparty.sh failed" ; return; }
77
source thirdparty/versions.sh
88

99
export GTEST_HOME=$SOURCE_DIR/thirdparty/$GTEST_BASEDIR
1010
export GBENCHMARK_HOME=$SOURCE_DIR/thirdparty/installed
11+
export FLATBUFFERS_HOME=$SOURCE_DIR/thirdparty/installed
1112

1213
echo "Build env initialized"

cpp/src/arrow/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
install(FILES
2020
api.h
2121
array.h
22+
column.h
2223
builder.h
24+
schema.h
25+
table.h
2326
type.h
2427
DESTINATION include/arrow)
2528

@@ -30,3 +33,8 @@ install(FILES
3033
set(ARROW_TEST_LINK_LIBS ${ARROW_MIN_TEST_LIBS})
3134

3235
ADD_ARROW_TEST(array-test)
36+
ADD_ARROW_TEST(column-test)
37+
ADD_ARROW_TEST(schema-test)
38+
ADD_ARROW_TEST(table-test)
39+
40+
ADD_ARROW_BENCHMARK(column-benchmark)

cpp/src/arrow/api.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@
2222

2323
#include "arrow/array.h"
2424
#include "arrow/builder.h"
25+
#include "arrow/column.h"
26+
#include "arrow/schema.h"
27+
#include "arrow/table.h"
2528
#include "arrow/type.h"
2629

27-
#include "arrow/table/column.h"
28-
#include "arrow/table/schema.h"
29-
#include "arrow/table/table.h"
30-
3130
#include "arrow/types/boolean.h"
3231
#include "arrow/types/construct.h"
33-
#include "arrow/types/floating.h"
34-
#include "arrow/types/integer.h"
3532
#include "arrow/types/list.h"
33+
#include "arrow/types/primitive.h"
3634
#include "arrow/types/string.h"
3735
#include "arrow/types/struct.h"
3836

37+
#include "arrow/util/buffer.h"
3938
#include "arrow/util/memory-pool.h"
4039
#include "arrow/util/status.h"
4140

0 commit comments

Comments
 (0)