Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add name metadata convenient constructors #310

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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
167 changes: 79 additions & 88 deletions .github/workflows/qemu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,31 @@ on:

jobs:
build_job:
runs-on: ubuntu-22.04
name: Build on ${{ matrix.target.arch }} / ${{ matrix.target.distro }} / ${{ matrix.config.name }} / date-polyfill ${{ matrix.target.date-polyfill}}
runs-on: ubuntu-24.04
name: Build on ${{ matrix.target.arch }} / ${{ matrix.config.name }} / date-polyfill ${{ matrix.target.date-polyfill}}

strategy:
matrix:
target:
- { arch: armv6, distro: alpine_latest, date-polyfill: 'ON' }
- { arch: armv7, distro: alpine_latest, date-polyfill: 'ON' }
- { arch: aarch64, distro: alpine_latest, date-polyfill: 'ON' }
- { arch: aarch64, distro: alpine_latest, date-polyfill: 'OFF' }
- { arch: riscv64, distro: alpine_latest, date-polyfill: 'ON' }
- { arch: s390x, distro: alpine_latest, date-polyfill: 'ON' }
- { arch: s390x, distro: alpine_latest, date-polyfill: 'OFF' }
- { arch: ppc64le, distro: alpine_latest, date-polyfill: 'ON' }
- { arch: ppc64le, distro: alpine_latest, date-polyfill: 'OFF' }
# - { arch: armv7, date-polyfill: 'ON' }
- { arch: aarch64, date-polyfill: 'ON' }
- { arch: aarch64, date-polyfill: 'OFF'}
- { arch: riscv64, date-polyfill: 'ON' }
- { arch: s390x, date-polyfill: 'ON' }
- { arch: s390x, date-polyfill: 'OFF' }
- { arch: ppc64le, date-polyfill: 'ON' }
- { arch: ppc64le, date-polyfill: 'OFF' }

config:
- { name: Debug }
- { name: Release }

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install binfmt-support
run: |
sudo apt-get update
sudo apt-get install binfmt-support

- name: Get current date
id: date
uses: Kaven-Universe/github-action-current-date-time@v1
Expand All @@ -40,91 +41,81 @@ jobs:
- name: Cache builds
uses: actions/cache@v4
with:
key: ${{matrix.target.arch}}_${{matrix.target.distro}}_${{matrix.config.name}}_${{matrix.target.date-polyfill}}_ccache-${{ steps.date.outputs.time }}
path: ccache_cache
key: ${{matrix.target.arch}}_${{matrix.config.name}}_${{matrix.target.date-polyfill}}_ccache-${{ steps.date.outputs.time }}
path: ${{ github.workspace }}/.ccache
restore-keys: |
${{matrix.target.arch}}_${{matrix.target.distro}}_${{matrix.config.name}}_${{matrix.target.date-polyfill}}_ccache-
${{matrix.target.arch}}_${{matrix.config.name}}_${{matrix.target.date-polyfill}}_ccache-

- uses: uraimo/run-on-arch-action@v2
name: Build artifact
id: build
- name: Set up Alpine Linux for ${{ matrix.target.arch }}
uses: jirutka/setup-alpine@v1
id: alpine-target
with:
arch: ${{matrix.target.arch}}
distro: ${{matrix.target.distro}}
branch: v3.20
arch: ${{ matrix.target.arch }}
packages: >
ccache
cmake
date-dev
doctest-dev
g++
git
linux-headers
make
musl-dev
samurai
tzdata
shell-name: alpine.sh

- name: Checkout code
uses: actions/checkout@v4

- name: Configuring sparrow
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
run: cmake -G Ninja -Bbuild
-DCMAKE_BUILD_TYPE:STRING=${{matrix.config.name}}
-DUSE_DATE_POLYFILL=${{matrix.target.date-polyfill}}
-DBUILD_TESTS:BOOL=ON
-DBUILD_EXAMPLES:BOOL=ON
-DFETCH_DEPENDENCIES_WITH_CMAKE=MISSING
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-B build

# Not required, but speeds up builds
githubToken: ${{github.token}}
shell: alpine.sh {0}

setup: |
mkdir -p "${PWD}/artifacts"
mkdir -p "${PWD}/ccache_cache"
- name: Building sparrow library
run: cmake --build build --config ${{matrix.config.name}} --target sparrow
shell: alpine.sh {0}

# Mount the artifacts directory as /artifacts
# Mount the ccache_cache directory as /ccache_cache
dockerRunArgs: |
--volume "${PWD}/artifacts:/artifacts" --volume "${PWD}/ccache_cache:/ccache_cache"
- name: Building sparrow tests
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
run: cmake --build build --config ${{matrix.config.name}} --target test_sparrow_lib
shell: alpine.sh {0}

# The shell to run commands with in the container
shell: /bin/sh
- name: Running sparrow examples
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
run: cmake --build build --config ${{matrix.config.name}} --target run_examples
shell: alpine.sh {0}

# Install some dependencies in the container. This speeds up builds if
# you are also using githubToken. Any dependencies installed here will
# be part of the container image that gets cached, so subsequent
# builds don't have to re-install them. The image layer is cached
# publicly in your project's package repository, so it is vital that
# no secrets are present in the container state or logs.
install: |
case "${{matrix.target.distro}}" in
ubuntu*|bookworm)
apt-get update -q -y
apt-get install -q -y git cmake make doctest-dev libhowardhinnant-date-dev tzdata g++ ninja-build build-essential ccache
;;
fedora*)
dnf -y update
dnf -y groupinstall "Development Tools"
dnf -y install git which cmake make doctest-devel date date-devel tzdata gcc-c++ ninja-build ccache
;;
alpine*)
apk update
apk add git cmake make doctest-dev date-dev tzdata g++ samurai ccache linux-headers musl-dev
;;
esac
- name: Running sparrow tests
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
run: cmake --build build --config ${{matrix.config.name}} --target run_tests_with_junit_report
shell: alpine.sh {0}

run: |
CCACHE_DIR=/ccache_cache
export CCACHE_DIR
export CCACHE_MAXSIZE=1G
CC=gcc
export CC
CXX=g++
export CXX
echo "Configuring sparrow"
cmake -G Ninja -Bbuild \
-DCMAKE_BUILD_TYPE:STRING=${{matrix.config.name}} \
-DUSE_DATE_POLYFILL=${{matrix.target.date-polyfill}} \
-DBUILD_TESTS=ON \
-DBUILD_EXAMPLES=ON \
-DUSE_LARGE_INT_PLACEHOLDERS=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DFETCH_DEPENDENCIES_WITH_CMAKE=MISSING
cd build
echo "Building sparrow library"
cmake --build . --config ${{matrix.config.name}} --target sparrow
echo "Building sparrow tests"
cmake --build . --config ${{matrix.config.name}} --target test_sparrow_lib
echo "Running sparrow examples"
cmake --build . --config ${{matrix.config.name}} --target run_examples
echo "Running sparrow tests"
cmake --build . --config ${{matrix.config.name}} --target run_tests_with_junit_report
ccache --show-stats
- name: CCache stat
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
run: ccache --show-stats
shell: alpine.sh {0}

- name: Upload test results
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test_sparrow_lib_report_Linux_${{matrix.target.distro}}_${{matrix.target.arch}}_${{matrix.config.name}}_date-polyfill_${{matrix.target.date-polyfill}}
path: |
build/test/test_sparrow_lib_report_doctest.xml
build/test/test_sparrow_lib_report_catch2.xml
name: test_sparrow_lib_report_Linux_${{matrix.target.arch}}_${{matrix.config.name}}_date-polyfill_${{matrix.target.date-polyfill}}
path: ./**/test*.xml
if-no-files-found: error
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ if(ENABLE_COVERAGE)
endif()

if (BUILD_TESTS)
message(STATUS "🧪 Create tests targets")
enable_testing()
add_subdirectory(test)
endif ()
Expand Down
8 changes: 4 additions & 4 deletions include/sparrow/arrow_array_schema_proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,22 @@
* @param data_type The data type to set.
*/
void SPARROW_API set_data_type(enum data_type data_type);
[[nodiscard]] SPARROW_API std::optional<const std::string_view> name() const;
[[nodiscard]] SPARROW_API std::optional<std::string_view> name() const;

/**
* Set the name of the `ArrowSchema`.
* @exception `arrow_proxy_exception` If the `ArrowSchema` was not created with sparrow.
* @param name The name to set.
*/
SPARROW_API void set_name(std::optional<const std::string_view> name);
[[nodiscard]] SPARROW_API std::optional<const std::string_view> metadata() const;
SPARROW_API void set_name(std::optional<std::string_view> name);
[[nodiscard]] SPARROW_API std::optional<std::string_view> metadata() const;

/**
* Set the metadata of the `ArrowSchema`.
* @exception `arrow_proxy_exception` If the `ArrowSchema` was not created with sparrow.
* @param metadata The metadata to set.
*/
SPARROW_API void set_metadata(std::optional<const std::string_view> metadata);
SPARROW_API void set_metadata(std::optional<std::string_view> metadata);
[[nodiscard]] SPARROW_API std::vector<ArrowFlag> flags() const;

/**
Expand Down Expand Up @@ -450,7 +450,7 @@

template <std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, arrow_array_and_schema>
void arrow_proxy::add_children(R&& arrow_arrays_and_schemas)

Check warning on line 453 in include/sparrow/arrow_array_schema_proxy.hpp

View workflow job for this annotation

GitHub Actions / build

include/sparrow/arrow_array_schema_proxy.hpp:453:40 [cppcoreguidelines-missing-std-forward]

forwarding reference parameter 'arrow_arrays_and_schemas' is never forwarded inside the function body
{
if (!is_created_with_sparrow())
{
Expand Down Expand Up @@ -479,7 +479,7 @@
{
throw arrow_proxy_exception("Cannot modify the bitmap on non-sparrow created ArrowArray");
}
SPARROW_ASSERT_TRUE(has_bitmap(data_type()))

Check warning on line 482 in include/sparrow/arrow_array_schema_proxy.hpp

View workflow job for this annotation

GitHub Actions / build

include/sparrow/arrow_array_schema_proxy.hpp:482:9 [cppcoreguidelines-avoid-do-while]

avoid do-while loops

Check warning on line 482 in include/sparrow/arrow_array_schema_proxy.hpp

View workflow job for this annotation

GitHub Actions / build

include/sparrow/arrow_array_schema_proxy.hpp:482:9 [cppcoreguidelines-pro-type-vararg]

do not call c-style vararg functions
auto bitmap = get_non_owning_dynamic_bitset();
const auto it = bitmap.insert(sparrow::next(bitmap.cbegin(), index), range.begin(), range.end());
return static_cast<size_t>(std::distance(bitmap.begin(), it));
Expand Down
66 changes: 34 additions & 32 deletions include/sparrow/buffer/dynamic_bitset/dynamic_bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@

#pragma once

#include "sparrow/buffer/dynamic_bitset/dynamic_bitset_base.hpp"
#include <type_traits>

#include "sparrow/buffer/buffer.hpp"
#include "sparrow/buffer/dynamic_bitset/dynamic_bitset_base.hpp"
#include "sparrow/utils/ranges.hpp"

namespace sparrow
Expand All @@ -38,15 +40,16 @@ namespace sparrow
using value_type = typename base_type::value_type;
using size_type = typename base_type::size_type;

template<std::ranges::input_range R>
requires std::convertible_to<std::ranges::range_value_t<R>, value_type>
template <std::ranges::input_range R>
requires std::convertible_to<std::ranges::range_value_t<R>, value_type>
explicit dynamic_bitset(const R& r)
: dynamic_bitset(std::ranges::size(r), true)
{
std::size_t i = 0;
for(auto value : r)
for (auto value : r)
{
if(!value){
if (!value)
{
this->set(i, false);
}
i++;
Expand Down Expand Up @@ -109,25 +112,24 @@ namespace sparrow
{
}


using validity_bitmap = dynamic_bitset<std::uint8_t>;


namespace detail
{
using validity_bitmap = sparrow::validity_bitmap;
inline validity_bitmap ensure_validity_bitmap_impl(std::size_t size, const validity_bitmap & bitmap)

inline validity_bitmap ensure_validity_bitmap_impl(std::size_t size, const validity_bitmap& bitmap)
{
if(bitmap.size() == 0)
if (bitmap.size() == 0)
{
return validity_bitmap(size, true);
}
return bitmap; // copy
return bitmap; // copy
}
inline validity_bitmap ensure_validity_bitmap_impl(std::size_t size, validity_bitmap && bitmap)

inline validity_bitmap ensure_validity_bitmap_impl(std::size_t size, validity_bitmap&& bitmap)
{
if(bitmap.size() == 0)
if (bitmap.size() == 0)
{
bitmap.resize(size, true);
}
Expand All @@ -136,15 +138,16 @@ namespace sparrow

// range of booleans
template <std::ranges::input_range R>
requires(std::same_as<std::ranges::range_value_t<R>, bool>)
requires(std::same_as<std::ranges::range_value_t<R>, bool>)
validity_bitmap ensure_validity_bitmap_impl(std::size_t size, R&& range)
{
{
SPARROW_ASSERT_TRUE(size == range_size(range) || range_size(range) == 0);
validity_bitmap bitmap(size, true);
std::size_t i = 0;
for(auto value : range)
for (auto value : range)
{
if(!value){
if (!value)
{
bitmap.set(i, false);
}
i++;
Expand All @@ -154,33 +157,32 @@ namespace sparrow

// range of indices / integers (but not booleans)
template <std::ranges::input_range R>
requires(
std::unsigned_integral<std::ranges::range_value_t<R>> &&
!std::same_as<std::ranges::range_value_t<R>, bool> &&
!std::same_as<std::decay_t<R>, validity_bitmap>
)
requires(std::unsigned_integral<std::ranges::range_value_t<R>> && !std::same_as<std::ranges::range_value_t<R>, bool> && !std::same_as<std::decay_t<R>, validity_bitmap>)
validity_bitmap ensure_validity_bitmap_impl(std::size_t size, R&& range_of_indices)
{
{
validity_bitmap bitmap(size, true);
for(auto index : range_of_indices)
for (auto index : range_of_indices)
{
bitmap.set(index, false);
}
return bitmap;
}
} // namespace detail
} // namespace detail

template <class T>
concept validity_bitmap_input =
std::same_as<T, validity_bitmap> ||
std::same_as<T, const validity_bitmap&> ||
(std::ranges::input_range<T> && std::same_as<std::ranges::range_value_t<T>, bool>) ||
(std::ranges::input_range<T> && std::unsigned_integral<std::ranges::range_value_t<T>> );
concept validity_bitmap_input = (std::same_as<T, validity_bitmap> || std::same_as<T, const validity_bitmap&>
|| (std::ranges::input_range<T>
&& std::same_as<std::ranges::range_value_t<T>, bool>)
|| (std::ranges::input_range<T>
&& std::unsigned_integral<std::ranges::range_value_t<T>>) )
&& (!std::same_as<std::remove_cvref_t<T>, std::string>
&& !std::same_as<std::remove_cvref_t<T>, std::string_view>
&& !std::same_as<T, const char*>);

template <validity_bitmap_input R>
validity_bitmap ensure_validity_bitmap(std::size_t size, R&& validity_input)
{
return detail::ensure_validity_bitmap_impl(size, std::forward<R>(validity_input));
}
} // namespace sparrow

} // namespace sparrow
Loading
Loading