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

Function ArrayFromVector

cpp/src/arrow/testing/builder.h:40–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39template <typename TYPE, typename C_TYPE = typename TYPE::c_type>
40void ArrayFromVector(const std::shared_ptr<DataType>& type,
41 const std::vector<bool>& is_valid, const std::vector<C_TYPE>& values,
42 std::shared_ptr<Array>* out) {
43 auto type_id = TYPE::type_id;
44 ASSERT_EQ(type_id, type->id())
45 << "template parameter and concrete DataType instance don't agree";
46
47 std::unique_ptr<ArrayBuilder> builder_ptr;
48 ASSERT_OK(MakeBuilder(default_memory_pool(), type, &builder_ptr));
49 // Get the concrete builder class to access its Append() specializations
50 auto& builder = dynamic_cast<typename TypeTraits<TYPE>::BuilderType&>(*builder_ptr);
51
52 for (size_t i = 0; i < values.size(); ++i) {
53 if (is_valid[i]) {
54 ASSERT_OK(builder.Append(values[i]));
55 } else {
56 ASSERT_OK(builder.AppendNull());
57 }
58 }
59 ASSERT_OK(builder.Finish(out));
60}
61
62template <typename TYPE, typename C_TYPE = typename TYPE::c_type>
63void ArrayFromVector(const std::shared_ptr<DataType>& type,

Callers

nothing calls this directly

Calls 8

default_memory_poolFunction · 0.85
MakeBuilderFunction · 0.50
type_singletonFunction · 0.50
idMethod · 0.45
sizeMethod · 0.45
AppendMethod · 0.45
AppendNullMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected