mrkn commented on a change in pull request #6302:
URL: https://github.com/apache/arrow/pull/6302#discussion_r559294691
##########
File path: cpp/src/arrow/ipc/test_common.cc
##########
@@ -1000,6 +1003,102 @@ Status MakeDictExtension(std::shared_ptr<RecordBatch>*
out) {
return Status::OK();
}
+namespace {
+
+template <typename CValueType, typename SeedType, typename DistributionType>
+void FillRandomData(CValueType* data, size_t n, CValueType min, CValueType max,
+ SeedType seed) {
+ std::default_random_engine rng(seed);
+ DistributionType dist(min, max);
+ std::generate(data, data + n,
+ [&dist, &rng] { return static_cast<CValueType>(dist(rng)); });
+}
+
+template <typename CValueType, typename SeedType>
+enable_if_t<std::is_integral<CValueType>::value &&
std::is_signed<CValueType>::value,
+ void>
+FillRandomData(CValueType* data, size_t n, SeedType seed) {
+ FillRandomData<CValueType, SeedType,
std::uniform_int_distribution<CValueType>>(
+ data, n, 0, 1000, seed);
+}
+
+template <typename CValueType, typename SeedType>
+enable_if_t<std::is_integral<CValueType>::value &&
std::is_unsigned<CValueType>::value,
+ void>
+FillRandomData(CValueType* data, size_t n, SeedType seed) {
+ FillRandomData<CValueType, SeedType,
std::uniform_int_distribution<CValueType>>(
+ data, n, -1000, 1000, seed);
Review comment:
This function is specialized for unsigned integer types by the
`enable_if_t` at line 1026.
The function for singed integer types is defined before this function.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]