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

Function GenerateNumericArray

cpp/src/arrow/testing/random.cc:176–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174
175template <typename ArrowType, typename OptionType>
176std::shared_ptr<NumericArray<ArrowType>> GenerateNumericArray(int64_t size,
177 OptionType options,
178 int64_t alignment,
179 MemoryPool* memory_pool) {
180 using CType = typename ArrowType::c_type;
181 auto type = TypeTraits<ArrowType>::type_singleton();
182 BufferVector buffers{2};
183
184 int64_t null_count = 0;
185 buffers[0] = *AllocateEmptyBitmap(size, alignment, memory_pool);
186 options.GenerateBitmap(buffers[0]->mutable_data(), size, &null_count);
187
188 buffers[1] = *AllocateBuffer(sizeof(CType) * size, alignment, memory_pool);
189 options.GenerateData(buffers[1]->mutable_data(), size);
190 if (std::is_same<ArrowType, Date64Type>::value) {
191 GenerateFullDayMillisNoNan(buffers[1]->mutable_data(), size);
192 }
193
194 auto array_data = ArrayData::Make(type, size, buffers, null_count);
195 return std::make_shared<NumericArray<ArrowType>>(array_data);
196}
197
198} // namespace
199

Callers

nothing calls this directly

Calls 8

AllocateEmptyBitmapFunction · 0.85
GenerateBitmapMethod · 0.80
type_singletonFunction · 0.50
AllocateBufferFunction · 0.50
MakeFunction · 0.50
mutable_dataMethod · 0.45
GenerateDataMethod · 0.45

Tested by

no test coverage detected