MCPcopy Create free account
hub / github.com/apache/arrow / MakeEmptyListsArray

Function MakeEmptyListsArray

cpp/src/parquet/arrow/test_util.h:420–442  ·  view source on GitHub ↗

Make an array containing only empty lists, with a null values array

Source from the content-addressed store, hash-verified

418
419// Make an array containing only empty lists, with a null values array
420Status MakeEmptyListsArray(int64_t size, std::shared_ptr<Array>* out_array) {
421 // Allocate an offsets buffer containing only zeroes
422 const int64_t offsets_nbytes = (size + 1) * sizeof(int32_t);
423 ARROW_ASSIGN_OR_RAISE(auto offsets_buffer, ::arrow::AllocateBuffer(offsets_nbytes));
424 memset(offsets_buffer->mutable_data(), 0, offsets_nbytes);
425
426 auto value_field =
427 ::arrow::field("item", ::arrow::float64(), false /* nullable_values */);
428 auto list_type = ::arrow::list(value_field);
429
430 std::vector<std::shared_ptr<Buffer>> child_buffers = {nullptr /* null bitmap */,
431 nullptr /* values */};
432 auto child_data =
433 ::arrow::ArrayData::Make(value_field->type(), 0, std::move(child_buffers));
434
435 std::vector<std::shared_ptr<Buffer>> buffers = {nullptr /* bitmap */,
436 std::move(offsets_buffer)};
437 auto array_data = ::arrow::ArrayData::Make(list_type, size, std::move(buffers));
438 array_data->child_data.push_back(child_data);
439
440 *out_array = ::arrow::MakeArray(array_data);
441 return Status::OK();
442}
443
444std::shared_ptr<::arrow::Table> MakeSimpleTable(
445 const std::shared_ptr<ChunkedArray>& values, bool nullable) {

Callers 1

Calls 8

listFunction · 0.85
push_backMethod · 0.80
fieldFunction · 0.70
MakeFunction · 0.50
MakeArrayFunction · 0.50
OKFunction · 0.50
mutable_dataMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected