Skip to content

Commit e5133a7

Browse files
committed
feat: Meson build support for IPC
1 parent f443e46 commit e5133a7

File tree

10 files changed

+110
-10
lines changed

10 files changed

+110
-10
lines changed

dev/release/rat_exclude_files.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ python/src/nanoarrow/dlpack_abi.h
1818
subprojects/google-benchmark.wrap
1919
subprojects/gtest.wrap
2020
subprojects/nlohmann_json.wrap
21+
subprojects/zlib.wrap

meson.build

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,14 @@ subdir('src/nanoarrow')
3434
if get_option('benchmarks')
3535
subdir('dev/benchmarks')
3636
endif
37+
38+
39+
if get_option('apps')
40+
if get_option('ipc')
41+
executable(
42+
'dump_stream',
43+
'src/apps/dump_stream.c',
44+
dependencies: [nanoarrow_dep, nanoarrow_ipc_dep]
45+
)
46+
endif
47+
endif

meson.options

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
option('tests', type: 'boolean', description: 'Build tests', value: false)
1919
option('benchmarks', type: 'boolean', description: 'Build benchmarks', value: false)
20+
option('apps', type: 'boolean', description: 'Build utility applications', value: false)
21+
option('ipc', type: 'boolean', description: 'Build IPC libraries', value: false)
2022
option('integration_tests', type: 'boolean',
2123
description: 'Build cross-implementation Arrow integration tests',
2224
value: false)

src/apps/dump_stream.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
void dump_schema_to_stdout(struct ArrowSchema* schema, int level, char* buf,
2525
int buf_size) {
26-
int n_chars = ArrowSchemaToString(schema, buf, buf_size, 0);
27-
2826
for (int i = 0; i < level; i++) {
2927
fprintf(stdout, " ");
3028
}

src/nanoarrow/meson.build

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,25 @@ incdir = include_directories('..')
6464
nanoarrow_dep = declare_dependency(include_directories: [curdir, incdir],
6565
link_with: nanoarrow_lib)
6666

67+
if get_option('ipc')
68+
cmake = import('cmake')
69+
cmake_opts = cmake.subproject_options()
70+
cmake_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': true})
71+
flatcc_subproj = cmake.subproject('flatcc', options: cmake_opts)
72+
flatcc_dep = flatcc_subproj.dependency('flatccrt')
73+
74+
nanoarrow_ipc_lib = build_target(
75+
'nanoarrow_ipc',
76+
'nanoarrow_ipc_decoder.c',
77+
'nanoarrow_ipc_reader.c',
78+
dependencies: [nanoarrow_dep, flatcc_dep],
79+
install: true,
80+
target_type: libtype,
81+
)
82+
nanoarrow_ipc_dep = declare_dependency(include_directories: [incdir],
83+
link_with: nanoarrow_ipc_lib)
84+
endif
85+
6786
if get_option('tests') or get_option('integration_tests')
6887
nlohmann_json_dep = dependency('nlohmann_json')
6988

@@ -147,4 +166,38 @@ if get_option('tests')
147166
include_directories: incdir)
148167
test('c_data_integration test', c_data_integration_test)
149168

169+
if get_option('ipc')
170+
zlib_dep = dependency('zlib')
171+
ipc_test_files = {
172+
'nanoarrow-ipc-decoder': {
173+
'deps': [nanoarrow_dep, flatcc_dep, arrow_dep, gtest_dep],
174+
},
175+
'nanoarrow-ipc-reader': {
176+
'deps': [nanoarrow_dep, flatcc_dep, arrow_dep, gtest_dep],
177+
},
178+
'nanoarrow-ipc-files': {
179+
'deps': [
180+
nanoarrow_dep,
181+
flatcc_dep,
182+
zlib_dep,
183+
arrow_dep,
184+
gtest_dep,
185+
nlohmann_json_dep
186+
],
187+
},
188+
'nanoarrow-ipc-hpp': {
189+
'deps': [nanoarrow_dep, flatcc_dep, gtest_dep],
190+
},
191+
}
192+
193+
foreach name, config : ipc_test_files
194+
exc = executable(
195+
name + '-test',
196+
name.replace('-', '_') + '_test.cc',
197+
link_with: nanoarrow_ipc_lib,
198+
dependencies: config['deps']
199+
)
200+
test(name, exc)
201+
endforeach
202+
endif
150203
endif

src/nanoarrow/nanoarrow.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,8 @@ class ViewArrayStream {
864864
};
865865

