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

variable_size_binary_layout inner ref #119

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions include/sparrow/data_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ namespace sparrow
{
static constexpr data_type type_id = data_type::STRING;
using value_type = std::string;
using default_layout = variable_size_binary_layout<value_type, std::string_view, const std::string_view>; // FIXME: this is incorrect, change when we have the right types
using default_layout = variable_size_binary_layout<value_type, const std::string_view>;
};

template <>
struct arrow_traits<std::vector<byte_t>>
{
static constexpr data_type type_id = data_type::STRING;
using value_type = std::vector<byte_t>;
using default_layout = variable_size_binary_layout<value_type, std::span<byte_t>, const std::span<byte_t>>; // FIXME: this is incorrect, change when we have the right types
using default_layout = variable_size_binary_layout<value_type, const std::span<byte_t>>;
};

template <>
Expand Down
41 changes: 33 additions & 8 deletions include/sparrow/dictionary_encoded_layout.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Man Group Operations Limited

Check notice on line 1 in include/sparrow/dictionary_encoded_layout.hpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on include/sparrow/dictionary_encoded_layout.hpp

File include/sparrow/dictionary_encoded_layout.hpp does not conform to Custom style guidelines. (lines 64, 82, 83, 84, 85, 101, 115, 261, 262, 263, 383, 436, 438, 444)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -221,7 +221,11 @@

private:

const indexes_layout& get_const_indexes_layout() const;
indexes_layout& get_indexes_layout();
const indexes_layout& get_indexes_layout() const;

sub_layout& get_sub_layout();
const sub_layout& get_sub_layout() const;

const_value_iterator value_cbegin() const;
const_value_iterator value_cend() const;
Expand Down Expand Up @@ -355,10 +359,10 @@
auto dictionary_encoded_layout<T, SL, OT>::operator[](size_type i) const -> const_reference
{
SPARROW_ASSERT_TRUE(i < size());
const auto index = (*m_indexes_layout)[i];
const auto index = get_indexes_layout()[i];
if (index.has_value())
{
return (*m_sub_layout)[index.value()];
return get_sub_layout()[index.value()];
}
else
{
Expand Down Expand Up @@ -391,34 +395,55 @@
return const_value_range(value_cbegin(), value_cend());
}

template <std::integral T, class SL, layout_offset OT>
typename dictionary_encoded_layout<T, SL, OT>::indexes_layout&
dictionary_encoded_layout<T, SL, OT>::get_indexes_layout()
{
return *(m_indexes_layout.get());
}

template <std::integral T, class SL, layout_offset OT>
const typename dictionary_encoded_layout<T, SL, OT>::indexes_layout&
dictionary_encoded_layout<T, SL, OT>::get_const_indexes_layout() const
dictionary_encoded_layout<T, SL, OT>::get_indexes_layout() const
{
return *const_cast<const indexes_layout*>(m_indexes_layout.get());
}

template <std::integral T, class SL, layout_offset OT>
typename dictionary_encoded_layout<T, SL, OT>::sub_layout&
dictionary_encoded_layout<T, SL, OT>::get_sub_layout()
{
return *(m_sub_layout.get());
}

template <std::integral T, class SL, layout_offset OT>
const typename dictionary_encoded_layout<T, SL, OT>::sub_layout&
dictionary_encoded_layout<T, SL, OT>::get_sub_layout() const
{
return *const_cast<const sub_layout*>(m_sub_layout.get());
}

template <std::integral T, class SL, layout_offset OT>
auto dictionary_encoded_layout<T, SL, OT>::value_cbegin() const -> const_value_iterator
{
return const_value_iterator(get_const_indexes_layout().cbegin(), *m_sub_layout);
return const_value_iterator(get_indexes_layout().cbegin(), *m_sub_layout);
}

template <std::integral T, class SL, layout_offset OT>
auto dictionary_encoded_layout<T, SL, OT>::value_cend() const -> const_value_iterator
{
return const_value_iterator(get_const_indexes_layout().cend(), *m_sub_layout);
return const_value_iterator(get_indexes_layout().cend(), *m_sub_layout);
}
template <std::integral T, class SL, layout_offset OT>
auto dictionary_encoded_layout<T, SL, OT>::bitmap_cbegin() const -> const_bitmap_iterator
{
return const_bitmap_iterator(get_const_indexes_layout().cbegin(), *m_sub_layout);
return const_bitmap_iterator(get_indexes_layout().cbegin(), get_sub_layout());
}

template <std::integral T, class SL, layout_offset OT>
auto dictionary_encoded_layout<T, SL, OT>::bitmap_cend() const -> const_bitmap_iterator
{
return const_bitmap_iterator(get_const_indexes_layout().cend(), *m_sub_layout);
return const_bitmap_iterator(get_indexes_layout().cend(), get_sub_layout());
}

template <std::integral T, class SL, layout_offset OT>
Expand Down
4 changes: 4 additions & 0 deletions include/sparrow/mp_utils.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Man Group Operations Limited

Check notice on line 1 in include/sparrow/mp_utils.hpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on include/sparrow/mp_utils.hpp

File include/sparrow/mp_utils.hpp does not conform to Custom style guidelines. (lines 359, 425)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -424,4 +424,8 @@
template <class T>
concept boolean_like = std::is_assignable_v<std::add_lvalue_reference_t<std::decay_t<T>>, bool> and
requires { static_cast<bool>(std::declval<T>()); };

/// Matches range types From whose elements are convertible to elements of range type To.
template <class From, class To>
concept convertible_ranges = std::convertible_to<std::ranges::range_value_t<From>, std::ranges::range_value_t<To>>;
}
Loading
Loading