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

Function GenerateRandomTimestampArray

cpp/src/arrow/adapters/orc/adapter_test.cc:130–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130Result<std::shared_ptr<Array>> GenerateRandomTimestampArray(
131 int64_t size, std::shared_ptr<TimestampType> type, double null_probability) {
132 random::RandomArrayGenerator rand(kRandomSeed);
133 switch (type->unit()) {
134 case TimeUnit::type::SECOND: {
135 return CastInt64ArrayToTemporalArray<TimestampArray>(
136 type, rand.Int64(size, kSecondMin, kSecondMax, null_probability));
137 }
138 case TimeUnit::type::MILLI: {
139 return CastInt64ArrayToTemporalArray<TimestampArray>(
140 type, rand.Int64(size, kMilliMin, kMilliMax, null_probability));
141 }
142 case TimeUnit::type::MICRO: {
143 return CastInt64ArrayToTemporalArray<TimestampArray>(
144 type, rand.Int64(size, kMicroMin, kMicroMax, null_probability));
145 }
146 case TimeUnit::type::NANO: {
147 return CastInt64ArrayToTemporalArray<TimestampArray>(
148 type, rand.Int64(size, kNanoMin, kNanoMax, null_probability));
149 }
150 default: {
151 return Status::TypeError("Unknown or unsupported Arrow TimeUnit: ", type);
152 }
153 }
154}
155
156/// \brief Construct a random weak composition of a nonnegative integer
157/// i.e. a way of writing it as the sum of a sequence of n non-negative

Callers 1

Calls 3

TypeErrorFunction · 0.50
unitMethod · 0.45
Int64Method · 0.45

Tested by

no test coverage detected