Skip to content

Commit a99b9a0

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

File tree

6 files changed

+128
-77
lines changed

6 files changed

+128
-77
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: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,22 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include <variant>
1615
#include "sparrow/layout/map_layout/map_value.hpp"
1716

17+
#include <variant>
18+
1819
#include "sparrow/layout/dispatch.hpp"
1920
#include "sparrow/layout/nested_value_types.hpp"
2021

2122
namespace sparrow
2223
{
23-
map_value::map_value(const array_wrapper* flat_keys, const array_wrapper* flat_items,
24-
size_type index_begin, size_type index_end, bool keys_sorted)
24+
map_value::map_value(
25+
const array_wrapper* flat_keys,
26+
const array_wrapper* flat_items,
27+
size_type index_begin,
28+
size_type index_end,
29+
bool keys_sorted
30+
)
2531
: p_flat_keys(flat_keys)
2632
, p_flat_items(flat_items)
2733
, m_index_begin(index_begin)
@@ -40,7 +46,7 @@ namespace sparrow
4046
return m_index_end - m_index_begin;
4147
}
4248

43-
auto map_value::operator[](const key_type& key) const -> const_mapped_reference
49+
auto map_value::operator[](const key_type& key) const -> const_mapped_reference
4450
{
4551
size_type index = find_index(key);
4652
if (index == m_index_end)
@@ -77,31 +83,41 @@ namespace sparrow
7783

7884
auto map_value::find_index(const key_type& key) const noexcept -> size_type
7985
{
80-
#if SPARROW_GCC_11_2_WORKAROUND
86+
#if SPARROW_GCC_11_2_WORKAROUND
8187
using variant_type = std::decay_t<decltype(key)>;
8288
using base_variant_type = variant_type::base_type;
8389
#endif
84-
return std::visit([this](const auto& k) {
85-
return visit([&k, this](const auto& ar) {
86-
for (size_type i = m_index_begin; i != m_index_end; ++i)
87-
{
88-
const auto& val = ar[i];
89-
using T = std::decay_t<decltype(k)>;
90-
using U = std::decay_t<decltype(val)>;
91-
if constexpr (std::same_as<T, U>)
90+
return std::visit(
91+
[this](const auto& k)
92+
{
93+
return visit(
94+
[&k, this](const auto& ar)
9295
{
93-
if (val == k)
96+
for (size_type i = m_index_begin; i != m_index_end; ++i)
9497
{
95-
return i;
98+
const auto& val = ar[i];
99+
using T = std::decay_t<decltype(k)>;
100+
using U = std::decay_t<decltype(val)>;
101+
if constexpr (std::same_as<T, U>)
102+
{
103+
if (val == k)
104+
{
105+
return i;
106+
}
107+
}
96108
}
97-
}
98-
}
99-
return m_index_end;
100-
}, *p_flat_keys);
109+
return m_index_end;
110+
},
111+
*p_flat_keys
112+
);
101113
#if SPARROW_GCC_11_2_WORKAROUND
102-
}, static_cast<const base_variant_type&>(key));
114+
},
115+
static_cast<const base_variant_type&>(key)
116+
);
103117
#else
104-
}, key);
118+
},
119+
key
120+
);
105121
#endif
106122
}
107123

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)