Check if we would need to expand the underlying storage type
| 61 | |
| 62 | // Check if we would need to expand the underlying storage type |
| 63 | static inline uint8_t ExpandedUIntWidth(uint64_t val, uint8_t current_width) { |
| 64 | // Optimize for the common case where width doesn't change |
| 65 | if (ARROW_PREDICT_TRUE(val <= max_uints[current_width])) { |
| 66 | return current_width; |
| 67 | } |
| 68 | if (current_width == 1 && val <= max_uint8) { |
| 69 | return 1; |
| 70 | } else if (current_width <= 2 && val <= max_uint16) { |
| 71 | return 2; |
| 72 | } else if (current_width <= 4 && val <= max_uint32) { |
| 73 | return 4; |
| 74 | } else { |
| 75 | return 8; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | uint8_t DetectUIntWidth(const uint64_t* values, int64_t length, uint8_t min_width) { |
| 80 | uint8_t width = min_width; |