◆ Normalize() [1/2]
5334 {
5335 auto &input = *this;
5336
5337
5338 micros = input.micros;
5339 int64_t carry_days = micros / Interval::MICROS_PER_DAY;
5340 micros -= carry_days * Interval::MICROS_PER_DAY;
5341
5342 days = input.days;
5343 days += carry_days;
5346
5347 months = input.months;
5348 months += carry_months;
5349}
static constexpr const int64_t DAYS_PER_MONTH
only used for interval comparison/ordering purposes, in which case a month counts as 30 days
Definition duckdb.hpp:5258
◆ Borrow()
5351 {
5352 if (msf > NumericLimits<int32_t>::Maximum()) {
5353 f = NumericLimits<int32_t>::Maximum();
5354 lsf += (msf - f) * scale;
5355 } else if (msf < NumericLimits<int32_t>::Minimum()) {
5356 f = NumericLimits<int32_t>::Minimum();
5357 lsf += (msf - f) * scale;
5358 } else {
5359 f = UnsafeNumericCast<int32_t>(msf);
5360 }
5361}
◆ Normalize() [2/2]
| interval_t duckdb::interval_t::Normalize |
( |
| ) |
const |
|
inline |
5363 {
5364 interval_t result;
5365
5368 Normalize(mm, dd, result.micros);
5369
5370
5372 Borrow(dd, result.micros, result.days, Interval::MICROS_PER_DAY);
5373
5374 return result;
5375}
◆ operator==()
| bool duckdb::interval_t::operator== |
( |
const interval_t & | right | ) |
const |
|
inline |
5192 {
5193
5194 const auto &left = *this;
5195 if (left.months == right.months && left.days == right.days && left.micros == right.micros) {
5196 return true;
5197 }
5198
5199 int64_t lmonths, ldays, lmicros;
5200 int64_t rmonths, rdays, rmicros;
5201 left.Normalize(lmonths, ldays, lmicros);
5202 right.Normalize(rmonths, rdays, rmicros);
5203
5204 return lmonths == rmonths && ldays == rdays && lmicros == rmicros;
5205 }
◆ operator!=()
| bool duckdb::interval_t::operator!= |
( |
const interval_t & | right | ) |
const |
|
inline |
5206 {
5207 return !(*this == right);
5208 }
◆ operator>()
| bool duckdb::interval_t::operator> |
( |
const interval_t & | right | ) |
const |
|
inline |
5210 {
5211 const auto &left = *this;
5212 int64_t lmonths, ldays, lmicros;
5213 int64_t rmonths, rdays, rmicros;
5214 left.Normalize(lmonths, ldays, lmicros);
5215 right.Normalize(rmonths, rdays, rmicros);
5216
5217 if (lmonths > rmonths) {
5218 return true;
5219 } else if (lmonths < rmonths) {
5220 return false;
5221 }
5222 if (ldays > rdays) {
5223 return true;
5224 } else if (ldays < rdays) {
5225 return false;
5226 }
5227 return lmicros > rmicros;
5228 }
◆ operator<()
| bool duckdb::interval_t::operator< |
( |
const interval_t & | right | ) |
const |
|
inline |
5230 {
5231 return right > *this;
5232 }
◆ operator<=()
| bool duckdb::interval_t::operator<= |
( |
const interval_t & | right | ) |
const |
|
inline |
5234 {
5235 return !(*this > right);
5236 }
◆ operator>=()
| bool duckdb::interval_t::operator>= |
( |
const interval_t & | right | ) |
const |
|
inline |
5238 {
5239 return !(*this < right);
5240 }
◆ Serialize()
| void duckdb::interval_t::Serialize |
( |
Serializer & | serializer | ) |
const |
417918 {
417919 serializer.WritePropertyWithDefault<
int32_t>(1,
"months", months);
417920 serializer.WritePropertyWithDefault<
int32_t>(2,
"days", days);
417921 serializer.WritePropertyWithDefault<
int64_t>(3,
"micros", micros);
417922}
◆ Deserialize()
417924 {
417925 interval_t result;
417926 deserializer.ReadPropertyWithDefault<
int32_t>(1,
"months", result.months);
417927 deserializer.ReadPropertyWithDefault<
int32_t>(2,
"days", result.days);
417928 deserializer.ReadPropertyWithDefault<
int64_t>(3,
"micros", result.micros);
417929 return result;
417930}
The documentation for this struct was generated from the following files: