Skip to content

Commit

Permalink
Removed duplicated data_descriptor in array (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanMabille authored Jul 1, 2024
1 parent 40c8c6b commit b264e66
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions include/sparrow/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace sparrow

using const_iterator = array_iterator<true>;

array(data_descriptor dd, array_data data);
explicit array(array_data data);

bool empty() const;
size_type size() const;
Expand All @@ -123,9 +123,8 @@ namespace sparrow
private:

using array_variant = array_traits::array_variant;
array_variant build_array(const data_descriptor& d, array_data&& data) const;
array_variant build_array(array_data&& data) const;

data_descriptor m_data_descriptor;
array_variant m_array;
};

Expand Down Expand Up @@ -257,8 +256,9 @@ namespace sparrow
* array implementation *
************************/

inline auto array::build_array(const data_descriptor& dd, array_data&& data) const -> array_variant
inline auto array::build_array(array_data&& data) const -> array_variant
{
data_descriptor dd = data.type;
switch (dd.id())
{
case data_type::NA:
Expand Down Expand Up @@ -299,9 +299,8 @@ namespace sparrow
}
}

inline array::array(data_descriptor dd, array_data data)
: m_data_descriptor(std::move(dd))
, m_array(build_array(m_data_descriptor, std::move(data)))
inline array::array(array_data data)
: m_array(build_array(std::move(data)))
{
}

Expand Down
1 change: 1 addition & 0 deletions test/array_data_creation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ namespace sparrow::test
words.push_back(std::to_string(i));
}
sparrow::array_data ad;
ad.type = sparrow::data_descriptor(sparrow::arrow_traits<std::string>::type_id);
ad.bitmap.resize(n);
ad.buffers.resize(2);
ad.buffers[0].resize(sizeof(std::int64_t) * (n + 1));
Expand Down
3 changes: 1 addition & 2 deletions test/test_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ namespace
array make_test_array(std::size_t size = array_size, std::size_t off = offset)

Check warning on line 36 in test/test_array.cpp

View workflow job for this annotation

GitHub Actions / build

test/test_array.cpp:36:11 [modernize-use-trailing-return-type]

use a trailing return type for this function
{
auto ar_data = sparrow::test::make_test_array_data<T>(size, off);
auto data_desc = data_descriptor(arrow_type_id<T>());
return array(data_desc, std::move(ar_data));
return array(std::move(ar_data));
}
}

Expand Down

0 comments on commit b264e66

Please sign in to comment.