Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::ArrowMapData< BUFTYPE > Struct Template Reference

Static Public Member Functions

static void Initialize (ArrowAppendData &result, const LogicalType &type, idx_t capacity)
 
static void Append (ArrowAppendData &append_data, Vector &input, idx_t from, idx_t to, idx_t input_size)
 
static void Finalize (ArrowAppendData &append_data, const LogicalType &type, ArrowArray *result)
 

Member Function Documentation

◆ Initialize()

template<class BUFTYPE = int64_t>
static void duckdb::ArrowMapData< BUFTYPE >::Initialize ( ArrowAppendData result,
const LogicalType type,
idx_t  capacity 
)
inlinestatic
33741 {
33742 // map types are stored in a (too) clever way
33743 // the main buffer holds the null values and the offsets
33744 // then we have a single child, which is a struct of the map_type, and the key_type
33745 result.GetMainBuffer().reserve((capacity + 1) * sizeof(BUFTYPE));
33746
33747 auto &key_type = MapType::KeyType(type);
33748 auto &value_type = MapType::ValueType(type);
33749 auto internal_struct = make_uniq<ArrowAppendData>(result.options);
33750 internal_struct->child_data.push_back(ArrowAppender::InitializeChild(key_type, capacity, result.options));
33751 internal_struct->child_data.push_back(ArrowAppender::InitializeChild(value_type, capacity, result.options));
33752
33753 result.child_data.push_back(std::move(internal_struct));
33754 }
R value_type

◆ Append()

template<class BUFTYPE = int64_t>
static void duckdb::ArrowMapData< BUFTYPE >::Append ( ArrowAppendData append_data,
Vector input,
idx_t  from,
idx_t  to,
idx_t  input_size 
)
inlinestatic
33756 {
33757 UnifiedVectorFormat format;
33758 input.ToUnifiedFormat(input_size, format);
33759 idx_t size = to - from;
33760 append_data.AppendValidity(format, from, to);
33761 vector<sel_t> child_indices;
33762 ArrowListData<BUFTYPE>::AppendOffsets(append_data, format, from, to, child_indices);
33763
33764 SelectionVector child_sel(child_indices.data());
33765 auto &key_vector = MapVector::GetKeys(input);
33766 auto &value_vector = MapVector::GetValues(input);
33767 auto list_size = child_indices.size();
33768
33769 auto &struct_data = *append_data.child_data[0];
33770 auto &key_data = *struct_data.child_data[0];
33771 auto &value_data = *struct_data.child_data[1];
33772
33773 Vector key_vector_copy(key_vector.GetType());
33774 key_vector_copy.Slice(key_vector, child_sel, list_size);
33775 Vector value_vector_copy(value_vector.GetType());
33776 value_vector_copy.Slice(value_vector, child_sel, list_size);
33777 key_data.append_vector(key_data, key_vector_copy, 0, list_size, list_size);
33778 value_data.append_vector(value_data, value_vector_copy, 0, list_size, list_size);
33779
33780 append_data.row_count += size;
33781 struct_data.row_count += size;
33782 }
GOpaque< Size > size(const GMat &src)

◆ Finalize()

template<class BUFTYPE = int64_t>
static void duckdb::ArrowMapData< BUFTYPE >::Finalize ( ArrowAppendData append_data,
const LogicalType type,
ArrowArray result 
)
inlinestatic
33784 {
33785 // set up the main map buffer
33786 D_ASSERT(result);
33787 result->n_buffers = 2;
33788 result->buffers[1] = append_data.GetMainBuffer().data();
33789
33790 // the main map buffer has a single child: a struct
33791 ArrowAppender::AddChildren(append_data, 1);
33792 result->children = append_data.child_pointers.data();
33793 result->n_children = 1;
33794
33795 auto &struct_data = *append_data.child_data[0];
33796 auto struct_result = ArrowAppender::FinalizeChild(type, std::move(append_data.child_data[0]));
33797
33798 // Initialize the struct array data
33799 const auto struct_child_count = 2;
33800 ArrowAppender::AddChildren(struct_data, struct_child_count);
33801 struct_result->children = struct_data.child_pointers.data();
33802 struct_result->n_buffers = 1;
33803 struct_result->n_children = struct_child_count;
33804 struct_result->length = NumericCast<int64_t>(struct_data.child_data[0]->row_count);
33805
33806 append_data.child_arrays[0] = *struct_result;
33807
33808 D_ASSERT(struct_data.child_data[0]->row_count == struct_data.child_data[1]->row_count);
33809
33810 auto &key_type = MapType::KeyType(type);
33811 auto &value_type = MapType::ValueType(type);
33812 auto key_data = ArrowAppender::FinalizeChild(key_type, std::move(struct_data.child_data[0]));
33813 struct_data.child_arrays[0] = *key_data;
33814 struct_data.child_arrays[1] = *ArrowAppender::FinalizeChild(value_type, std::move(struct_data.child_data[1]));
33815
33816 // keys cannot have null values
33817 if (key_data->null_count > 0) {
33818 throw std::runtime_error("Arrow doesn't accept NULL keys on Maps");
33819 }
33820 }

The documentation for this struct was generated from the following file: