Skip to content

Commit 22794ce

Browse files
authored
chore: Update + namespace nanoarrow (#86)
1 parent a9293f3 commit 22794ce

16 files changed

+588
-248
lines changed

.cmake-format

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
# cmake-format configuration file
19+
# Use `archery lint --cmake-format --fix` to reformat all cmake files in the
20+
# source tree
21+
22+
# -----------------------------
23+
# Options affecting formatting.
24+
# -----------------------------
25+
with section("format"):
26+
# How wide to allow formatted cmake files
27+
line_width = 90
28+
29+
# How many spaces to tab for indent
30+
tab_size = 2
31+
32+
# If a positional argument group contains more than this many arguments,
33+
# then force it to a vertical layout.
34+
max_pargs_hwrap = 4
35+
36+
# If the statement spelling length (including space and parenthesis) is
37+
# smaller than this amount, then force reject nested layouts.
38+
# This value only comes into play when considering whether or not to nest
39+
# arguments below their parent. If the number of characters in the parent
40+
# is less than this value, we will not nest.
41+
min_prefix_chars = 32
42+
43+
# If true, separate flow control names from their parentheses with a space
44+
separate_ctrl_name_with_space = False
45+
46+
# If true, separate function names from parentheses with a space
47+
separate_fn_name_with_space = False
48+
49+
# If a statement is wrapped to more than one line, than dangle the closing
50+
# parenthesis on it's own line
51+
dangle_parens = False
52+
53+
# What style line endings to use in the output.
54+
line_ending = 'unix'
55+
56+
# Format command names consistently as 'lower' or 'upper' case
57+
command_case = 'lower'
58+
59+
# Format keywords consistently as 'lower' or 'upper' case
60+
keyword_case = 'unchanged'
61+
62+
# ------------------------------------------------
63+
# Options affecting comment reflow and formatting.
64+
# ------------------------------------------------
65+
with section("markup"):
66+
# enable comment markup parsing and reflow
67+
enable_markup = False
68+
69+
# If comment markup is enabled, don't reflow the first comment block in
70+
# eachlistfile. Use this to preserve formatting of your
71+
# copyright/licensestatements.
72+
first_comment_is_literal = True
73+
74+
# If comment markup is enabled, don't reflow any comment block which
75+
# matchesthis (regex) pattern. Default is `None` (disabled).
76+
literal_comment_pattern = None

CMakeLists.txt

Lines changed: 76 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
message(STATUS "Building using CMake version: ${CMAKE_VERSION}")
32
cmake_minimum_required(VERSION 3.14)
43

@@ -7,7 +6,8 @@ if(NOT DEFINED CMAKE_C_STANDARD)
76
endif()
87

98
set(GEOARROW_VERSION "0.2.0-SNAPSHOT")
10-
string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" GEOARROW_BASE_VERSION "${GEOARROW_VERSION}")
9+
string(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" GEOARROW_BASE_VERSION
10+
"${GEOARROW_VERSION}")
1111
project(geoarrow VERSION "${GEOARROW_BASE_VERSION}")
1212

1313
set(GEOARROW_VERSION_MAJOR "${geoarrow_VERSION_MAJOR}")
@@ -18,8 +18,17 @@ option(GEOARROW_BUILD_TESTS "Build tests" OFF)
1818
option(GEOARROW_CODE_COVERAGE "Enable coverage reporting" OFF)
1919
option(GEOARROW_USE_FAST_FLOAT "Use fast_float for numeric value parsing" ON)
2020
option(GEOARROW_USE_RYU "Use ryu for numeric value printing" ON)
21+
option(GEOARROW_NAMESPACE "A prefix for exported symbols" OFF)
22+
option(GEOARROW_ARROW_STATIC "Use a statically-linked Arrow C++ build when linking tests"
23+
OFF)
24+
25+
if(GEOARROW_NAMESPACE)
26+
set(GEOARROW_NAMESPACE_DEFINE "#define GEOARROW_NAMESPACE ${GEOARROW_NAMESPACE}")
27+
else()
28+
set(GEOARROW_NAMESPACE_DEFINE "// #define GEOARROW_NAMESPACE YourNamespaceHere")
29+
endif()
2130

22-
if (GEOARROW_BUILD_TESTS)
31+
if(GEOARROW_BUILD_TESTS)
2332
add_library(coverage_config INTERFACE)
2433
endif()
2534

@@ -49,69 +58,68 @@ endif()
4958

5059
configure_file(src/geoarrow/geoarrow_config.h.in generated/geoarrow_config.h)
5160

52-
add_library(
53-
geoarrow
54-
src/geoarrow/schema.c
55-
src/geoarrow/schema_view.c
56-
src/geoarrow/metadata.c
57-
src/geoarrow/kernel.c
58-
src/geoarrow/builder.c
59-
src/geoarrow/array_view.c
60-
src/geoarrow/util.c
61-
src/geoarrow/visitor.c
62-
src/geoarrow/wkb_reader.c
63-
src/geoarrow/wkb_writer.c
64-
src/geoarrow/wkt_reader.c
65-
src/geoarrow/wkt_writer.c
66-
src/geoarrow/array_reader.c
67-
src/geoarrow/array_writer.c
68-
${GEOARROW_DOUBLE_PARSE_SOURCE}
69-
${GEOARROW_DOUBLE_PRINT_SOURCE}
70-
src/geoarrow/nanoarrow.c)
71-
72-
target_include_directories(geoarrow PUBLIC
73-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/geoarrow>
74-
$<INSTALL_INTERFACE:include>)
61+
add_library(geoarrow
62+
src/geoarrow/schema.c
63+
src/geoarrow/schema_view.c
64+
src/geoarrow/metadata.c
65+
src/geoarrow/kernel.c
66+
src/geoarrow/builder.c
67+
src/geoarrow/array_view.c
68+
src/geoarrow/util.c
69+
src/geoarrow/visitor.c
70+
src/geoarrow/wkb_reader.c
71+
src/geoarrow/wkb_writer.c
72+
src/geoarrow/wkt_reader.c
73+
src/geoarrow/wkt_writer.c
74+
src/geoarrow/array_reader.c
75+
src/geoarrow/array_writer.c
76+
${GEOARROW_DOUBLE_PARSE_SOURCE}
77+
${GEOARROW_DOUBLE_PRINT_SOURCE}
78+
src/geoarrow/nanoarrow.c)
79+
80+
target_include_directories(geoarrow
81+
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/geoarrow>
82+
$<INSTALL_INTERFACE:include>)
7583
target_include_directories(geoarrow
76-
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>
84+
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>
7785
)
78-
target_compile_definitions(geoarrow PUBLIC
79-
"$<$<CONFIG:Debug>:NANOARROW_DEBUG>"
80-
"$<$<CONFIG:Debug>:GEOARROW_DEBUG>")
86+
target_compile_definitions(geoarrow PUBLIC "$<$<CONFIG:Debug>:NANOARROW_DEBUG>"
87+
"$<$<CONFIG:Debug>:GEOARROW_DEBUG>")
8188

8289
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
8390
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
84-
target_compile_options(
85-
geoarrow
86-
PRIVATE
87-
-Wall
88-
-Werror
89-
-Wextra
90-
-Wno-type-limits
91-
-Wno-unused-parameter
92-
-Wpedantic
93-
-Wunused-result)
94-
elseif(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" OR
95-
CMAKE_C_COMPILER_ID STREQUAL "Clang")
96-
target_compile_options(
97-
geoarrow
98-
PRIVATE
99-
-Wall
100-
-Werror
101-
-Wextra
102-
-Wdocumentation
103-
-Wno-unused-parameter
104-
-Wshorten-64-to-32)
91+
target_compile_options(geoarrow
92+
PRIVATE -Wall
93+
-Werror
94+
-Wextra
95+
-Wno-type-limits
96+
-Wno-unused-parameter
97+
-Wpedantic
98+
-Wunused-result)
99+
elseif(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_C_COMPILER_ID STREQUAL
100+
"Clang")
101+
target_compile_options(geoarrow
102+
PRIVATE -Wall
103+
-Werror
104+
-Wextra
105+
-Wdocumentation
106+
-Wno-unused-parameter
107+
-Wshorten-64-to-32)
105108
endif()
106109
endif()
107110

108111
install(TARGETS geoarrow DESTINATION lib)
109-
install(DIRECTORY src/ DESTINATION include FILES_MATCHING PATTERN "*.h")
112+
install(DIRECTORY src/
113+
DESTINATION include
114+
FILES_MATCHING
115+
PATTERN "*.h")
110116
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/generated/geoarrow_config.h
111117
DESTINATION include/geoarrow)
112118

