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 20d815f0e77 [refactor](style) Using C++style and changing to smart
pointers (#28454)
20d815f0e77 is described below
commit 20d815f0e77cdf635fe52701763c025a799e582a
Author: 赵硕 <[email protected]>
AuthorDate: Sat Dec 16 10:44:43 2023 +0800
[refactor](style) Using C++style and changing to smart pointers (#28454)
---
be/src/geo/geo_types.cpp | 12 ++++++------
be/src/geo/geo_types.h | 2 +-
be/src/vec/functions/functions_geo.cpp | 15 +++++++--------
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/be/src/geo/geo_types.cpp b/be/src/geo/geo_types.cpp
index ec06ffdfa28..bee6f69ba8e 100644
--- a/be/src/geo/geo_types.cpp
+++ b/be/src/geo/geo_types.cpp
@@ -212,26 +212,26 @@ GeoShape* GeoShape::from_wkb(const char* data, size_t
size, GeoParseStatus* stat
return shape;
}
-GeoShape* GeoShape::from_encoded(const void* ptr, size_t size) {
+std::unique_ptr<GeoShape> GeoShape::from_encoded(const void* ptr, size_t size)
{
if (size < 2 || ((const char*)ptr)[0] != 0X00) {
return nullptr;
}
std::unique_ptr<GeoShape> shape;
switch (((const char*)ptr)[1]) {
case GEO_SHAPE_POINT: {
- shape.reset(GeoPoint::create_unique().release());
+ shape = GeoPoint::create_unique();
break;
}
case GEO_SHAPE_LINE_STRING: {
- shape.reset(GeoLine::create_unique().release());
+ shape = GeoLine::create_unique();
break;
}
case GEO_SHAPE_POLYGON: {
- shape.reset(GeoPolygon::create_unique().release());
+ shape = GeoPolygon::create_unique();
break;
}
case GEO_SHAPE_CIRCLE: {
- shape.reset(GeoCircle::create_unique().release());
+ shape = GeoCircle::create_unique();
break;
}
default:
@@ -241,7 +241,7 @@ GeoShape* GeoShape::from_encoded(const void* ptr, size_t
size) {
if (!res) {
return nullptr;
}
- return shape.release();
+ return shape;
}
GeoParseStatus GeoPoint::from_coord(double x, double y) {
diff --git a/be/src/geo/geo_types.h b/be/src/geo/geo_types.h
index aecd9bbd531..aaeff3db58f 100644
--- a/be/src/geo/geo_types.h
+++ b/be/src/geo/geo_types.h
@@ -46,7 +46,7 @@ public:
virtual GeoShapeType type() const = 0;
// decode from serialized data
- static GeoShape* from_encoded(const void* data, size_t size);
+ static std::unique_ptr<GeoShape> from_encoded(const void* data, size_t
size);
// try to construct a GeoShape from a WKT. If construct successfully, a
GeoShape will
// be returned, and the client should delete it when don't need it.
// return nullptr if convert failed, and reason will be set in status
diff --git a/be/src/vec/functions/functions_geo.cpp
b/be/src/vec/functions/functions_geo.cpp
index 28e8b16fd13..34bec39d4ff 100644
--- a/be/src/vec/functions/functions_geo.cpp
+++ b/be/src/vec/functions/functions_geo.cpp
@@ -98,8 +98,7 @@ struct StAsText {
std::unique_ptr<GeoShape> shape;
for (int row = 0; row < size; ++row) {
auto shape_value = input->get_data_at(row);
- shape.reset(GeoShape::from_encoded(shape_value.data,
shape_value.size));
-
+ shape = GeoShape::from_encoded(shape_value.data, shape_value.size);
if (shape == nullptr) {
res->insert_data(nullptr, 0);
continue;
@@ -355,8 +354,8 @@ struct StAreaSquareMeters {
for (int row = 0; row < size; ++row) {
auto shape_value = col->get_data_at(row);
- shape.reset(GeoShape::from_encoded(shape_value.data,
shape_value.size));
- if (shape == nullptr) {
+ shape = GeoShape::from_encoded(shape_value.data, shape_value.size);
+ if (!shape) {
res->insert_data(nullptr, 0);
continue;
}
@@ -390,8 +389,8 @@ struct StAreaSquareKm {
for (int row = 0; row < size; ++row) {
auto shape_value = col->get_data_at(row);
- shape.reset(GeoShape::from_encoded(shape_value.data,
shape_value.size));
- if (shape == nullptr) {
+ shape = GeoShape::from_encoded(shape_value.data, shape_value.size);
+ if (!shape) {
res->insert_data(nullptr, 0);
continue;
}
@@ -646,8 +645,8 @@ struct StAsBinary {
for (int row = 0; row < size; ++row) {
auto shape_value = col->get_data_at(row);
- shape.reset(GeoShape::from_encoded(shape_value.data,
shape_value.size));
- if (shape == nullptr) {
+ shape = GeoShape::from_encoded(shape_value.data, shape_value.size);
+ if (!shape) {
res->insert_data(nullptr, 0);
continue;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]