[ https://issues.apache.org/jira/browse/QUICKSTEP-53?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15469286#comment-15469286 ]
ASF GitHub Bot commented on QUICKSTEP-53: ----------------------------------------- Github user hakanmemisoglu commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/98#discussion_r77751465 --- Diff: types/DatetimeLit.hpp --- @@ -51,53 +54,70 @@ struct DateLit { + 1 // - + 2; // Day + // Years should be between [-kMaxYear, +kMaxYear] inclusive both end. + static constexpr std::int32_t kMaxYear = 99999; + static constexpr std::uint8_t kBitsNeededForDay = 5u; + static constexpr std::uint8_t kBitsNeededForMonth = 4u; + static DateLit Create(const std::int32_t _year, const std::uint8_t _month, const std::uint8_t _day) { DateLit date; - date.year = _year; - date.month = _month; - date.day = _day; + // Normalize year by adding kMaxYear value, because we try to + // encode signed year value into an unsigned integer. --- End diff -- **L125** `std::int32_t result_year = lhs.yearField() + (rhs.months / 12);` **L126** `std::uint8_t result_month = static_cast<std::uint8_t>(lhs.monthField()) + (rhs.months % 12);` **L134** `ClampDayOfMonth(result_year, result_month, lhs.dayField()));` - Access to the struct happens via these methods (yearField(), monthField() etc...) that decodes from representation (normalized and shifted) to the year value (which is -2000 in your example). - After the operation + is done, and the check is applied. - The result year, month, day is calculated and given to `DateLit::Create()` - `DateLit::Create()`encodes the real values to the unified representation. I might be missing something, but does the execution above make sense? > New representation and faster comparison operators for DateLit > -------------------------------------------------------------- > > Key: QUICKSTEP-53 > URL: https://issues.apache.org/jira/browse/QUICKSTEP-53 > Project: Apache Quickstep > Issue Type: Improvement > Components: Types > Reporter: Hakan Memisoglu > Assignee: Hakan Memisoglu > > DateLit structure contains 3 member: > 32i for year, > 8u for month, > 8u for day. > Instead we can put all year, month, and day information into 32u. It will > benefit from having a smaller sized representation. > The new representation also provide faster comparison operator by directly > using 32u comparison operators that have corresponding assembly primitives > (instead of using if else branches). -- This message was sent by Atlassian JIRA (v6.3.4#6332)