@@ -538,6 +538,8 @@ tuple_compare_field_with_type(const char *field_a, enum mp_type a_type,
538
538
field_b, b_type);
539
539
case FIELD_TYPE_UUID:
540
540
return mp_compare_uuid (field_a, field_b);
541
+ case FIELD_TYPE_DATETIME:
542
+ return mp_compare_datetime (field_a, field_b);
541
543
default :
542
544
unreachable ();
543
545
return 0 ;
@@ -1630,6 +1632,18 @@ hint_uuid_raw(const char *data)
1630
1632
return hint_create (MP_CLASS_UUID, val);
1631
1633
}
1632
1634
1635
+ static inline hint_t
1636
+ hint_datetime (struct datetime_t *date)
1637
+ {
1638
+ /*
1639
+ * Use at most HINT_VALUE_BITS from datetime
1640
+ * seconds field as a hint value
1641
+ */
1642
+ uint64_t val = (uint64_t )date->secs & HINT_VALUE_MAX;
1643
+
1644
+ return hint_create (MP_CLASS_DATETIME, val);
1645
+ }
1646
+
1633
1647
static inline uint64_t
1634
1648
hint_str_raw (const char *s, uint32_t len)
1635
1649
{
@@ -1761,6 +1775,17 @@ field_hint_uuid(const char *field)
1761
1775
return hint_uuid_raw (data);
1762
1776
}
1763
1777
1778
+ static inline hint_t
1779
+ field_hint_datetime (const char *field)
1780
+ {
1781
+ assert (mp_typeof (*field) == MP_EXT);
1782
+ int8_t ext_type;
1783
+ uint32_t len = mp_decode_extl (&field, &ext_type);
1784
+ assert (ext_type == MP_DATETIME);
1785
+ struct datetime_t date;
1786
+ return hint_datetime (datetime_unpack (&field, len, &date));
1787
+ }
1788
+
1764
1789
static inline hint_t
1765
1790
field_hint_string (const char *field, struct coll *coll)
1766
1791
{
@@ -1849,6 +1874,8 @@ field_hint(const char *field, struct coll *coll)
1849
1874
return field_hint_decimal (field);
1850
1875
case FIELD_TYPE_UUID:
1851
1876
return field_hint_uuid (field);
1877
+ case FIELD_TYPE_DATETIME:
1878
+ return field_hint_datetime (field);
1852
1879
default :
1853
1880
unreachable ();
1854
1881
}
@@ -1963,6 +1990,9 @@ key_def_set_hint_func(struct key_def *def)
1963
1990
case FIELD_TYPE_UUID:
1964
1991
key_def_set_hint_func<FIELD_TYPE_UUID>(def);
1965
1992
break ;
1993
+ case FIELD_TYPE_DATETIME:
1994
+ key_def_set_hint_func<FIELD_TYPE_DATETIME>(def);
1995
+ break ;
1966
1996
default :
1967
1997
/* Invalid key definition. */
1968
1998
def->key_hint = NULL ;
0 commit comments