866866
internal::InputRange<Next> range_;
867-
ArrowError* error_;
868867
ArrowErrorCode* code_;
868+
ArrowError* error_;
869869
ArrowError internal_error_ = {};
870870
ArrowErrorCode internal_code_;
871871
bool code_was_accessed_ = false;

src/nanoarrow/nanoarrow_ipc_decoder_test.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ struct ArrowIpcDecoderPrivate {
5454
static enum ArrowIpcEndianness ArrowIpcSystemEndianness(void) {
5555
uint32_t check = 1;
5656
char first_byte;
57-
enum ArrowIpcEndianness system_endianness;
5857
memcpy(&first_byte, &check, sizeof(char));
5958
if (first_byte) {
6059
return NANOARROW_IPC_ENDIANNESS_LITTLE;
@@ -501,8 +500,6 @@ TEST(NanoarrowIpcTest, NanoarrowIpcDecodeSimpleRecordBatchFromShared) {
501500
data.size_bytes = sizeof(kSimpleRecordBatch);
502501

503502
ArrowIpcDecoderInit(&decoder);
504-
auto decoder_private =
505-
reinterpret_cast<struct ArrowIpcDecoderPrivate*>(decoder.private_data);
506503

507504
ASSERT_EQ(ArrowIpcDecoderSetSchema(&decoder, &schema, nullptr), NANOARROW_OK);
508505
EXPECT_EQ(ArrowIpcDecoderDecodeHeader(&decoder, data, &error), NANOARROW_OK);
@@ -602,8 +599,10 @@ TEST(NanoarrowIpcTest, NanoarrowIpcSharedBufferThreadSafeDecode) {
602599
std::thread threads[10];
603600
for (int i = 0; i < 10; i++) {
604601
threads[i] = std::thread([&arrays, i, &one_two_three_le] {
605-
memcmp(arrays[i].children[0]->buffers[1], one_two_three_le,
606-
sizeof(one_two_three_le));
602+
auto result = memcmp(arrays[i].children[0]->buffers[1], one_two_three_le,
603+
sizeof(one_two_three_le));
604+
// discard result to silence -Wunused-value
605+
(void)result;
607606
ArrowArrayRelease(arrays + i);
608607
});
609608
}
@@ -791,7 +790,7 @@ TEST_P(ArrowTypeIdParameterizedTestFixture, NanoarrowIpcDecodeSwapEndian) {
791790
// Make a data buffer long enough for 10 Decimal256s with a pattern
792791
// where an endian swap isn't silently the same value (e.g., 0s)
793792
uint8_t data_buffer[32 * 10];
794-
for (int64_t i = 0; i < sizeof(data_buffer); i++) {
793+
for (size_t i = 0; i < sizeof(data_buffer); i++) {
795794
data_buffer[i] = i % 256;
796795
}
797796

src/nanoarrow/nanoarrow_testing_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ TEST(NanoarrowTestingTest, NanoarrowTestingTestFieldMetadata) {
470470
NANOARROW_RETURN_NOT_OK(ArrowSchemaSetMetadata(schema, "\0\0\0\0"));
471471
return NANOARROW_OK;
472472
},
473-
[](ArrowArray* array) { return NANOARROW_OK; }, &WriteFieldJSON,
473+
[](ArrowArray*) { return NANOARROW_OK; }, &WriteFieldJSON,
474474
R"({"name": null, "nullable": true, "type": {"name": "null"}, "children": []})",
475475
[](TestingJSONWriter& writer) { writer.set_include_metadata(false); });
476476
}

subprojects/flatcc.wrap

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
[wrap-git]
19+
method = cmake
20+
url = https://github.com/dvidelabs/flatcc
21+
revision = v0.6.1
22+
depth = 1
23+
clone-recursive = true

subprojects/zlib.wrap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[wrap-file]
2+
directory = zlib-1.3.1
3+
source_url = http://zlib.net/fossils/zlib-1.3.1.tar.gz
4+
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/zlib_1.3.1-1/zlib-1.3.1.tar.gz
5+
source_filename = zlib-1.3.1.tar.gz
6+
source_hash = 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23
7+
patch_filename = zlib_1.3.1-1_patch.zip
8+
patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.1-1/get_patch
9+
patch_hash = e79b98eb24a75392009cec6f99ca5cdca9881ff20bfa174e8b8926d5c7a47095
10+
wrapdb_version = 1.3.1-1
11+
12+
[provide]
13+
zlib = zlib_dep

0 commit comments

Comments
 (0)