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

Function MakeBinaryArrayWithUniqueValues

cpp/src/arrow/ipc/test_common.cc:373–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371
372template <std::derived_from<ArrayBuilder> BuilderType>
373static Result<std::shared_ptr<Array>> MakeBinaryArrayWithUniqueValues(
374 BuilderType builder, int64_t length, bool include_nulls) {
375 if constexpr (std::is_base_of_v<BinaryViewBuilder, BuilderType>) {
376 // Try to emit several variadic buffers by choosing a small block size.
377 builder.SetBlockSize(512);
378 }
379 for (int64_t i = 0; i < length; ++i) {
380 if (include_nulls && (i % 7 == 0)) {
381 RETURN_NOT_OK(builder.AppendNull());
382 } else {
383 // Make sure that some strings are long enough to have non-inline binary views
384 const auto base = std::to_string(i);
385 std::string value;
386 for (int64_t j = 0; j < 3 * (i % 10); ++j) {
387 value += base;
388 }
389 RETURN_NOT_OK(builder.Append(value));
390 }
391 }
392 return builder.Finish();
393}
394
395Status MakeStringTypesRecordBatch(std::shared_ptr<RecordBatch>* out, bool with_nulls,
396 bool with_view_types) {

Callers

nothing calls this directly

Calls 4

to_stringFunction · 0.85
AppendNullMethod · 0.45
AppendMethod · 0.45
FinishMethod · 0.45

Tested by

no test coverage detected