Skip to content
Closed
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
28 changes: 28 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,31 @@ jobs:
cmake .. -DBUILD_JAVA=OFF -DPROTOBUF_HOME=${CMAKE_PREFIX_PATH}
make package test-out

meson:
name: "Meson C++ configuration"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- ubuntu-24.04
- ubuntu-24.04-arm
- macos-13
- macos-14
- macos-15
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install meson
run: |
pip install --upgrade pip
pip install meson
- name: Test
run: |
meson setup build
meson compile -C build
meson test -C build
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ dependency-reduced-pom.xml
java/bench/data
*.swp
.cache/*
subprojects/*
!subprojects/packagefiles
!subprojects/*.wrap
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,43 @@ Cmake option BUILD_ENABLE_AVX512 can be set to "ON" or (default value)"OFF" at t
Environment variable ORC_USER_SIMD_LEVEL can be set to "AVX512" or (default value)"NONE" at the run time. At run time, it defines the SIMD level to dispatch the code which can apply SIMD optimization.

Note that if ORC_USER_SIMD_LEVEL is set to "NONE" at run time, AVX512 will not take effect at run time even if BUILD_ENABLE_AVX512 is set to "ON" at compile time.

### Building with Meson

While CMake is the official build system for orc, there is unofficial support for using Meson to build select parts of the project. To build a debug version of the library and test it using Meson, from the project root you can run:

```shell
meson setup build
meson compile -C build
meson test -C build
```

By default, Meson will build release libraries. If you would instead like debug libraries, you can use the ``-Dbuildtype=debug`` argument to setup. You must either remove the existing build directory before changing that setting, or alternatively pass the ``--reconfigure`` flag:

```shell
meson setup build -Dbuildtype=debug --reconfigure
meson compile -C build
meson test -C build
```

Meson supports running your test suite through valgrind out of the box:

```shell
meson test -C build --wrap=valgrind
```

If you'd like to enable sanitizers, you can leverage the ``-Db_sanitize=`` option. For example, to enable both ASAN and UBSAN, you can run:

```shell
meson setup build -Dbuildtype=debug -Db_sanitize=address,undefined --reconfigure
meson compile -C build
meson test
```

Meson takes care of detecting all dependencies on your system, and downloading missing ones as required through its [Wrap system](https://mesonbuild.com/Wrap-dependency-system-manual.html). The dependencies for the project are all stored in the ``subprojects`` directory in individual wrap files. The majority of these are system generated files created by running:

```shell
meson wrap install <depencency_name>
```

From the project root. If you are developing orc and need to add a new dependency in the future, be sure to check Meson's [WrapDB](https://mesonbuild.com/Wrapdb-projects.html) to check if a pre-configured wrap entry exists. If not, you may still manually configure the dependency as outlined in the aforementioned Wrap system documentation.
56 changes: 56 additions & 0 deletions c++/include/orc/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

cdata = configuration_data()
cdata.set('ORC_VERSION', meson.project_version())
cdata.set('ORC_CXX_HAS_CSTDINT', 1)

configure_file(
input: 'orc-config.hh.in',
output: 'orc-config.hh',
configuration: cdata,
format: 'cmake',
install: true,
install_dir: 'orc',
)

install_headers(
[
'BloomFilter.hh',
'ColumnPrinter.hh',
'Common.hh',
'Exceptions.hh',
'Int128.hh',
'MemoryPool.hh',
'OrcFile.hh',
'Reader.hh',
'Statistics.hh',
'Type.hh',
'Vector.hh',
'Writer.hh',
],
subdir: 'orc',
)

install_headers(
[
'sargs/Literal.hh',
'sargs/SearchArgument.hh',
'sargs/TruthValue.hh',
],
subdir: 'orc/sargs',
)
39 changes: 39 additions & 0 deletions c++/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# required dependencies
protobuf_dep = dependency('protobuf', fallback: ['protobuf', 'protobuf_dep'])
lz4_dep = dependency('liblz4')
snappy_dep = dependency('snappy')
zlib_dep = dependency('zlib')
zstd_dep = dependency('libzstd')

# optional dependencies (should be set later in configuration)
gtest_dep = disabler()
gmock_dep = disabler()

subdir('include/orc')
subdir('src')

if get_option('tests').enabled()
gtest_dep = dependency('gtest')
gmock_dep = dependency('gmock')
subdir('test')
endif

pkg = import('pkgconfig')
pkg.generate(orc_lib)
196 changes: 196 additions & 0 deletions c++/src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

compiler = meson.get_compiler('cpp')
has_pread = compiler.compiles('''
#include<fcntl.h>
#include<unistd.h>
int main(int,char*[]){
int f = open("/x/y", O_RDONLY);
char buf[100];
return pread(f, buf, 100, 1000) == 0;
}
''')

has_strptime = compiler.compiles('''
#include<time.h>
int main(int,char*[]){
struct tm time2020;
return !strptime("2020-02-02 12:34:56", "%Y-%m-%d %H:%M:%S", &time2020);
}
''')

has_builtin_overflow_check = compiler.compiles('''
int main(){
int a;
return __builtin_add_overflow(1, 2, &a);
}
''')

has_diagnostic_push = compiler.compiles('''
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
#pragma clang diagnostic pop
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated"
#pragma GCC diagnostic pop
#elif defined(_MSC_VER)
#pragma warning( push )
#pragma warning( disable : 4996 )
#pragma warning( pop )
#else
unknownCompiler!
#endif
int main(int, char *[]) {}
''')

has_std_isnan = compiler.compiles('''
#include<cmath>
int main(int, char *[]) {
return std::isnan(1.0f);
}
''')

has_double_to_string = compiler.compiles('''
#include<string>
int main(int, char *[]) {
double d = 5;
std::to_string(d);
}
''')

has_int64_to_string = compiler.compiles('''
#include<cstdint>
#include<string>
int main(int, char *[]) {
int64_t d = 5;
std::to_string(d);
}
''')

has_pre_1970 = compiler.run('''
#include<time.h>
int main(int, char *[]) {
time_t t = -14210715; // 1969-07-20 12:34:45
struct tm *ptm = gmtime(&t);
return !(ptm && ptm->tm_year == 69);
}
''')

has_post_2038 = compiler.run('''
#include<stdlib.h>
#include<time.h>
int main(int, char *[]) {
setenv("TZ", "America/Los_Angeles", 1);
tzset();
struct tm time2037;
struct tm time2038;
strptime("2037-05-05 12:34:56", "%Y-%m-%d %H:%M:%S", &time2037);
strptime("2038-05-05 12:34:56", "%Y-%m-%d %H:%M:%S", &time2038);
return (mktime(&time2038) - mktime(&time2037)) <= 31500000;
}
''')

cdata = configuration_data()
cdata.set10('HAS_PREAD', has_pread)
cdata.set10('HAS_STRPTIME', has_strptime)
cdata.set10('HAS_DIAGNOSTIC_PUSH', has_diagnostic_push)
cdata.set10('HAS_DOUBLE_TO_STRING', has_double_to_string)
cdata.set10('HAS_INT64_TO_STRING', has_int64_to_string)
cdata.set('HAS_PRE_1970', has_pre_1970.returncode() == 0)
cdata.set('HAS_POST_2038', has_post_2038.returncode() == 0)
cdata.set10('HAS_STD_ISNAN', has_std_isnan)
cdata.set10('HAS_BUILTIN_OVERFLOW_CHECK', has_builtin_overflow_check)
cdata.set10('NEEDS_Z_PREFIX', false) # Meson zlib subproject does not need this

adaptor_header = configure_file(
input: 'Adaptor.hh.in',
output: 'Adaptor.hh',
configuration: cdata,
format: 'cmake',
)

source_files = [adaptor_header]
source_files += files(
'io/InputStream.cc',
'io/OutputStream.cc',
'io/Cache.cc',
'sargs/ExpressionTree.cc',
'sargs/Literal.cc',
'sargs/PredicateLeaf.cc',
'sargs/SargsApplier.cc',
'sargs/SearchArgument.cc',
'sargs/TruthValue.cc',
'wrap/orc-proto-wrapper.cc',
'Adaptor.cc',
'BlockBuffer.cc',
'BloomFilter.cc',
'BpackingDefault.cc',
'ByteRLE.cc',
'ColumnPrinter.cc',
'ColumnReader.cc',
'ColumnWriter.cc',
'Common.cc',
'Compression.cc',
'ConvertColumnReader.cc',
'CpuInfoUtil.cc',
'Exceptions.cc',
'Int128.cc',
'LzoDecompressor.cc',
'MemoryPool.cc',
'Murmur3.cc',
'OrcFile.cc',
'Reader.cc',
'RLEv1.cc',
'RLEV2Util.cc',
'RleDecoderV2.cc',
'RleEncoderV2.cc',
'RLE.cc',
'SchemaEvolution.cc',
'Statistics.cc',
'StripeStream.cc',
'Timezone.cc',
'TypeImpl.cc',
'Vector.cc',
'Writer.cc',
)

incdir = include_directories('../include')
orc_format_proto_dep = dependency('orc_format_proto')

orc_lib = library(
'orc',
sources: source_files,
dependencies: [
orc_format_proto_dep,
protobuf_dep,
zlib_dep,
snappy_dep,
lz4_dep,
zstd_dep,
],
include_directories: incdir,
install: true,
)

orc_dep = declare_dependency(
link_with: orc_lib,
include_directories: incdir,
dependencies: orc_format_proto_dep,
)
Loading
Loading