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::ArrowVarcharToStringViewData Struct 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()

static void duckdb::ArrowVarcharToStringViewData::Initialize ( ArrowAppendData result,
const LogicalType type,
idx_t  capacity 
)
inlinestatic
34042 {
34043 result.GetMainBuffer().reserve((capacity) * sizeof(arrow_string_view_t));
34044 result.GetAuxBuffer().reserve(capacity);
34045 result.GetBufferSizeBuffer().reserve(sizeof(int64_t));
34046 }
::int64_t int64_t

◆ Append()

static void duckdb::ArrowVarcharToStringViewData::Append ( ArrowAppendData append_data,
Vector input,
idx_t  from,
idx_t  to,
idx_t  input_size 
)
inlinestatic
34048 {
34049 idx_t size = to - from;
34050 UnifiedVectorFormat format;
34051 input.ToUnifiedFormat(input_size, format);
34052 auto &main_buffer = append_data.GetMainBuffer();
34053 auto &validity_buffer = append_data.GetValidityBuffer();
34054 auto &aux_buffer = append_data.GetAuxBuffer();
34055 // resize the validity mask and set up the validity buffer for iteration
34056 ArrowAppendData::ResizeValidity(validity_buffer, append_data.row_count + size);
34057 auto validity_data = (uint8_t *)validity_buffer.data();
34058
34059 main_buffer.resize(main_buffer.size() + sizeof(arrow_string_view_t) * (size));
34060 // resize the offset buffer - the offset buffer holds the offsets into the child array
34061 auto data = UnifiedVectorFormat::GetData<string_t>(format);
34062 for (idx_t i = from; i < to; i++) {
34063 auto result_idx = append_data.row_count + i - from;
34064 auto arrow_data = main_buffer.GetData<arrow_string_view_t>();
34065 auto source_idx = format.sel->get_index(i);
34066 if (!format.validity.RowIsValid(source_idx)) {
34067 // Null value
34068 uint8_t current_bit;
34069 idx_t current_byte;
34070 ArrowAppendData::GetBitPosition(result_idx, current_byte, current_bit);
34071 append_data.SetNull(validity_data, current_byte, current_bit);
34072 // We have to set these bytes to 0, for some reason
34073 arrow_data[result_idx] = arrow_string_view_t(0, "");
34074 continue;
34075 }
34076 // These two are now the same buffer
34077 idx_t string_length = ArrowVarcharConverter::GetLength(data[source_idx]);
34078 auto string_data = data[source_idx].GetData();
34079 if (string_length <= ArrowStringViewConstants::MAX_INLINED_BYTES) {
34080 // This string is inlined
34081 // | Bytes 0-3 | Bytes 4-15 |
34082 // |------------|---------------------------------------|
34083 // | length | data (padded with 0) |
34084 arrow_data[result_idx] = arrow_string_view_t(UnsafeNumericCast<int32_t>(string_length), string_data);
34085 } else {
34086 // This string is not inlined, we have to check a different buffer and offsets
34087 // | Bytes 0-3 | Bytes 4-7 | Bytes 8-11 | Bytes 12-15 |
34088 // |------------|------------|------------|-------------|
34089 // | length | prefix | buf. index | offset |
34090 arrow_data[result_idx] = arrow_string_view_t(UnsafeNumericCast<int32_t>(string_length), string_data, 0,
34091 UnsafeNumericCast<int32_t>(append_data.offset));
34092 auto current_offset = append_data.offset + string_length;
34093 aux_buffer.resize(current_offset);
34094 ArrowVarcharConverter::WriteData(aux_buffer.data() + append_data.offset, data[source_idx]);
34095 append_data.offset = current_offset;
34096 }
34097 }
34098 append_data.row_count += size;
34099 }
GOpaque< Size > size(const GMat &src)
::uint8_t uint8_t

◆ Finalize()

static void duckdb::ArrowVarcharToStringViewData::Finalize ( ArrowAppendData append_data,
const LogicalType type,
ArrowArray result 
)
inlinestatic
34101 {
34102 // We output four buffers
34103 result->n_buffers = 4;
34104 // Buffer 0 is the validity mask
34105 // Buffer 1 is our string views (short/long strings)
34106 result->buffers[1] = append_data.GetMainBuffer().data();
34107 // Buffer 2 is our only data buffer, could theoretically be more [ buffers ]
34108 result->buffers[2] = append_data.GetAuxBuffer().data();
34109 // Buffer 3 is the data-buffer lengths buffer, and we also populate it in to finalize
34110 reinterpret_cast<int64_t *>(append_data.GetBufferSizeBuffer().data())[0] =
34111 UnsafeNumericCast<int64_t>(append_data.offset);
34112 result->buffers[3] = append_data.GetBufferSizeBuffer().data();
34113 }

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