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

Method Boolean

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

Source from the content-addressed store, hash-verified

213}
214
215std::shared_ptr<Array> RandomArrayGenerator::Boolean(int64_t size,
216 double true_probability,
217 double null_probability,
218 int64_t alignment,
219 MemoryPool* memory_pool) {
220 // The boolean generator does not care about the value distribution since it
221 // only calls the GenerateBitmap method.
222 using GenOpt = GenerateOptions<int, std::uniform_int_distribution<int>>;
223
224 BufferVector buffers{2};
225 // Need 2 distinct generators such that probabilities are not shared.
226
227 // The "GenerateBitmap" function is written to generate validity bitmaps
228 // parameterized by the null probability, which is the probability of 0. For
229 // boolean data, the true probability is the probability of 1, so to use
230 // GenerateBitmap we must provide the probability of false instead.
231 GenOpt value_gen(seed(), 0, 1, 1 - true_probability);
232
233 GenOpt null_gen(seed(), 0, 1, null_probability);
234
235 int64_t null_count = 0;
236 buffers[0] = *AllocateEmptyBitmap(size, alignment, memory_pool);
237 null_gen.GenerateBitmap(buffers[0]->mutable_data(), size, &null_count);
238
239 buffers[1] = *AllocateEmptyBitmap(size, alignment, memory_pool);
240 value_gen.GenerateBitmap(buffers[1]->mutable_data(), size, nullptr);
241
242 auto array_data = ArrayData::Make(arrow::boolean(), size, buffers, null_count);
243 return std::make_shared<BooleanArray>(array_data);
244}
245
246#define PRIMITIVE_RAND_IMPL(Name, CType, ArrowType, Distribution) \
247 std::shared_ptr<Array> RandomArrayGenerator::Name( \

Callers 15

ArrayRangeEqualsBooleanFunction · 0.45
MakeBatchArraysFunction · 0.45
GenRandomRecordsFunction · 0.45
array_test.ccFile · 0.45
PrimitiveArrayMethod · 0.45
MakeRandomArrayMethod · 0.45
TEST_FFunction · 0.45
TESTFunction · 0.45
CreateRandomBitsBufferFunction · 0.45

Calls 5

seedFunction · 0.85
AllocateEmptyBitmapFunction · 0.85
GenerateBitmapMethod · 0.80
MakeFunction · 0.50
mutable_dataMethod · 0.45

Tested by 13

MakeBatchArraysFunction · 0.36
GenRandomRecordsFunction · 0.36
PrimitiveArrayMethod · 0.36
TEST_FFunction · 0.36
TESTFunction · 0.36
TEST_FFunction · 0.36
TESTFunction · 0.36
TestMethod · 0.36
TEST_PFunction · 0.36
TESTFunction · 0.36
GenerateInputDataMethod · 0.36