Skip to content

Commit

Permalink
Clang format all files
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-PLACET committed Apr 9, 2024
1 parent a0fef12 commit 2335ab3
Show file tree
Hide file tree
Showing 18 changed files with 208 additions and 271 deletions.
39 changes: 13 additions & 26 deletions include/sparrow/array_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ namespace sparrow
self_type& operator=(U&& value);

void swap(self_type& rhs);

private:

void reset();
Expand All @@ -205,34 +205,26 @@ namespace sparrow
* return reference proxies when it is dereferenced.
*/
template <class L, bool is_const>
class layout_iterator : public iterator_base
<
layout_iterator<L, is_const>,
mpl::constify_t<typename L::value_type, is_const>,
typename L::iterator_tag,
std::conditional_t<is_const, const_reference_proxy<L>, reference_proxy<L>>
>
class layout_iterator : public iterator_base<
layout_iterator<L, is_const>,
mpl::constify_t<typename L::value_type, is_const>,
typename L::iterator_tag,
std::conditional_t<is_const, const_reference_proxy<L>, reference_proxy<L>>>
{
public:

using self_type = layout_iterator<L, is_const>;
using base_type = iterator_base
<
using base_type = iterator_base<
self_type,
mpl::constify_t<typename L::value_type, is_const>,
typename L::iterator_tag,
std::conditional_t<is_const, const_reference_proxy<L>, reference_proxy<L>>
>;
std::conditional_t<is_const, const_reference_proxy<L>, reference_proxy<L>>>;
using reference = typename base_type::reference;
using difference_type = typename base_type::difference_type;

using value_iterator = std::conditional_t<
is_const, typename L::const_value_iterator, typename L::value_iterator
>;
using value_iterator = std::conditional_t<is_const, typename L::const_value_iterator, typename L::value_iterator>;

using bitmap_iterator = std::conditional_t<
is_const, typename L::const_bitmap_iterator, typename L::bitmap_iterator
>;
using bitmap_iterator = std::conditional_t<is_const, typename L::const_bitmap_iterator, typename L::bitmap_iterator>;

layout_iterator() noexcept = default;
layout_iterator(value_iterator value_iter, bitmap_iterator bitmap_iter);
Expand Down Expand Up @@ -275,7 +267,6 @@ namespace sparrow
const D1& dlhs = lhs.derived_cast();
const D2& drhs = rhs.derived_cast();
return (dlhs && drhs && (dlhs.value() == drhs.value())) || (!dlhs && !drhs);

}

template <class D, not_ref_proxy T>
Expand Down Expand Up @@ -400,15 +391,15 @@ namespace sparrow

template <class L>
template <std::convertible_to<typename L::inner_value_type> U>
auto reference_proxy<L>::operator=(const std::optional<U>& rhs) -> self_type&
auto reference_proxy<L>::operator=(const std::optional<U>& rhs) -> self_type&
{
update(rhs);
return *this;
}

template <class L>
template <std::convertible_to<typename L::inner_value_type> U>
auto reference_proxy<L>::operator=(std::optional<U>&& rhs) -> self_type&
auto reference_proxy<L>::operator=(std::optional<U>&& rhs) -> self_type&
{
update(std::move(rhs));
return *this;
Expand Down Expand Up @@ -487,10 +478,7 @@ namespace sparrow
**********************************/

template <class L, bool is_const>
layout_iterator<L, is_const>::layout_iterator(
value_iterator value_iter,
bitmap_iterator bitmap_iter
)
layout_iterator<L, is_const>::layout_iterator(value_iterator value_iter, bitmap_iterator bitmap_iter)
: m_value_iter(value_iter)
, m_bitmap_iter(bitmap_iter)
{
Expand Down Expand Up @@ -541,4 +529,3 @@ namespace sparrow
return m_value_iter < rhs.m_value_iter && m_bitmap_iter < rhs.m_bitmap_iter;
}
}

3 changes: 1 addition & 2 deletions include/sparrow/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include <concepts>
#include <cstdint>

#include "sparrow/mp_utils.hpp"
#include "sparrow/iterator.hpp"
#include "sparrow/mp_utils.hpp"

namespace sparrow
{
Expand Down Expand Up @@ -469,4 +469,3 @@ namespace sparrow
{
}
}

6 changes: 4 additions & 2 deletions include/sparrow/data_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ namespace sparrow
{
}