113119
if(GEOARROW_BUILD_TESTS)
114-
set(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --suppressions=${CMAKE_CURRENT_LIST_DIR}/valgrind.supp --error-exitcode=1")
120+
set(MEMORYCHECK_COMMAND_OPTIONS
121+
"--leak-check=full --suppressions=${CMAKE_CURRENT_LIST_DIR}/valgrind.supp --error-exitcode=1"
122+
)
115123
include(CTest)
116124
include(FetchContent)
117125

@@ -129,30 +137,28 @@ if(GEOARROW_BUILD_TESTS)
129137
cmake_policy(SET CMP0135 NEW)
130138
endif()
131139

132-
if(MSVC)
133-
set(gtest_force_shared_crt on)
134-
set(NANOARROW_ARROW_TARGET arrow_static)
140+
# Give caller the option to link a static version of Arrow C++
141+
if(GEOARROW_ARROW_STATIC)
142+
set(GEOARROW_ARROW_TARGET arrow_static)
135143
else()
136-
set(NANOARROW_ARROW_TARGET arrow_shared)
144+
set(GEOARROW_ARROW_TARGET arrow_shared)
137145
endif()
138146

139147
# Use an old version of googletest if we have to to support gcc 4.8
140-
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
141-
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "5.0.0")
142-
FetchContent_Declare(
143-
googletest
144-
URL https://github.com/google/googletest/archive/release-1.11.0.zip
145-
URL_HASH SHA256=353571c2440176ded91c2de6d6cd88ddd41401d14692ec1f99e35d013feda55a
148+
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_VERSION
149+
VERSION_GREATER_EQUAL "5.0.0")
150+
fetchcontent_declare(googletest
151+
URL https://github.com/google/googletest/archive/release-1.11.0.zip
152+
URL_HASH SHA256=353571c2440176ded91c2de6d6cd88ddd41401d14692ec1f99e35d013feda55a
146153
)
147154
else()
148-
FetchContent_Declare(
149-
googletest
150-
URL https://github.com/google/googletest/archive/release-1.10.0.zip
151-
URL_HASH SHA256=94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91
155+
fetchcontent_declare(googletest
156+
URL https://github.com/google/googletest/archive/release-1.10.0.zip
157+
URL_HASH SHA256=94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91
152158
)
153159
endif()
154160

155-
FetchContent_MakeAvailable(googletest)
161+
fetchcontent_makeavailable(googletest)
156162

157163
enable_testing()
158164

@@ -185,7 +191,7 @@ if(GEOARROW_BUILD_TESTS)
185191
target_link_libraries(geoarrow_type_inline_test geoarrow gtest_main)
186192
target_link_libraries(builder_test geoarrow gtest_main)
187193
target_link_libraries(array_view_test geoarrow gtest_main)
188-
target_link_libraries(schema_test geoarrow arrow_shared gtest_main)
194+
target_link_libraries(schema_test geoarrow ${GEOARROW_ARROW_TARGET} gtest_main)
189195
target_link_libraries(schema_view_test geoarrow gtest_main)
190196
target_link_libraries(kernel_test geoarrow gtest_main)
191197
target_link_libraries(metadata_test geoarrow gtest_main)
@@ -198,7 +204,7 @@ if(GEOARROW_BUILD_TESTS)
198204
target_link_libraries(array_reader_test geoarrow gtest_main)
199205
target_link_libraries(array_writer_test geoarrow gtest_main)
200206
target_link_libraries(wkx_files_test geoarrow gtest_main)
201-
target_link_libraries(geoarrow_arrow_test geoarrow arrow_shared gtest_main)
207+
target_link_libraries(geoarrow_arrow_test geoarrow ${GEOARROW_ARROW_TARGET} gtest_main)
202208

203209
include(GoogleTest)
204210
gtest_discover_tests(geoarrow_hpp_test)

src/geoarrow/array_reader.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ struct GeoArrowArrayReaderPrivate {
88
struct GeoArrowWKBReader wkb_reader;
99
};
1010

11-
static GeoArrowErrorCode GeoArrowArrayViewVisitWKT(struct GeoArrowArrayView* array_view,
12-
int64_t offset, int64_t length,
13-
struct GeoArrowWKTReader* reader,
14-
struct GeoArrowVisitor* v) {
11+
static GeoArrowErrorCode GeoArrowArrayViewVisitWKT(
12+
const struct GeoArrowArrayView* array_view, int64_t offset, int64_t length,
13+
struct GeoArrowWKTReader* reader, struct GeoArrowVisitor* v) {
1514
struct GeoArrowStringView item;
1615
const int32_t* offset_begin = array_view->offsets[0] + array_view->offset[0] + offset;
1716

@@ -31,10 +30,9 @@ static GeoArrowErrorCode GeoArrowArrayViewVisitWKT(struct GeoArrowArrayView* arr
3130
return GEOARROW_OK;
3231
}
3332

34-
static GeoArrowErrorCode GeoArrowArrayViewVisitWKB(struct GeoArrowArrayView* array_view,
35-
int64_t offset, int64_t length,
36-
struct GeoArrowWKBReader* reader,
37-
struct GeoArrowVisitor* v) {
33+
static GeoArrowErrorCode GeoArrowArrayViewVisitWKB(
34+
const struct GeoArrowArrayView* array_view, int64_t offset, int64_t length,
35+
struct GeoArrowWKBReader* reader, struct GeoArrowVisitor* v) {
3836
struct GeoArrowBufferView item;
3937
const int32_t* offset_begin = array_view->offsets[0] + array_view->offset[0] + offset;
4038

@@ -89,7 +87,7 @@ void GeoArrowArrayReaderReset(struct GeoArrowArrayReader* reader) {
8987
}
9088

9189
GeoArrowErrorCode GeoArrowArrayReaderVisit(struct GeoArrowArrayReader* reader,
92-
struct GeoArrowArrayView* array_view,
90+
const struct GeoArrowArrayView* array_view,
9391
int64_t offset, int64_t length,
9492
struct GeoArrowVisitor* v) {
9593
struct GeoArrowArrayReaderPrivate* private_data =

0 commit comments

Comments
 (0)