diff --git a/src/box/key_def.h b/src/box/key_def.h index 9ad2644c20011125c9cfa896b418fbeecefc6dc9..54930ba1d3f07812dc8330b7f1127cb7bb513166 100644 --- a/src/box/key_def.h +++ b/src/box/key_def.h @@ -958,6 +958,19 @@ tuple_extract_key_raw(const char *data, const char *data_end, multikey_idx, key_size); } +/** + * @brief Compare two fields parts using a type definition + * @param field_a field + * @param field_b field + * @param field_type field type definition + * @retval 0 if field_a == field_b + * @retval <0 if field_a < field_b + * @retval >0 if field_a > field_b + */ +int +tuple_compare_field(const char *field_a, const char *field_b, + int8_t type, struct coll *coll); + /** * Compare keys using the key definition and comparison hints. * @param key_a key parts with MessagePack array header diff --git a/src/box/tuple_compare.cc b/src/box/tuple_compare.cc index 011fd4631079d680dafc5946bb82f6e3ee5f154f..dc8b7e87f823eacad82aa961d18a4a3b6d60caa8 100644 --- a/src/box/tuple_compare.cc +++ b/src/box/tuple_compare.cc @@ -41,25 +41,6 @@ /* {{{ tuple_compare */ -/** - * Compare two tuple hints. - * - * Returns: - * - * -1 if the first tuple is less than the second tuple - * +1 if the first tuple is greater than the second tuple - * 0 if the first tuple may be less than, equal to, or - * greater than the second tuple, and a full tuple - * comparison is needed to determine the order. - */ -static inline int -hint_cmp(hint_t hint_a, hint_t hint_b) -{ - if (hint_a != HINT_NONE && hint_b != HINT_NONE && hint_a != hint_b) - return hint_a < hint_b ? -1 : 1; - return 0; -} - /* * Compare two tuple fields. * Separate version exists since compare is a very @@ -488,7 +469,7 @@ mp_compare_scalar_coll(const char *field_a, const char *field_b, * @retval <0 if field_a < field_b * @retval >0 if field_a > field_b */ -static int +int tuple_compare_field(const char *field_a, const char *field_b, int8_t type, struct coll *coll) { diff --git a/src/box/tuple_compare.h b/src/box/tuple_compare.h index 8614f2320e8c17fde4975e45e9b6939aea965d4c..031502b0fcac97025e525d3faddc9d7a98ac86cb 100644 --- a/src/box/tuple_compare.h +++ b/src/box/tuple_compare.h @@ -69,6 +69,25 @@ typedef uint64_t hint_t; */ #define HINT_NONE ((hint_t)UINT64_MAX) +/** + * Compare two tuple hints. + * + * Returns: + * + * -1 if the first tuple is less than the second tuple + * +1 if the first tuple is greater than the second tuple + * 0 if the first tuple may be less than, equal to, or + * greater than the second tuple, and a full tuple + * comparison is needed to determine the order. + */ +static inline int +hint_cmp(hint_t hint_a, hint_t hint_b) +{ + if (hint_a != HINT_NONE && hint_b != HINT_NONE && hint_a != hint_b) + return hint_a < hint_b ? -1 : 1; + return 0; +} + /** * Initialize comparator functions for the key_def. * @param key_def key definition