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

Method StringWithRepeats

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

Source from the content-addressed store, hash-verified

554}
555
556std::shared_ptr<Array> RandomArrayGenerator::StringWithRepeats(
557 int64_t size, int64_t unique, int32_t min_length, int32_t max_length,
558 double null_probability, int64_t alignment, MemoryPool* memory_pool) {
559 ARROW_CHECK_LE(unique, size);
560
561 // Generate a random string dictionary without any nulls
562 auto array = String(unique, min_length, max_length, /*null_probability=*/0);
563 auto dictionary = std::dynamic_pointer_cast<StringArray>(array);
564
565 // Generate random indices to sample the dictionary with
566 auto id_array = Int64(size, 0, unique - 1, null_probability);
567 auto indices = std::dynamic_pointer_cast<Int64Array>(id_array);
568 StringBuilder builder;
569
570 for (int64_t i = 0; i < size; ++i) {
571 if (indices->IsValid(i)) {
572 const auto index = indices->Value(i);
573 const auto value = dictionary->GetView(index);
574 ABORT_NOT_OK(builder.Append(value));
575 } else {
576 ABORT_NOT_OK(builder.AppendNull());
577 }
578 }
579
580 std::shared_ptr<Array> result;
581 ABORT_NOT_OK(builder.Finish(&result));
582 return result;
583}
584
585std::shared_ptr<Array> RandomArrayGenerator::FixedSizeBinary(
586 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