MCPcopy Create free account
hub / github.com/alibaba/zvec / fill_doc_sparse_vector

Function fill_doc_sparse_vector

src/db/sqlengine/sqlengine_impl.cc:370–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368
369template <typename VectorType>
370Status fill_doc_sparse_vector(const arrow::StructArray *typed_arr,
371 const std::string &field_name,
372 DocPtrList::iterator doc_it) {
373 auto *indices = (const arrow::BinaryArray *)typed_arr->field(0).get();
374 auto *values = (const arrow::BinaryArray *)typed_arr->field(1).get();
375 bool has_null = typed_arr->null_count() > 0;
376 for (int64_t i = 0; i < typed_arr->length(); ++i, ++doc_it) {
377 if (has_null && typed_arr->IsNull(i)) {
378 continue;
379 }
380 auto indice_data = indices->GetView(i);
381 auto value_data = values->GetView(i);
382 uint32_t count = indice_data.size() / sizeof(uint32_t);
383 if (count != value_data.size() / sizeof(VectorType)) {
384 return Status::InvalidArgument(
385 "Sparse vector indices and values size mismatch [", field_name,
386 "]: indices count=", count,
387 " vs values count=", value_data.size() / sizeof(VectorType));
388 }
389 (*doc_it)->set(
390 field_name,
391 std::make_pair(to_vector<uint32_t>(indice_data.data(), count),
392 to_vector<VectorType>(value_data.data(), count)));
393 }
394 return Status::OK();
395}
396
397template <typename VectorType>
398Status fill_doc_vector(const arrow::BinaryArray *typed_arr,

Callers

nothing calls this directly

Calls 8

InvalidArgumentFunction · 0.85
OKFunction · 0.85
lengthMethod · 0.80
getMethod · 0.45
fieldMethod · 0.45
sizeMethod · 0.45
setMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected