mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Avoid UBSan report in greatCircleDistance
This commit is contained in:
parent
4afcb94a8a
commit
0528ca60d6
@ -160,6 +160,12 @@ DECLARE_MULTITARGET_CODE(
|
||||
namespace
|
||||
{
|
||||
|
||||
inline NO_SANITIZE_UNDEFINED size_t metricLUTIndex(float latitude_midpoint)
|
||||
{
|
||||
/// Implementation specific behaviour on overflow or infinite value.
|
||||
return static_cast<size_t>(latitude_midpoint) & (METRIC_LUT_SIZE - 1);
|
||||
}
|
||||
|
||||
template <Method method>
|
||||
float distance(float lon1deg, float lat1deg, float lon2deg, float lat2deg)
|
||||
{
|
||||
@ -177,7 +183,7 @@ float distance(float lon1deg, float lat1deg, float lon2deg, float lat2deg)
|
||||
/// But if longitude is close but latitude is different enough, there is no difference between meridian and great circle line.
|
||||
|
||||
float latitude_midpoint = (lat1deg + lat2deg + 180) * METRIC_LUT_SIZE / 360; // [-90, 90] degrees -> [0, KTABLE] indexes
|
||||
size_t latitude_midpoint_index = static_cast<size_t>(latitude_midpoint) & (METRIC_LUT_SIZE - 1);
|
||||
size_t latitude_midpoint_index = metricLUTIndex(latitude_midpoint);
|
||||
|
||||
/// This is linear interpolation between two table items at index "latitude_midpoint_index" and "latitude_midpoint_index + 1".
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
SELECT greatCircleAngle(0, -9223372036854775808, number, number) FROM numbers(3) FORMAT Null;
|
Loading…
Reference in New Issue
Block a user