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

Method Generate

cpp/src/arrow/testing/generator.h:332–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330 StepGenerator(T start, T step) : start_(start), step_(step) {}
331
332 Result<std::shared_ptr<Array>> Generate(int64_t num_rows) override {
333 TypedBufferBuilder<T> builder;
334 ARROW_RETURN_NOT_OK(builder.Reserve(num_rows));
335 T val = start_;
336 for (int64_t i = 0; i < num_rows; i++) {
337 builder.UnsafeAppend(val);
338 val += step_;
339 }
340 start_ = val;
341 ARROW_ASSIGN_OR_RAISE(auto buf, builder.Finish());
342 return MakeArray(ArrayData::Make(TypeTraits<ArrowType>::type_singleton(), num_rows,
343 {NULLPTR, std::move(buf)}, /*null_count=*/0));
344 }
345
346 std::shared_ptr<DataType> type() const override {
347 return TypeTraits<ArrowType>::type_singleton();

Callers

nothing calls this directly

Calls 5

MakeArrayFunction · 0.70
MakeFunction · 0.50
type_singletonFunction · 0.50
ReserveMethod · 0.45
UnsafeAppendMethod · 0.45

Tested by

no test coverage detected