You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/12/16 02:56:08 UTC
[doris] branch master updated: [Bug](s2geo) avoid some core dump on s2geo && enable ut of s2geo #15068
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 219489ca0e [Bug](s2geo) avoid some core dump on s2geo && enable ut of s2geo #15068
219489ca0e is described below
commit 219489ca0e6ed34d1527f51bd44cae9759d6e049
Author: Pxl <px...@qq.com>
AuthorDate: Fri Dec 16 10:56:02 2022 +0800
[Bug](s2geo) avoid some core dump on s2geo && enable ut of s2geo #15068
---
be/src/common/config.h | 2 --
be/src/geo/geo_functions.cpp | 5 ++++-
be/src/geo/geo_types.cpp | 11 +++++------
be/test/geo/geo_functions_test.cpp | 10 ++++------
be/test/geo/geo_types_test.cpp | 10 ++++------
be/test/vec/function/function_geo_test.cpp | 9 +++------
6 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/be/src/common/config.h b/be/src/common/config.h
index b4feaef618..0f3a04ccd5 100644
--- a/be/src/common/config.h
+++ b/be/src/common/config.h
@@ -864,8 +864,6 @@ CONF_Bool(enable_fuzzy_mode, "false");
CONF_Int32(pipeline_executor_size, "0");
-CONF_Double(s2geo_eps, "0.000000001");
-
#ifdef BE_TEST
// test s3
CONF_String(test_s3_resource, "resource");
diff --git a/be/src/geo/geo_functions.cpp b/be/src/geo/geo_functions.cpp
index 0502432f35..bda65a1346 100644
--- a/be/src/geo/geo_functions.cpp
+++ b/be/src/geo/geo_functions.cpp
@@ -24,7 +24,10 @@
namespace doris {
-void GeoFunctions::init() {}
+void GeoFunctions::init() {
+ // set s2debug to false to avoid crash
+ FLAGS_s2debug = false;
+}
DoubleVal GeoFunctions::st_distance_sphere(FunctionContext* ctx, const DoubleVal& x_lng,
const DoubleVal& x_lat, const DoubleVal& y_lng,
diff --git a/be/src/geo/geo_types.cpp b/be/src/geo/geo_types.cpp
index 4c6422b619..80d0d6b65c 100644
--- a/be/src/geo/geo_types.cpp
+++ b/be/src/geo/geo_types.cpp
@@ -31,7 +31,6 @@
#include <sstream>
#include <type_traits>
-#include "common/config.h"
#include "geo/wkt_parse.h"
namespace doris {
@@ -76,7 +75,7 @@ static bool is_loop_closed(const std::vector<S2Point>& points) {
if (points.empty()) {
return false;
}
- if (!points[0].aequal(points[points.size() - 1], config::s2geo_eps)) {
+ if (points[0] != points[points.size() - 1]) {
return false;
}
return true;
@@ -87,7 +86,7 @@ static void remove_duplicate_points(std::vector<S2Point>* points) {
int lhs = 0;
int rhs = 1;
for (; rhs < points->size(); ++rhs) {
- if (!(*points)[rhs].aequal((*points)[lhs], config::s2geo_eps)) {
+ if ((*points)[rhs] != (*points)[lhs]) {
lhs++;
if (lhs != rhs) {
(*points)[lhs] = (*points)[rhs];
@@ -270,7 +269,7 @@ void GeoPoint::encode(std::string* buf) {
}
bool GeoPoint::decode(const void* data, size_t size) {
- if (size < sizeof(*_point)) {
+ if (size != sizeof(*_point)) {
return false;
}
memcpy(_point.get(), data, size);
@@ -336,7 +335,7 @@ void GeoPolygon::encode(std::string* buf) {
bool GeoPolygon::decode(const void* data, size_t size) {
Decoder decoder(data, size);
_polygon.reset(new S2Polygon());
- return _polygon->Decode(&decoder);
+ return _polygon->Decode(&decoder) && _polygon->IsValid();
}
std::string GeoLine::as_wkt() const {
@@ -429,7 +428,7 @@ void GeoCircle::encode(std::string* buf) {
bool GeoCircle::decode(const void* data, size_t size) {
Decoder decoder(data, size);
_cap.reset(new S2Cap());
- return _cap->Decode(&decoder);
+ return _cap->Decode(&decoder) && _cap->is_valid();
}
std::string GeoCircle::as_wkt() const {
diff --git a/be/test/geo/geo_functions_test.cpp b/be/test/geo/geo_functions_test.cpp
index 1cfc118c95..b62a26c777 100644
--- a/be/test/geo/geo_functions_test.cpp
+++ b/be/test/geo/geo_functions_test.cpp
@@ -22,10 +22,8 @@
#include <vector>
-#include "common/logging.h"
#include "geo/geo_types.h"
#include "geo/wkt_parse.h"
-#include "geo/wkt_parse_ctx.h"
#include "testutil/function_utils.h"
#include "udf/udf.h"
#include "udf/udf_internal.h"
@@ -182,7 +180,7 @@ TEST_F(GeoFunctionsTest, st_line) {
GeoFunctions::st_from_wkt_close(ctx, FunctionContext::FRAGMENT_LOCAL);
}
}
-/*
+
TEST_F(GeoFunctionsTest, st_polygon) {
FunctionUtils utils;
FunctionContext* ctx = utils.get_fn_ctx();
@@ -216,7 +214,7 @@ TEST_F(GeoFunctionsTest, st_polygon) {
GeoFunctions::st_from_wkt_close(ctx, FunctionContext::FRAGMENT_LOCAL);
}
}
-*/
+
TEST_F(GeoFunctionsTest, st_circle) {
FunctionUtils utils;
FunctionContext* ctx = utils.get_fn_ctx();
@@ -275,7 +273,7 @@ TEST_F(GeoFunctionsTest, st_poly_line_fail) {
GeoFunctions::st_from_wkt_close(ctx, FunctionContext::FRAGMENT_LOCAL);
}
}
-/*
+
TEST_F(GeoFunctionsTest, st_contains) {
FunctionUtils utils;
FunctionContext* ctx = utils.get_fn_ctx();
@@ -325,5 +323,5 @@ TEST_F(GeoFunctionsTest, st_contains_cached) {
EXPECT_TRUE(res.val);
GeoFunctions::st_contains_close(ctx, FunctionContext::FRAGMENT_LOCAL);
}
-*/
+
} // namespace doris
diff --git a/be/test/geo/geo_types_test.cpp b/be/test/geo/geo_types_test.cpp
index e3ac577028..9999f3f502 100644
--- a/be/test/geo/geo_types_test.cpp
+++ b/be/test/geo/geo_types_test.cpp
@@ -22,8 +22,6 @@
#include "common/logging.h"
#include "geo/geo_types.h"
#include "geo/wkt_parse.h"
-#include "geo/wkt_parse_ctx.h"
-#include "s2/s2debug.h"
namespace doris {
@@ -93,7 +91,7 @@ TEST_F(GeoTypesTest, linestring) {
EXPECT_EQ(nullptr, line2);
}
}
-/*
+
TEST_F(GeoTypesTest, polygon_contains) {
const char* wkt = "POLYGON ((10 10, 50 10, 50 10, 50 50, 50 50, 10 50, 10 10))";
GeoParseStatus status;
@@ -128,7 +126,7 @@ TEST_F(GeoTypesTest, polygon_contains) {
EXPECT_EQ(nullptr, shape);
}
}
-*/
+
TEST_F(GeoTypesTest, polygon_parse_fail) {
{
const char* wkt = "POLYGON ((10 10, 50 10, 50 50, 10 50), (10 10 01))";
@@ -152,7 +150,7 @@ TEST_F(GeoTypesTest, polygon_parse_fail) {
EXPECT_EQ(nullptr, polygon.get());
}
}
-/*
+
TEST_F(GeoTypesTest, polygon_hole_contains) {
const char* wkt =
"POLYGON ((10 10, 50 10, 50 50, 10 50, 10 10), (20 20, 40 20, 40 40, 20 40, 20 20))";
@@ -180,7 +178,7 @@ TEST_F(GeoTypesTest, polygon_hole_contains) {
EXPECT_TRUE(res);
}
}
-*/
+
TEST_F(GeoTypesTest, circle) {
GeoCircle circle;
auto res = circle.init(110.123, 64, 1000);
diff --git a/be/test/vec/function/function_geo_test.cpp b/be/test/vec/function/function_geo_test.cpp
index 999e377c64..544424f842 100644
--- a/be/test/vec/function/function_geo_test.cpp
+++ b/be/test/vec/function/function_geo_test.cpp
@@ -22,9 +22,7 @@
#include "function_test_util.h"
#include "geo/geo_types.h"
-#include "vec/core/field.h"
#include "vec/core/types.h"
-#include "vec/data_types/data_type_nullable.h"
#include "vec/data_types/data_type_string.h"
namespace doris::vectorized {
@@ -137,7 +135,7 @@ TEST(VGeoFunctionsTest, function_geo_st_distance_sphere) {
check_function<DataTypeFloat64, true>(func_name, input_types, data_set);
}
}
-/*
+
TEST(VGeoFunctionsTest, function_geo_st_contains) {
std::string func_name = "st_contains";
{
@@ -172,7 +170,7 @@ TEST(VGeoFunctionsTest, function_geo_st_contains) {
check_function<DataTypeUInt8, true>(func_name, input_types, data_set);
}
}
-*/
+
TEST(VGeoFunctionsTest, function_geo_st_circle) {
std::string func_name = "st_circle";
{
@@ -246,7 +244,6 @@ TEST(VGeoFunctionsTest, function_geo_st_linefromtext) {
}
}
-/*
TEST(VGeoFunctionsTest, function_geo_st_polygon) {
std::string func_name = "st_polygon";
{
@@ -284,5 +281,5 @@ TEST(VGeoFunctionsTest, function_geo_st_polygonfromtext) {
check_function<DataTypeString, true>(func_name, input_types, data_set);
}
}
-*/
+
} // namespace doris::vectorized
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org