/src/duckdb/src/function/scalar/nested_functions.cpp
Line | Count | Source |
1 | | #include "duckdb/function/scalar/nested_functions.hpp" |
2 | | |
3 | | namespace duckdb { |
4 | | |
5 | 0 | void MapUtil::ReinterpretMap(Vector &result, Vector &input, idx_t count) { |
6 | | // Copy the list size |
7 | 0 | const auto list_size = ListVector::GetListSize(input); |
8 | 0 | ListVector::SetListSize(result, list_size); |
9 | |
|
10 | 0 | UnifiedVectorFormat input_data; |
11 | 0 | input.ToUnifiedFormat(count, input_data); |
12 | | |
13 | | // Copy the list validity |
14 | 0 | FlatVector::SetValidity(result, input_data.validity); |
15 | | |
16 | | // Copy the struct validity |
17 | 0 | UnifiedVectorFormat input_struct_data; |
18 | 0 | ListVector::GetEntry(input).ToUnifiedFormat(list_size, input_struct_data); |
19 | 0 | auto &result_struct = ListVector::GetEntry(result); |
20 | 0 | FlatVector::SetValidity(result_struct, input_struct_data.validity); |
21 | | |
22 | | // Copy the list buffer (the list_entry_t data) |
23 | 0 | result.CopyBuffer(input); |
24 | |
|
25 | 0 | auto &input_keys = MapVector::GetKeys(input); |
26 | 0 | auto &result_keys = MapVector::GetKeys(result); |
27 | 0 | result_keys.Reference(input_keys); |
28 | |
|
29 | 0 | auto &input_values = MapVector::GetValues(input); |
30 | 0 | auto &result_values = MapVector::GetValues(result); |
31 | 0 | result_values.Reference(input_values); |
32 | |
|
33 | 0 | if (input.GetVectorType() == VectorType::DICTIONARY_VECTOR) { |
34 | 0 | result.Slice(*input_data.sel, count); |
35 | 0 | } |
36 | | |
37 | | // Set the right vector type |
38 | 0 | result.SetVectorType(input.GetVectorType()); |
39 | 0 | } |
40 | | |
41 | | } // namespace duckdb |