mapleFU commented on PR #14341:
URL: https://github.com/apache/arrow/pull/14341#issuecomment-1550607525
@rok I've written a bit ugly random string generator:
```C++
std::shared_ptr<::arrow::Array> generateShareSeqString(
::arrow::random::RandomArrayGenerator& gen, size_t seqNum, double
nullPercent) {
::arrow::StringBuilder builder;
auto seed = gen.seed();
std::shared_ptr<::arrow::Buffer> nullBitMap = nullptr;
if (nullPercent != 0) {
nullBitMap = gen.NullBitmap(seqNum, nullPercent);
}
std::mt19937 engine(seed);
std::uniform_int_distribution<int32_t> igen;
std::string s = "share-seq-string";
std::string prefix = s;
for (size_t i = 0; i < seqNum; ++i) {
if (nullBitMap != nullptr &&
::arrow::bit_util::GetBit(nullBitMap->data(), i)) {
PARQUET_THROW_NOT_OK(builder.AppendNull());
} else {
PARQUET_THROW_NOT_OK(builder.Append(s));
int length = igen(engine) % 4 + 1; // random string length between 1
and 4
std::string randomStr;
for (int j = 0; j < length; j++) {
char c = 'a' + igen(engine) % 26; // random lowercase letter
s += c;
}
s = prefix + randomStr;
if (igen(engine) % 2 == 0) { // randomly change prefix
prefix = s.substr(0, igen(engine) % s.length());
}
}
}
PARQUET_ASSIGN_OR_THROW(auto array, builder.Finish());
if (static_cast<size_t>(array->length()) != seqNum) {
throw ParquetException("Error");
}
return array;
}
```
Maybe you can change a bit and use it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]