Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-PLACET committed Oct 16, 2024
1 parent bd1d621 commit c7d2e3e
Show file tree
Hide file tree
Showing 64 changed files with 1,049 additions and 929 deletions.
5 changes: 2 additions & 3 deletions include/sparrow/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ namespace sparrow
using size_type = std::size_t;
using value_type = array_traits::value_type;
using const_reference = array_traits::const_reference;

SPARROW_API array() = default;

SPARROW_API array(ArrowArray&& array, ArrowSchema&& schema);
SPARROW_API array(ArrowArray&& array, ArrowSchema* schema);
SPARROW_API array(ArrowArray* array, ArrowSchema* schema);

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

Expand All @@ -44,4 +44,3 @@ namespace sparrow
cloning_ptr<array_wrapper> p_array = nullptr;
};
}

2 changes: 1 addition & 1 deletion include/sparrow/array_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
namespace sparrow
{
SPARROW_API cloning_ptr<array_wrapper> array_factory(arrow_proxy proxy);

}
2 changes: 1 addition & 1 deletion include/sparrow/arrow_array_schema_proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace sparrow
* @param null_count The null count to set.
*/
SPARROW_API void set_null_count(int64_t null_count);
[[nodiscard]] SPARROW_API size_t offset() const;
[[nodiscard]] SPARROW_API size_t offset() const;

/**
* Set the offset of the `ArrowArray`.
Expand Down
1 change: 0 additions & 1 deletion include/sparrow/arrow_interface/arrow_array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "sparrow/c_interface.hpp"
#include "sparrow/config/config.hpp"


namespace sparrow
{
/**
Expand Down
5 changes: 2 additions & 3 deletions include/sparrow/arrow_interface/arrow_array/private_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace sparrow

[[nodiscard]] constexpr BufferType& buffers() noexcept;
[[nodiscard]] constexpr const BufferType& buffers() const noexcept;

constexpr void resize_buffers(std::size_t size);
void set_buffer(std::size_t index, buffer<std::uint8_t>&& buffer);
void set_buffer(std::size_t index, const buffer_view<std::uint8_t>& buffer);
Expand All @@ -62,8 +62,7 @@ namespace sparrow
{
}

[[nodiscard]] constexpr std::vector<buffer<std::uint8_t>>&
arrow_array_private_data::buffers() noexcept
[[nodiscard]] constexpr std::vector<buffer<std::uint8_t>>& arrow_array_private_data::buffers() noexcept
{
return m_buffers;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace sparrow
{
/// @returns `true` if the number of buffers in an `ArrowArray` for a given data type is valid, `false`
/// otherwise.
constexpr bool validate_buffers_count(data_type data_type, int64_t n_buffers)
constexpr bool validate_buffers_count(data_type data_type, int64_t n_buffers)
{
const std::size_t expected_buffer_count = get_expected_buffer_count(data_type);
return static_cast<std::size_t>(n_buffers) == expected_buffer_count;
Expand Down Expand Up @@ -74,16 +74,17 @@ namespace sparrow
}

/// @returns `true` if the format of an `ArrowArray` for a given data type is valid, `false` otherwise.
inline bool validate_format_with_arrow_array(data_type , const ArrowArray& )
inline bool validate_format_with_arrow_array(data_type, const ArrowArray&)
{
return true;
return true;
/* THE CODE BELOW MAKES WRONG ASSUMPTIONS AND NEEDS TO BE REFACTORED IN A SEPERATE PR*/
// const bool buffers_count_valid = validate_buffers_count(data_type, array.n_buffers);
// // const bool children_count_valid = static_cast<std::size_t>(array.n_children)
// // == get_expected_children_count(data_type);

// //std::cout<<"child cound: "<<array.n_children<<" expected: "<<get_expected_children_count(data_type)<<std::endl;
// return buffers_count_valid //&& children_count_valid;
// //std::cout<<"child cound: "<<array.n_children<<" expected:
// "<<get_expected_children_count(data_type)<<std::endl; return buffers_count_valid //&&
// children_count_valid;
}

enum class buffer_type : uint8_t
Expand All @@ -98,7 +99,6 @@ namespace sparrow
SIZES_64BIT,
};


/// @returns A vector of buffer types for a given data type.
/// This information helps how interpret and parse each buffer in an ArrowArray.
constexpr std::vector<buffer_type> get_buffer_types_from_data_type(data_type data_type)
Expand Down
6 changes: 3 additions & 3 deletions include/sparrow/arrow_interface/arrow_array_schema_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ namespace sparrow
{
/**
* Release the children and dictionnary of an `ArrowArray` or `ArrowSchema`.
*
*
* @tparam T `ArrowArray` or `ArrowSchema`
* @param t The `ArrowArray` or `ArrowSchema` to release.
*/
template <class T>
requires std::same_as<T, ArrowArray> || std::same_as<T, ArrowSchema>
requires std::same_as<T, ArrowArray> || std::same_as<T, ArrowSchema>
void release_common_arrow(T& t)
{
if (t.release == nullptr)
{
return;
}

if (t.dictionary)
{
if (t.dictionary->release)
Expand Down
2 changes: 0 additions & 2 deletions include/sparrow/arrow_interface/arrow_schema.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <cstdint>


#include "sparrow/arrow_interface/arrow_schema/private_data.hpp"
#include "sparrow/arrow_interface/arrow_schema/smart_pointers.hpp"
#include "sparrow/config/config.hpp"
Expand Down Expand Up @@ -108,7 +107,6 @@ namespace sparrow
*/
arrow_schema_unique_ptr default_arrow_schema_unique_ptr();


template <class F, class N, class M>
requires std::constructible_from<arrow_schema_private_data::FormatType, F>
&& std::constructible_from<arrow_schema_private_data::NameType, N>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ namespace sparrow
return *this;
};

inline arrow_schema_shared_ptr& arrow_schema_shared_ptr::operator=(const arrow_schema_shared_ptr& ptr) noexcept
inline arrow_schema_shared_ptr&
arrow_schema_shared_ptr::operator=(const arrow_schema_shared_ptr& ptr) noexcept
{
std::shared_ptr<ArrowSchema>::operator=(ptr);
return *this;
Expand Down
1 change: 0 additions & 1 deletion include/sparrow/buffer/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "sparrow/utils/variant_visitor.hpp"


namespace sparrow
{
/*
Expand Down
1 change: 0 additions & 1 deletion include/sparrow/buffer/buffer_adaptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "sparrow/utils/iterator.hpp"
#include "sparrow/utils/mp_utils.hpp"


namespace sparrow
{
template <typename FromBufferRef, typename T>
Expand Down
2 changes: 1 addition & 1 deletion include/sparrow/buffer/dynamic_bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

#pragma once

#include "sparrow/buffer/dynamic_bitset/dynamic_bitset.hpp"
#include "sparrow/buffer/dynamic_bitset/dynamic_bitset_view.hpp"
#include "sparrow/buffer/dynamic_bitset/non_owning_dynamic_bitset.hpp"
#include "sparrow/buffer/dynamic_bitset/dynamic_bitset.hpp"
2 changes: 1 addition & 1 deletion include/sparrow/buffer/dynamic_bitset/bitset_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

#pragma once

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

namespace sparrow
{
Expand Down
2 changes: 1 addition & 1 deletion include/sparrow/buffer/dynamic_bitset/dynamic_bitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#pragma once

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

namespace sparrow
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "sparrow/buffer/buffer_view.hpp"
#include "sparrow/buffer/dynamic_bitset/dynamic_bitset_base.hpp"


namespace sparrow
{
/**
Expand Down
16 changes: 8 additions & 8 deletions include/sparrow/config/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
#endif

#if defined(_WIN32)
# if defined(SPARROW_STATIC_LIB)
# define SPARROW_API
# elif defined(SPARROW_EXPORTS)
# define SPARROW_API __declspec(dllexport)
# else
# define SPARROW_API __declspec(dllimport)
# endif
# if defined(SPARROW_STATIC_LIB)
# define SPARROW_API
# elif defined(SPARROW_EXPORTS)
# define SPARROW_API __declspec(dllexport)
# else
# define SPARROW_API __declspec(dllimport)
# endif
#else
# define SPARROW_API __attribute__((visibility("default")))
# define SPARROW_API __attribute__((visibility("default")))
#endif

consteval bool is_apple_compiler()
Expand Down
15 changes: 6 additions & 9 deletions include/sparrow/layout/array_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include "sparrow/arrow_array_schema_proxy.hpp"
#include "sparrow/buffer/dynamic_bitset.hpp"
#include "sparrow/layout/layout_iterator.hpp"
#include "sparrow/utils/nullable.hpp"
#include "sparrow/utils/iterator.hpp"
#include "sparrow/utils/crtp_base.hpp"
#include "sparrow/utils/iterator.hpp"
#include "sparrow/utils/nullable.hpp"

namespace sparrow
{
Expand Down Expand Up @@ -54,6 +54,7 @@ namespace sparrow
class array_crtp_base : public crtp_base<D>
{
public:

using self_type = array_crtp_base<D>;
using derived_type = D;
using inner_types = array_inner_types<derived_type>;
Expand All @@ -78,7 +79,7 @@ namespace sparrow

using iterator = layout_iterator<self_type, false>;
using const_iterator = layout_iterator<self_type, true>;

using value_iterator = typename inner_types::value_iterator;
using const_value_iterator = typename inner_types::const_value_iterator;

Expand Down Expand Up @@ -155,10 +156,7 @@ namespace sparrow
auto array_crtp_base<D>::operator[](size_type i) -> reference
{
SPARROW_ASSERT_TRUE(i < this->derived_cast().size());
return reference(
inner_reference(this->derived_cast().value(i)),
this->derived_cast().has_value(i)
);
return reference(inner_reference(this->derived_cast().value(i)), this->derived_cast().has_value(i));
}

template <class D>
Expand Down Expand Up @@ -240,7 +238,7 @@ namespace sparrow
m_bitmap = make_bitmap();
return *this;
}

template <class D>
auto array_crtp_base<D>::storage() -> arrow_proxy&
{
Expand Down Expand Up @@ -291,7 +289,6 @@ namespace sparrow
return sparrow::next(bitmap_begin(), size());
}


template <class D>
auto array_crtp_base<D>::make_bitmap() -> bitmap_type
{
Expand Down
40 changes: 23 additions & 17 deletions include/sparrow/layout/array_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ namespace sparrow
{

namespace detail
{
// Helper struct to allow overloading on the type of ARRAY
// to get the data_type for an array. This is needed since
{
// Helper struct to allow overloading on the type of ARRAY
// to get the data_type for an array. This is needed since
// some arrays (for instance run_length_encoded_array)
// do not have a inner_value_type, therefore we specialize
// this in their respecitve headers.
template<class ARRAY>
template <class ARRAY>
struct get_data_type_from_array
{
constexpr static sparrow::data_type get()
static constexpr sparrow::data_type get()
{
return arrow_traits<typename ARRAY::inner_value_type>::type_id;
}
Expand All @@ -42,7 +42,7 @@ namespace sparrow
template <class ARRAY>
struct is_dictionary_encoded_array
{
constexpr static bool get()
static constexpr bool get()
{
return false;
}
Expand Down Expand Up @@ -94,7 +94,7 @@ namespace sparrow

T& get_wrapped();
const T& get_wrapped() const;

private:

using wrapper_ptr = array_wrapper::wrapper_ptr;
Expand Down Expand Up @@ -191,22 +191,29 @@ namespace sparrow
: array_wrapper(rhs)
, m_storage(rhs.m_storage)
{
p_array = std::visit([](auto&& arg)
{
using U = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<U, T*>)
return arg;
else
return arg.get();
}, m_storage);
p_array = std::visit(
[](auto&& arg)
{
using U = std::decay_t<decltype(arg)>;
if constexpr (std::is_same_v<U, T*>)
{
return arg;
}
else
{
return arg.get();
}
},
m_storage
);
}

template <class T>
bool array_wrapper_impl<T>::is_dictionary_impl() const
{
return detail::is_dictionary_encoded_array<T>::get();
}

template <class T>
auto array_wrapper_impl<T>::clone_impl() const -> wrapper_ptr
{
Expand All @@ -225,4 +232,3 @@ namespace sparrow
return static_cast<const array_wrapper_impl<T>&>(ar).get_wrapped();
}
}

Loading

0 comments on commit c7d2e3e

Please sign in to comment.