fix gis hash

This commit is contained in:
obdev
2023-01-28 18:26:43 +08:00
committed by ob-robot
parent 10cf0f58c9
commit 59d26b53a0
3 changed files with 64 additions and 5 deletions

View File

@ -1489,7 +1489,67 @@ DEF_TEXT_FUNCS(ObTinyTextType, string, ObString);
DEF_TEXT_FUNCS(ObTextType, string, ObString);
DEF_TEXT_FUNCS(ObMediumTextType, string, ObString);
DEF_TEXT_FUNCS(ObLongTextType, string, ObString);
DEF_TEXT_FUNCS(ObGeometryType, string, ObString); //todo: not implement
#define DEF_GEO_CS_FUNCS(OBJTYPE) \
template <> \
inline int64_t obj_crc64<OBJTYPE>(const ObObj &obj, const int64_t current) \
{ \
int type = obj.get_type(); \
int cs = obj.get_collation_type(); \
int64_t ret = ob_crc64_sse42(current, &type, sizeof(type)); \
ret = ob_crc64_sse42(ret, &cs, sizeof(cs)); \
return ob_crc64_sse42(ret, obj.get_string_ptr(), obj.get_string_len()); \
} \
template <> \
inline int64_t obj_crc64_v2<OBJTYPE>(const ObObj &obj, const int64_t current) \
{ \
int cs = obj.get_collation_type(); \
int64_t ret = ob_crc64_sse42(current, &cs, sizeof(cs)); \
return ob_crc64_sse42(ret, obj.get_string_ptr(), obj.get_string_len()); \
} \
template <> \
inline void obj_batch_checksum<OBJTYPE>(const ObObj &obj, ObBatchChecksum &bc) \
{ \
int type = obj.get_type(); \
int cs = obj.get_collation_type(); \
bc.fill(&type, sizeof(type)); \
bc.fill(&cs, sizeof(cs)); \
bc.fill(obj.get_string_ptr(), obj.get_string_len()); \
} \
template <> \
inline uint64_t obj_murmurhash<OBJTYPE>(const ObObj &obj, const uint64_t hash) \
{ \
return varchar_murmurhash(obj, obj.get_collation_type(), hash); \
} \
template <typename T> \
struct ObjHashCalculator<OBJTYPE, T, ObObj> \
{ \
static uint64_t calc_hash_value(const ObObj &param, const uint64_t hash) { \
common::ObString wkb = param.get_string(); \
uint64_t hash_res = hash; \
if (wkb.length() > 0 && !param.is_null()) { \
hash_res = ObCharset::hash(param.get_collation_type(), param.get_string_ptr(), \
param.get_string_len(), hash, \
false, T::is_varchar_hash ? T::hash : NULL); \
} \
return hash_res; \
} \
}; \
template <> \
inline uint64_t obj_crc64_v3<OBJTYPE>(const ObObj &obj, const uint64_t current) \
{ \
int cs = obj.get_collation_type(); \
uint64_t ret = ob_crc64_sse42(current, &cs, sizeof(cs)); \
return ob_crc64_sse42(ret, obj.get_string_ptr(), obj.get_string_len()); \
} \
#define DEF_GEO_FUNCS(OBJTYPE, TYPE, VTYPE) \
DEF_TEXT_PRINT_FUNCS(OBJTYPE); \
DEF_GEO_CS_FUNCS(OBJTYPE); \
DEF_TEXT_SERIALIZE_FUNCS(OBJTYPE, TYPE, VTYPE)
DEF_GEO_FUNCS(ObGeometryType, string, ObString);
#define DEF_JSON_CS_FUNCS(OBJTYPE) \
template <> \

View File

@ -295,6 +295,7 @@ DEF_DATUM_SPECIAL_HASH_FUNCS(ObUFloatType);
DEF_DATUM_SPECIAL_HASH_FUNCS(ObDoubleType);
DEF_DATUM_SPECIAL_HASH_FUNCS(ObUDoubleType);
DEF_DATUM_SPECIAL_HASH_FUNCS(ObJsonType);
DEF_DATUM_SPECIAL_HASH_FUNCS(ObGeometryType);
OB_INLINE static uint64_t datum_varchar_hash(const ObDatum &datum,
const ObCollationType cs_type,

View File

@ -61,10 +61,8 @@ uint64_t ObSharedExprResolver::hash_expr_tree(ObRawExpr *expr, uint64_t hash_cod
if (expr->get_expr_type() == T_QUESTIONMARK) {
// do nothing
} else if (expr->is_const_raw_expr()) {
if (expr->get_expr_type() != T_GEOMETRY) { // GIS does not support hash func
hash_code = common::do_hash(static_cast<ObConstRawExpr *>(expr)->get_value(),
hash_code);
}
hash_code = common::do_hash(static_cast<ObConstRawExpr *>(expr)->get_value(),
hash_code);
} else if (expr->get_expr_type() == T_FUN_SYS_CAST) {
hash_code = hash_expr_tree(expr->get_param_expr(0), hash_code, false);
} else if (!is_root) {