emkornfield commented on a change in pull request #10177: URL: https://github.com/apache/arrow/pull/10177#discussion_r689931835
########## File path: cpp/src/arrow/testing/random.h ########## @@ -454,6 +454,37 @@ std::shared_ptr<arrow::Array> GenerateArray(const Field& field, int64_t size, // Assorted functions // +inline void rand_day_millis(int64_t N, + std::vector<DayTimeIntervalType::DayMilliseconds>* out) { + const int random_seed = 0; + std::default_random_engine gen(random_seed); + std::uniform_int_distribution<int32_t> d(std::numeric_limits<int32_t>::min(), + std::numeric_limits<int32_t>::max()); + out->resize(N, {}); + std::generate(out->begin(), out->end(), [&d, &gen] { + DayTimeIntervalType::DayMilliseconds tmp; + tmp.days = d(gen); + tmp.milliseconds = d(gen); + return tmp; + }); +} + +inline void rand_month_day_nanos( + int64_t N, std::vector<MonthDayNanoIntervalType::MonthDayNanos>* out) { + const int random_seed = 0; + std::default_random_engine gen(random_seed); + std::uniform_int_distribution<int64_t> d(std::numeric_limits<int64_t>::min(), + std::numeric_limits<int64_t>::max()); + out->resize(N, {}); + std::generate(out->begin(), out->end(), [&d, &gen] { + MonthDayNanoIntervalType::MonthDayNanos tmp; + tmp.months = static_cast<int32_t>(d(gen)); + tmp.days = static_cast<int32_t>(d(gen)); + tmp.nanoseconds = d(gen); + return tmp; + }); +} + Review comment: they are used in array_test -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org