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

Function Numeric

cpp/src/arrow/testing/random.h:256–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254
255 template <typename ArrowType, typename CType = typename ArrowType::c_type>
256 std::shared_ptr<Array> Numeric(int64_t size, CType min, CType max,
257 double null_probability = 0,
258 int64_t alignment = kDefaultBufferAlignment,
259 MemoryPool* memory_pool = default_memory_pool()) {
260 switch (ArrowType::type_id) {
261 case Type::UINT8:
262 return UInt8(size, static_cast<uint8_t>(min), static_cast<uint8_t>(max),
263 null_probability, alignment, memory_pool);
264 case Type::INT8:
265 return Int8(size, static_cast<int8_t>(min), static_cast<int8_t>(max),
266 null_probability, alignment, memory_pool);
267 case Type::UINT16:
268 return UInt16(size, static_cast<uint16_t>(min), static_cast<uint16_t>(max),
269 null_probability, alignment, memory_pool);
270 case Type::INT16:
271 return Int16(size, static_cast<int16_t>(min), static_cast<int16_t>(max),
272 null_probability, alignment, memory_pool);
273 case Type::UINT32:
274 return UInt32(size, static_cast<uint32_t>(min), static_cast<uint32_t>(max),
275 null_probability, alignment, memory_pool);
276 case Type::INT32:
277 return Int32(size, static_cast<int32_t>(min), static_cast<int32_t>(max),
278 null_probability, alignment, memory_pool);
279 case Type::UINT64:
280 return UInt64(size, static_cast<uint64_t>(min), static_cast<uint64_t>(max),
281 null_probability, alignment, memory_pool);
282 case Type::INT64:
283 return Int64(size, static_cast<int64_t>(min), static_cast<int64_t>(max),
284 null_probability, alignment, memory_pool);
285 case Type::HALF_FLOAT:
286 return Float16(size, util::Float16::FromBits(static_cast<uint16_t>(min)),
287 util::Float16::FromBits(static_cast<uint16_t>(max)),
288 null_probability, /*nan_probability=*/0, alignment, memory_pool);
289 case Type::FLOAT:
290 return Float32(size, static_cast<float>(min), static_cast<float>(max),
291 null_probability, /*nan_probability=*/0, alignment, memory_pool);
292 case Type::DOUBLE:
293 return Float64(size, static_cast<double>(min), static_cast<double>(max),
294 null_probability, /*nan_probability=*/0, alignment, memory_pool);
295 case Type::DATE64:
296 return Date64(size, static_cast<int64_t>(min), static_cast<int64_t>(max),
297 null_probability, alignment, memory_pool);
298 default:
299 return nullptr;
300 }
301 }
302
303 /// \brief Generate a random Decimal32Array
304 ///

Callers

nothing calls this directly

Calls 4

default_memory_poolFunction · 0.85
FromBitsFunction · 0.85
Date64Class · 0.85
Float16Function · 0.50

Tested by

no test coverage detected