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

Method StringWithRepeats

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

Source from the content-addressed store, hash-verified

545}
546
547std::shared_ptr<Array> RandomArrayGenerator::StringWithRepeats(
548 int64_t size, int64_t unique, int32_t min_length, int32_t max_length,
549 double null_probability, int64_t alignment, MemoryPool* memory_pool) {
550 ARROW_CHECK_LE(unique, size);
551
552 // Generate a random string dictionary without any nulls
553 auto array = String(unique, min_length, max_length, /*null_probability=*/0);
554 auto dictionary = std::dynamic_pointer_cast<StringArray>(array);
555
556 // Generate random indices to sample the dictionary with
557 auto id_array = Int64(size, 0, unique - 1, null_probability);
558 auto indices = std::dynamic_pointer_cast<Int64Array>(id_array);
559 StringBuilder builder;
560
561 for (int64_t i = 0; i < size; ++i) {
562 if (indices->IsValid(i)) {
563 const auto index = indices->Value(i);
564 const auto value = dictionary->GetView(index);
565 ABORT_NOT_OK(builder.Append(value));
566 } else {
567 ABORT_NOT_OK(builder.AppendNull());
568 }
569 }
570
571 std::shared_ptr<Array> result;
572 ABORT_NOT_OK(builder.Finish(&result));
573 return result;
574}
575
576std::shared_ptr<Array> RandomArrayGenerator::FixedSizeBinary(
577 int64_t size, int32_t byte_width, double null_probability, uint8_t min_byte,

Callers 11

TEST_FFunction · 0.80
BatchesFunction · 0.80
TESTFunction · 0.80
TEST_PFunction · 0.80
GenerateTestDataMethod · 0.80
InitDataInputsMethod · 0.80
GenerateDataMethod · 0.80
TESTFunction · 0.80
AllColumnsWithEncodingsFunction · 0.80
RandomStringTableFunction · 0.80

Calls 7

StringClass · 0.85
IsValidMethod · 0.45
ValueMethod · 0.45
GetViewMethod · 0.45
AppendMethod · 0.45
AppendNullMethod · 0.45
FinishMethod · 0.45

Tested by 5

TEST_FFunction · 0.64
TESTFunction · 0.64
TEST_PFunction · 0.64
GenerateDataMethod · 0.64
TESTFunction · 0.64