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

Function CommonTemporalResolution

cpp/src/arrow/compute/kernels/codegen_internal.cc:220–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220bool CommonTemporalResolution(const TypeHolder* begin, size_t count,
221 TimeUnit::type* finest_unit) {
222 bool is_time_unit = false;
223 *finest_unit = TimeUnit::SECOND;
224 const TypeHolder* end = begin + count;
225 for (auto it = begin; it != end; it++) {
226 auto id = it->type->id();
227 switch (id) {
228 case Type::DATE32: {
229 // Date32's unit is days, but the coarsest we have is seconds
230 is_time_unit = true;
231 continue;
232 }
233 case Type::DATE64: {
234 *finest_unit = std::max(*finest_unit, TimeUnit::MILLI);
235 is_time_unit = true;
236 continue;
237 }
238 case Type::TIMESTAMP: {
239 const auto& ty = checked_cast<const TimestampType&>(*it->type);
240 *finest_unit = std::max(*finest_unit, ty.unit());
241 is_time_unit = true;
242 continue;
243 }
244 case Type::DURATION: {
245 const auto& ty = checked_cast<const DurationType&>(*it->type);
246 *finest_unit = std::max(*finest_unit, ty.unit());
247 is_time_unit = true;
248 continue;
249 }
250 case Type::TIME32: {
251 const auto& ty = checked_cast<const Time32Type&>(*it->type);
252 *finest_unit = std::max(*finest_unit, ty.unit());
253 is_time_unit = true;
254 continue;
255 }
256 case Type::TIME64: {
257 const auto& ty = checked_cast<const Time64Type&>(*it->type);
258 *finest_unit = std::max(*finest_unit, ty.unit());
259 is_time_unit = true;
260 continue;
261 }
262 default:
263 continue;
264 }
265 }
266 return is_time_unit;
267}
268
269TypeHolder CommonTemporal(const TypeHolder* begin, size_t count) {
270 TimeUnit::type finest_unit = TimeUnit::SECOND;

Callers 2

TESTFunction · 0.85
DispatchBestMethod · 0.85

Calls 2

idMethod · 0.45
unitMethod · 0.45

Tested by 1

TESTFunction · 0.68