[Tarantool-patches] [PATCH v3 6/9] box, datetime: datetime comparison for indices

Timur Safin tsafin at tarantool.org
Wed Aug 4 13:12:52 MSK 2021


Hello Sergey,

Here is small update since previous message...

> > You just need to assign the same HINT_VALUE_MAX hint to every
> datetime value
> > with date->secs >= HINT_VALUE_SECS_MAX. Otherwise the comparison
> would
> > make mistakes (judging by hint values only) for such far away
> dates.
> 
> Yes, thanks for the note, will make sure that values which exceed
> selected
> 36-bit will stick to the maximum value.

Introduced this simple fix to the current code:
----------------------------------------
diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc
index f733b9f01..0c5e0b666 100644
--- a/src/box/tuple_compare.cc
+++ b/src/box/tuple_compare.cc
@@ -1659,7 +1659,8 @@ hint_datetime(struct datetime_t *date)
        int32_t nsec = date->nsec;
        uint64_t val = secs <= HINT_VALUE_SECS_MIN ? 0 :
                        secs - HINT_VALUE_SECS_MIN;
-       val &= HINT_VALUE_SECS_MAX;
+       if (val >= HINT_VALUE_SECS_MAX)
+               val = HINT_VALUE_SECS_MAX;
        val <<= HINT_VALUE_NSEC_BITS;
        val |= (nsec >> HINT_VALUE_NSEC_SHIFT) & HINT_VALUE_NSEC_MAX;
        return hint_create(MP_CLASS_DATETIME, val);
----------------------------------------

Updated accordingly and force-pushed to the branch. 

> > But you don't allow datetime in SCALAR fields, as I see in the
> previous
> > commit.
> > So you don't need to account for datetime in scalar hints.
> 
> That's bug - every type is scalar type, unless it's collection (map
> or array)
> so datetime should be considered as scalar. That was oversight if
> not.
> Thanks!

Also DATETIME is considered compatible with SCALAR type in 
MessagePack and with scalar column. Also updated patch, and force-pushed
to branch.

Thanks,
Timur



More information about the Tarantool-patches mailing list