Skip to content

Commit 209f39b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f4d6875 commit 209f39b

File tree

6 files changed

+147
-86
lines changed

6 files changed

+147
-86
lines changed

include/sparrow/layout/map_layout/map_array.hpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ namespace sparrow
101101

102102
[[nodiscard]] inner_reference value(size_type i);
103103
[[nodiscard]] inner_const_reference value(size_type i) const;
104-
104+
105105
[[nodiscard]] offset_type* make_list_offsets() const;
106106
[[nodiscard]] cloning_ptr<array_wrapper> make_keys_array() const;
107107
[[nodiscard]] cloning_ptr<array_wrapper> make_items_array() const;
@@ -144,7 +144,7 @@ namespace sparrow
144144
);
145145
}
146146

147-
template <
147+
template <
148148
validity_bitmap_input VB = validity_bitmap,
149149
input_metadata_container METADATA_RANGE = std::vector<metadata_pair>>
150150
[[nodiscard]] static arrow_proxy create_proxy(
@@ -225,16 +225,17 @@ namespace sparrow
225225

226226
ArrowSchema schema = make_arrow_schema(
227227
std::string("+m"),
228-
name, // name
229-
metadata, // metadata
230-
flags, // flags,
231-
new ArrowSchema*[2]{ // Children
228+
name, // name
229+
metadata, // metadata
230+
flags, // flags,
231+
new ArrowSchema*[2]{
232+
// Children
232233
new ArrowSchema(std::move(flat_keys_schema)),
233234
new ArrowSchema(std::move(flat_items_schema))
234235
},
235-
children_ownership, // children ownership
236-
nullptr, // dictionary
237-
true // dictionary ownership
236+
children_ownership, // children ownership
237+
nullptr, // dictionary
238+
true // dictionary ownership
238239

239240
);
240241
std::vector<buffer<std::uint8_t>> arr_buffs = {
@@ -247,13 +248,10 @@ namespace sparrow
247248
static_cast<int64_t>(null_count),
248249
0, // offset
249250
std::move(arr_buffs),
250-
new ArrowArray*[2]{
251-
new ArrowArray(std::move(flat_keys_arr)),
252-
new ArrowArray(std::move(flat_items_arr))
253-
},
254-
children_ownership, // children ownership
255-
nullptr, // dictionary
256-
true // dictionary ownership
251+
new ArrowArray*[2]{new ArrowArray(std::move(flat_keys_arr)), new ArrowArray(std::move(flat_items_arr))},
252+
children_ownership, // children ownership
253+
nullptr, // dictionary
254+
true // dictionary ownership
257255
);
258256
return arrow_proxy{std::move(arr), std::move(schema)};
259257
}
@@ -287,17 +285,18 @@ namespace sparrow
287285
const repeat_view<bool> children_ownership{true, 2};
288286

289287
ArrowSchema schema = make_arrow_schema(
290-
std::string("+m"), // format
291-
name, // name
292-
metadata, // metadata
293-
std::nullopt, // flags,
294-
new ArrowSchema*[2]{ // Children
288+
std::string("+m"), // format
289+
name, // name
290+
metadata, // metadata
291+
std::nullopt, // flags,
292+
new ArrowSchema*[2]{
293+
// Children
295294
new ArrowSchema(std::move(flat_keys_schema)),
296295
new ArrowSchema(std::move(flat_items_schema))
297296
},
298-
children_ownership, // children ownership
299-
nullptr, // dictionary
300-
true // dictionary ownership
297+
children_ownership, // children ownership
298+
nullptr, // dictionary
299+
true // dictionary ownership
301300

302301
);
303302
std::vector<buffer<std::uint8_t>> arr_buffs = {
@@ -314,9 +313,9 @@ namespace sparrow
314313
new ArrowArray(std::move(flat_keys_arr)),
315314
new ArrowArray(std::move(flat_items_arr))
316315
},
317-
children_ownership, // children ownership
318-
nullptr, // dictionary
319-
true // dictionary ownership
316+
children_ownership, // children ownership
317+
nullptr, // dictionary
318+
true // dictionary ownership
320319
);
321320
return arrow_proxy{std::move(arr), std::move(schema)};
322321
}

include/sparrow/layout/map_layout/map_value.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ namespace sparrow
4040
using const_iterator = functor_index_iterator<functor_type>;
4141

4242
map_value() = default;
43-
map_value(const array_wrapper* flat_keys, const array_wrapper* flat_items,
44-
size_type index_begin, size_type index_end, bool keys_sorted);
43+
map_value(
44+
const array_wrapper* flat_keys,
45+
const array_wrapper* flat_items,
46+
size_type index_begin,
47+
size_type index_end,
48+
bool keys_sorted
49+
);
4550

4651
bool empty() const noexcept;
4752
size_type size() const noexcept;

src/layout/map_layout/map_array.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,22 @@ namespace sparrow
6767
return p_items_array.get();
6868
}
6969

70-
auto map_array::value_begin() -> value_iterator
70+
auto map_array::value_begin() -> value_iterator
7171
{
7272
return value_iterator(value_iterator::functor_type(this), 0);
7373
}
7474

75-
auto map_array::value_end() -> value_iterator
75+
auto map_array::value_end() -> value_iterator
7676
{
7777
return value_iterator(value_iterator::functor_type(this), this->size());
7878
}
7979

80-
auto map_array::value_cbegin() const -> const_value_iterator
80+
auto map_array::value_cbegin() const -> const_value_iterator
8181
{
8282
return const_value_iterator(const_value_iterator::functor_type(this), 0);
8383
}
8484

85-
auto map_array::value_cend() const -> const_value_iterator
85+
auto map_array::value_cend() const -> const_value_iterator
8686
{
8787
return const_value_iterator(const_value_iterator::functor_type(this), this->size());
8888
}
@@ -95,10 +95,9 @@ namespace sparrow
9595
auto map_array::value(size_type i) const -> inner_const_reference
9696
{
9797
using st = size_type;
98-
return map_value(raw_keys_array(), raw_items_array(), p_list_offsets[i], p_list_offsets[i+1],
99-
m_keys_sorted);
98+
return map_value(raw_keys_array(), raw_items_array(), p_list_offsets[i], p_list_offsets[i + 1], m_keys_sorted);
10099
}
101-
100+
102101
auto map_array::make_list_offsets() const -> offset_type*
103102
{
104103
return reinterpret_cast<offset_type*>(

src/layout/map_layout/map_value.cpp

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@
1919

2020
namespace sparrow
2121
{
22-
map_value::map_value(const array_wrapper* flat_keys, const array_wrapper* flat_items,
23-
size_type index_begin, size_type index_end, bool keys_sorted)
22+
map_value::map_value(
23+
const array_wrapper* flat_keys,
24+
const array_wrapper* flat_items,
25+
size_type index_begin,
26+
size_type index_end,
27+
bool keys_sorted
28+
)
2429
: p_flat_keys(flat_keys)
2530
, p_flat_items(flat_items)
2631
, m_index_begin(index_begin)
@@ -39,7 +44,7 @@ namespace sparrow
3944
return m_index_end - m_index_begin;
4045
}
4146

42-
auto map_value::operator[](const key_type& key) const -> const_mapped_reference
47+
auto map_value::operator[](const key_type& key) const -> const_mapped_reference
4348
{
4449
size_type index = find_index(key);
4550
if (index == m_index_end)
@@ -76,7 +81,7 @@ namespace sparrow
7681

7782
auto map_value::find_index(const key_type& key) const noexcept -> size_type
7883
{
79-
#if SPARROW_GCC_11_2_WORKAROUND
84+
#if SPARROW_GCC_11_2_WORKAROUND
8085
using T0 = sparrow::nullable<sparrow::null_type, bool>;
8186
using T1 = sparrow::nullable<bool, bool>;
8287
using T2 = sparrow::nullable<unsigned char, bool>;
@@ -90,23 +95,35 @@ namespace sparrow
9095
using T11 = sparrow::nullable<numeric::float16_t, bool>;
9196
using T12 = sparrow::nullable<float, bool>;
9297
using T13 = sparrow::nullable<double, bool>;
93-
using T14 = sparrow::nullable<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool>;
94-
using T15 = sparrow::nullable<std::vector<std::byte, std::allocator<std::byte> >, bool>;
95-
using T16 = sparrow::nullable<std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<int, std::ratio<86400, 1> > >, bool>;
96-
using T17 = sparrow::nullable<std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000> > >, bool>;
97-
using T18 = sparrow::nullable<date::zoned_time<std::chrono::duration<long int, std::ratio<1, 1> >, const date::time_zone*>, bool>;
98-
using T19 = sparrow::nullable<date::zoned_time<std::chrono::duration<long int, std::ratio<1, 1000> >, const date::time_zone*>, bool>;
99-
using T20 = sparrow::nullable<date::zoned_time<std::chrono::duration<long int, std::ratio<1, 1000000> >, const date::time_zone*>, bool>;
100-
using T21 = sparrow::nullable<date::zoned_time<std::chrono::duration<long int, std::ratio<1, 1000000000> >, const date::time_zone*>, bool>;
98+
using T14 = sparrow::nullable<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool>;
99+
using T15 = sparrow::nullable<std::vector<std::byte, std::allocator<std::byte>>, bool>;
100+
using T16 = sparrow::nullable<
101+
std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<int, std::ratio<86400, 1>>>,
102+
bool>;
103+
using T17 = sparrow::nullable<
104+
std::chrono::time_point<std::chrono::_V2::system_clock, std::chrono::duration<long int, std::ratio<1, 1000>>>,
105+
bool>;
106+
using T18 = sparrow::nullable<
107+
date::zoned_time<std::chrono::duration<long int, std::ratio<1, 1>>, const date::time_zone*>,
108+
bool>;
109+
using T19 = sparrow::nullable<
110+
date::zoned_time<std::chrono::duration<long int, std::ratio<1, 1000>>, const date::time_zone*>,
111+
bool>;
112+
using T20 = sparrow::nullable<
113+
date::zoned_time<std::chrono::duration<long int, std::ratio<1, 1000000>>, const date::time_zone*>,
114+
bool>;
115+
using T21 = sparrow::nullable<
116+
date::zoned_time<std::chrono::duration<long int, std::ratio<1, 1000000000>>, const date::time_zone*>,
117+
bool>;
101118
using T22 = sparrow::nullable<sparrow::zoned_time_without_timezone_seconds, bool>;
102119
using T23 = sparrow::nullable<sparrow::zoned_time_without_timezone_milliseconds, bool>;
103120
using T24 = sparrow::nullable<sparrow::zoned_time_without_timezone_microseconds, bool>;
104121
using T25 = sparrow::nullable<sparrow::zoned_time_without_timezone_nanoseconds, bool>;
105-
using T26 = sparrow::nullable<std::chrono::duration<long int, std::ratio<1, 1> >, bool>;
106-
using T27 = sparrow::nullable<std::chrono::duration<long int, std::ratio<1, 1000> >, bool>;
107-
using T28 = sparrow::nullable<std::chrono::duration<long int, std::ratio<1, 1000000> >, bool>;
108-
using T29 = sparrow::nullable<std::chrono::duration<long int, std::ratio<1, 1000000000> >, bool>;
109-
using T30 = sparrow::nullable<std::chrono::duration<int, std::ratio<2629746, 1> >, bool>;
122+
using T26 = sparrow::nullable<std::chrono::duration<long int, std::ratio<1, 1>>, bool>;
123+
using T27 = sparrow::nullable<std::chrono::duration<long int, std::ratio<1, 1000>>, bool>;
124+
using T28 = sparrow::nullable<std::chrono::duration<long int, std::ratio<1, 1000000>>, bool>;
125+
using T29 = sparrow::nullable<std::chrono::duration<long int, std::ratio<1, 1000000000>>, bool>;
126+
using T30 = sparrow::nullable<std::chrono::duration<int, std::ratio<2629746, 1>>, bool>;
110127
using T31 = sparrow::nullable<sparrow::days_time_interval, bool>;
111128
using T32 = sparrow::nullable<sparrow::month_day_nanoseconds_interval, bool>;
112129
using T33 = sparrow::nullable<sparrow::chrono::time_seconds, bool>;
@@ -166,24 +183,32 @@ namespace sparrow
166183
T43 t43;
167184
return size_type(0);
168185
#else
169-
return std::visit([this](const auto& k) {
170-
return visit([&k, this](const auto& ar) {
171-
for (size_type i = m_index_begin; i != m_index_end; ++i)
172-
{
173-
const auto& val = ar[i];
174-
using T = std::decay_t<decltype(k)>;
175-
using U = std::decay_t<decltype(val)>;
176-
if constexpr (std::same_as<T, U>)
186+
return std::visit(
187+
[this](const auto& k)
188+
{
189+
return visit(
190+
[&k, this](const auto& ar)
177191
{
178-
if (val == k)
192+
for (size_type i = m_index_begin; i != m_index_end; ++i)
179193
{
180-
return i;
194+
const auto& val = ar[i];
195+
using T = std::decay_t<decltype(k)>;
196+
using U = std::decay_t<decltype(val)>;
197+
if constexpr (std::same_as<T, U>)
198+
{
199+
if (val == k)
200+
{
201+
return i;
202+
}
203+
}
181204
}
182-
}
183-
}
184-
return m_index_end;
185-
}, *p_flat_keys);
186-
}, key);
205+
return m_index_end;
206+
},
207+
*p_flat_keys
208+
);
209+
},
210+
key
211+
);
187212
#endif
188213
}
189214

test/test_list_value.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
// limitations under the License.
1414

1515
#include "sparrow/layout/list_layout/list_value.hpp"
16-
#include "sparrow/layout/primitive_layout/primitive_array.hpp"
1716
#include "sparrow/layout/map_layout/map_value.hpp"
17+
#include "sparrow/layout/primitive_layout/primitive_array.hpp"
1818
#include "sparrow/layout/struct_layout/struct_value.hpp"
1919

2020
#include "../test/external_array_data_creation.hpp"

0 commit comments

Comments
 (0)