constexpr data_type id() const { return m_id; }
constexpr data_type id() const
{
return m_id;
}

private:

data_type m_id;
};
}

33 changes: 19 additions & 14 deletions include/sparrow/dictionary_encoded_layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
#pragma once

#include "sparrow/array_data.hpp"
#include "sparrow/iterator.hpp"
#include "sparrow/fixed_size_layout.hpp"
#include "sparrow/mp_utils.hpp"
#include "sparrow/iterator.hpp"
#include "sparrow/mp_utils.hpp"

namespace sparrow
{
Expand All @@ -41,25 +40,22 @@ namespace sparrow
public:

using self_type = dictionary_value_iterator<IL, SL, is_const>;
using base_type = iterator_base<
self_type,
typename SL::value_type,
std::random_access_iterator_tag,
typename SL::const_reference>;
using base_type = iterator_base<self_type, typename SL::value_type, std::random_access_iterator_tag, typename SL::const_reference>;
using reference = typename base_type::reference;
using difference_type = typename base_type::difference_type;

using index_iterator = std::conditional_t<is_const, typename IL::const_value_iterator, typename IL::value_iterator>;
using sub_layout = mpl::constify_t<SL, is_const>;
using sub_layout_reference = sub_layout&;

// `dictionary_value_iterator` needs to be default constructible
// to satisfy `dictionary_encoded_layout::const_value_range`'s
// constraints.
dictionary_value_iterator() noexcept = default;
dictionary_value_iterator(index_iterator index_it, sub_layout_reference sub_layout_reference);

private:

reference dereference() const;
void increment();
void decrement();
Expand Down Expand Up @@ -105,6 +101,7 @@ namespace sparrow
class dictionary_encoded_layout
{
public:

using self_type = dictionary_encoded_layout<IT, SL, OT>;
using index_type = IT;
using inner_value_type = SL::inner_value_type;
Expand Down Expand Up @@ -151,7 +148,7 @@ namespace sparrow
dictionary_encoded_layout& operator=(const dictionary_encoded_layout&) = delete;
dictionary_encoded_layout(dictionary_encoded_layout&&) = delete;
dictionary_encoded_layout& operator=(dictionary_encoded_layout&&) = delete;

size_type size() const;
const_reference operator[](size_type i) const;

Expand All @@ -162,6 +159,7 @@ namespace sparrow
const_value_range values() const;

private:

const indexes_layout& get_const_indexes_layout() const;

const_value_iterator value_cbegin() const;
Expand All @@ -176,7 +174,8 @@ namespace sparrow
std::unique_ptr<indexes_layout> m_indexes_layout;
std::unique_ptr<sub_layout> m_sub_layout;

static const const_reference& dummy_const_reference(){
static const const_reference& dummy_const_reference()
{
static const typename sub_layout::inner_value_type dummy_inner_value;
static const typename sub_layout::bitmap_type dummy_bitmap(1, false);
static const const_reference instance(dummy_inner_value, dummy_bitmap[0]);
Expand All @@ -192,7 +191,10 @@ namespace sparrow
*******************************************/

template <class L, class SL, bool is_const>
dictionary_value_iterator<L, SL, is_const>::dictionary_value_iterator(index_iterator index_it, sub_layout_reference sub_layout_reference)
dictionary_value_iterator<L, SL, is_const>::dictionary_value_iterator(
index_iterator index_it,
sub_layout_reference sub_layout_reference
)
: m_index_it(index_it)
, m_sub_layout_reference(sub_layout_reference)
{
Expand Down Expand Up @@ -264,10 +266,12 @@ namespace sparrow
{
assert(i < size());
const auto index = (*m_indexes_layout)[i];
if (index.has_value()) {
if (index.has_value())
{
return (*m_sub_layout)[index.value()];
}
else {
else
{
return dummy_const_reference();
}
}
Expand All @@ -279,7 +283,8 @@ namespace sparrow
}

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
const typename dictionary_encoded_layout<T, SL, OT>::indexes_layout&
dictionary_encoded_layout<T, SL, OT>::get_const_indexes_layout() const
{
return *const_cast<const indexes_layout*>(m_indexes_layout.get());
}
Expand Down
49 changes: 20 additions & 29 deletions include/sparrow/dynamic_bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ namespace sparrow
void assign(bool) noexcept;
void set() noexcept;
void reset() noexcept;

bitset_type& m_bitset;
block_type& m_block;
block_type m_mask;
Expand All @@ -248,24 +248,20 @@ namespace sparrow
* a const iterator.
*/
template <class B, bool is_const>
class bitset_iterator : public iterator_base
<
bitset_iterator<B, is_const>,
mpl::constify_t<typename B::value_type, is_const>,
std::random_access_iterator_tag,
std::conditional_t<is_const, bool, bitset_reference<B>>
>
class bitset_iterator : public iterator_base<
bitset_iterator<B, is_const>,
mpl::constify_t<typename B::value_type, is_const>,
std::random_access_iterator_tag,
std::conditional_t<is_const, bool, bitset_reference<B>>>
{
public:

using self_type = bitset_iterator<B, is_const>;
using base_type = iterator_base
<
using base_type = iterator_base<
self_type,
mpl::constify_t<typename B::value_type, is_const>,
std::contiguous_iterator_tag,
std::conditional_t<is_const, bool, bitset_reference<B>>
>;
std::conditional_t<is_const, bool, bitset_reference<B>>>;
using reference = typename base_type::reference;
using difference_type = typename base_type::difference_type;

Expand Down Expand Up @@ -297,7 +293,7 @@ namespace sparrow

friend class iterator_access;
};

/**************************************
* dynamic_bitset_base implementation *
**************************************/
Expand Down Expand Up @@ -439,8 +435,7 @@ namespace sparrow
template <random_access_range B>
auto dynamic_bitset_base<B>::compute_block_count(size_type bits_count) const noexcept -> size_type
{
return bits_count / s_bits_per_block
+ static_cast<size_type>(bits_count % s_bits_per_block != 0);
return bits_count / s_bits_per_block + static_cast<size_type>(bits_count % s_bits_per_block != 0);
}

template <random_access_range B>
Expand All @@ -465,12 +460,13 @@ namespace sparrow
auto dynamic_bitset_base<B>::count_non_null() const noexcept -> size_type
{
if (m_buffer.empty())
{
return 0u;
}

// Number of bits set to 1 in i for i from 0 to 255.
// This can be seen as a mapping "uint8_t -> number of non null bits"
static constexpr unsigned char table[] =
{
static constexpr unsigned char table[] = {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
Expand All @@ -491,8 +487,6 @@ namespace sparrow
return res;
}



template <random_access_range B>
auto dynamic_bitset_base<B>::count_extra_bits() const noexcept -> size_type
{
Expand All @@ -516,7 +510,7 @@ namespace sparrow
{
--m_null_count;
}
else if(!new_value && old_value)
else if (!new_value && old_value)
{
++m_null_count;
}
Expand Down Expand Up @@ -566,10 +560,7 @@ namespace sparrow

template <std::integral T>
dynamic_bitset<T>::dynamic_bitset(size_type n, value_type value)
: base_type(
storage_type(this->compute_block_count(n), value ? ~block_type(0) : 0),
n,
value ? 0u : n)
: base_type(storage_type(this->compute_block_count(n), value ? ~block_type(0) : 0), n, value ? 0u : n)
{
}

Expand Down Expand Up @@ -631,7 +622,7 @@ namespace sparrow
}
return *this;
}

template <class B>
auto bitset_reference<B>::operator|=(bool rhs) noexcept -> self_type&
{
Expand All @@ -641,7 +632,7 @@ namespace sparrow
}
return *this;
}

template <class B>
auto bitset_reference<B>::operator^=(bool rhs) noexcept -> self_type&
{
Expand Down Expand Up @@ -708,7 +699,7 @@ namespace sparrow
{
assert(m_index < bitset_type::s_bits_per_block);
}

template <class B, bool is_const>
auto bitset_iterator<B, is_const>::dereference() const -> reference
{
Expand Down Expand Up @@ -763,7 +754,7 @@ namespace sparrow
else
{
size_type to_next_block = bitset_type::s_bits_per_block - m_index;
n -= to_next_block;
n -= to_next_block;
size_type block_n = n / bitset_type::s_bits_per_block;
p_block += block_n + 1;
n -= block_n * bitset_type::s_bits_per_block;
Expand Down
Loading

0 comments on commit 2335ab3

Please sign in to comment.