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

Function MakeRandomBooleanArray

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

Source from the content-addressed store, hash-verified

246}
247
248Status MakeRandomBooleanArray(const int length, bool include_nulls,
249 std::shared_ptr<Array>* out) {
250 std::vector<uint8_t> values(length);
251 random_null_bytes(length, 0.5, values.data());
252 ARROW_ASSIGN_OR_RAISE(auto data, arrow::internal::BytesToBits(values));
253
254 if (include_nulls) {
255 std::vector<uint8_t> valid_bytes(length);
256 ARROW_ASSIGN_OR_RAISE(auto null_bitmap, arrow::internal::BytesToBits(valid_bytes));
257 random_null_bytes(length, 0.1, valid_bytes.data());
258 *out = std::make_shared<BooleanArray>(length, data, null_bitmap, -1);
259 } else {
260 *out = std::make_shared<BooleanArray>(length, data, NULLPTR, 0);
261 }
262 return Status::OK();
263}
264
265Status MakeBooleanBatchSized(const int length, std::shared_ptr<RecordBatch>* out) {
266 // Make the schema

Callers 3

MakeBooleanBatchSizedFunction · 0.85
TEST_FFunction · 0.85

Calls 3

random_null_bytesFunction · 0.85
OKFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected