mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix style
This commit is contained in:
parent
155d392d31
commit
2475143ed3
@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <Columns/ColumnsNumber.h>
|
||||
#include <Columns/ColumnTuple.h>
|
||||
#include <DataTypes/DataTypeArray.h>
|
||||
|
@ -20,14 +20,6 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
class FunctionPolygonsUnion : public IFunction
|
||||
{
|
||||
public:
|
||||
|
@ -3,9 +3,16 @@
|
||||
|
||||
#include <common/logger_useful.h>
|
||||
|
||||
namespace DB {
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace {
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
size_t getArrayDepth(DataTypePtr data_type, size_t max_depth)
|
||||
{
|
||||
|
@ -18,11 +18,11 @@
|
||||
|
||||
#include <common/logger_useful.h>
|
||||
|
||||
namespace DB {
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
}
|
||||
|
||||
@ -54,8 +54,8 @@ using GeographicMultiPolygon = MultiPolygon<GeographicPoint>;
|
||||
using GeographicGeometry = Geometry<GeographicPoint>;
|
||||
|
||||
/**
|
||||
* Class which takes some boost type and returns a pair of numbers.
|
||||
* They are (x,y) in case of cartesian coordinated and (lon,lat) in case of geographic.
|
||||
* Class which takes some boost type and returns a pair of numbers.
|
||||
* They are (x,y) in case of cartesian coordinated and (lon,lat) in case of geographic.
|
||||
*/
|
||||
template <typename PointType>
|
||||
class PointFromColumnParser
|
||||
@ -154,9 +154,8 @@ public:
|
||||
container.reserve(r - l + 1);
|
||||
container.resize(r - l);
|
||||
|
||||
for (size_t j = l; j < r; j++) {
|
||||
for (size_t j = l; j < r; j++)
|
||||
point_parser.get(container[j - l], j);
|
||||
}
|
||||
|
||||
// make ring closed
|
||||
if (!boost::geometry::equals(container[0], container.back()))
|
||||
@ -289,25 +288,25 @@ public:
|
||||
|
||||
void operator()(const Ring<Point> & ring)
|
||||
{
|
||||
if (ring.size() != 1) {
|
||||
if (ring.size() != 1)
|
||||
throw Exception("Unable to write ring of size " + toString(ring.size()) + " != 1 to point column", ErrorCodes::BAD_ARGUMENTS);
|
||||
}
|
||||
|
||||
(*this)(ring[0]);
|
||||
}
|
||||
|
||||
void operator()(const Polygon<Point> & polygon)
|
||||
{
|
||||
if (polygon.inners().size() != 0) {
|
||||
if (polygon.inners().size() != 0)
|
||||
throw Exception("Unable to write polygon with holes to point column", ErrorCodes::BAD_ARGUMENTS);
|
||||
}
|
||||
|
||||
(*this)(polygon.outer());
|
||||
}
|
||||
|
||||
void operator()(const MultiPolygon<Point> & multi_polygon)
|
||||
{
|
||||
if (multi_polygon.size() != 1) {
|
||||
if (multi_polygon.size() != 1)
|
||||
throw Exception("Unable to write multi-polygon of size " + toString(multi_polygon.size()) + " != 1 to point column", ErrorCodes::BAD_ARGUMENTS);
|
||||
}
|
||||
|
||||
(*this)(multi_polygon[0]);
|
||||
}
|
||||
|
||||
@ -357,17 +356,17 @@ public:
|
||||
|
||||
void operator()(const Polygon<Point> & polygon)
|
||||
{
|
||||
if (polygon.inners().size() != 0) {
|
||||
if (polygon.inners().size() != 0)
|
||||
throw Exception("Unable to write polygon with holes to ring column", ErrorCodes::BAD_ARGUMENTS);
|
||||
}
|
||||
|
||||
(*this)(polygon.outer());
|
||||
}
|
||||
|
||||
void operator()(const MultiPolygon<Point> & multi_polygon)
|
||||
{
|
||||
if (multi_polygon.size() != 1) {
|
||||
if (multi_polygon.size() != 1)
|
||||
throw Exception("Unable to write multi-polygon of size " + toString(multi_polygon.size()) + " != 1 to ring column", ErrorCodes::BAD_ARGUMENTS);
|
||||
}
|
||||
|
||||
(*this)(multi_polygon[0]);
|
||||
}
|
||||
|
||||
@ -421,9 +420,9 @@ public:
|
||||
|
||||
void operator()(const MultiPolygon<Point> & multi_polygon)
|
||||
{
|
||||
if (multi_polygon.size() != 1) {
|
||||
if (multi_polygon.size() != 1)
|
||||
throw Exception("Unable to write multi-polygon of size " + toString(multi_polygon.size()) + " != 1 to polygon column", ErrorCodes::BAD_ARGUMENTS);
|
||||
}
|
||||
|
||||
(*this)(multi_polygon[0]);
|
||||
}
|
||||
|
||||
|
@ -19,15 +19,6 @@
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
template <typename Point>
|
||||
class FunctionPolygonArea : public IFunction
|
||||
{
|
||||
|
@ -20,14 +20,6 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
template <typename Point>
|
||||
class FunctionPolygonConvexHull : public IFunction
|
||||
{
|
||||
|
@ -20,14 +20,6 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
template <typename Point>
|
||||
class FunctionPolygonPerimeter : public IFunction
|
||||
{
|
||||
|
@ -22,14 +22,6 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
template <typename Point>
|
||||
class FunctionPolygonsDistance : public IFunction
|
||||
{
|
||||
|
@ -22,18 +22,11 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
template <typename Point>
|
||||
class FunctionPolygonsEquals : public IFunction
|
||||
{
|
||||
public:
|
||||
static inline const char * name = "polygonsEquals";
|
||||
static const char * name;
|
||||
|
||||
explicit FunctionPolygonsEquals() = default;
|
||||
|
||||
@ -64,35 +57,22 @@ public:
|
||||
|
||||
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & /*result_type*/, size_t input_rows_count) const override
|
||||
{
|
||||
auto get_parser = [&arguments] (size_t i) {
|
||||
const auto * const_col =
|
||||
checkAndGetColumn<ColumnConst>(arguments[i].column.get());
|
||||
|
||||
bool is_const = static_cast<bool>(const_col);
|
||||
|
||||
return std::pair<bool, GeometryFromColumnParser<CartesianPoint>>{is_const, is_const ?
|
||||
makeGeometryFromColumnParser<CartesianPoint>(ColumnWithTypeAndName(const_col->getDataColumnPtr(), arguments[i].type, arguments[i].name)) :
|
||||
makeGeometryFromColumnParser<CartesianPoint>(arguments[i])};
|
||||
};
|
||||
|
||||
auto [is_first_polygon_const, first_parser] = get_parser(0);
|
||||
auto first_parser = makeGeometryFromColumnParser<Point>(arguments[0]);
|
||||
auto first_container = createContainer(first_parser);
|
||||
|
||||
auto [is_second_polygon_const, second_parser] = get_parser(1);
|
||||
auto second_parser = makeGeometryFromColumnParser<Point>(arguments[1]);
|
||||
auto second_container = createContainer(second_parser);
|
||||
|
||||
auto res_column = ColumnUInt8::create();
|
||||
|
||||
for (size_t i = 0; i < input_rows_count; i++)
|
||||
{
|
||||
if (!is_first_polygon_const || i == 0)
|
||||
get(first_parser, first_container, i);
|
||||
if (!is_second_polygon_const || i == 0)
|
||||
get(second_parser, second_container, i);
|
||||
get(first_parser, first_container, i);
|
||||
get(second_parser, second_container, i);
|
||||
|
||||
bool equals = boost::geometry::equals(
|
||||
boost::get<CartesianMultiPolygon>(first_container),
|
||||
boost::get<CartesianMultiPolygon>(second_container));
|
||||
boost::get<MultiPolygon<Point>>(first_container),
|
||||
boost::get<MultiPolygon<Point>>(second_container));
|
||||
|
||||
res_column->insertValue(equals);
|
||||
}
|
||||
@ -107,9 +87,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
const char * FunctionPolygonsEquals<CartesianPoint>::name = "polygonsEqualsCartesian";
|
||||
|
||||
|
||||
void registerFunctionPolygonsEquals(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionPolygonsEquals>();
|
||||
factory.registerFunction<FunctionPolygonsEquals<CartesianPoint>>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,16 +19,6 @@
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
|
||||
class FunctionPolygonsIntersection : public IFunction
|
||||
{
|
||||
public:
|
||||
|
@ -20,14 +20,6 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
template <typename Point>
|
||||
class FunctionPolygonsSymDifference : public IFunction
|
||||
{
|
||||
@ -109,6 +101,4 @@ void registerFunctionPolygonsSymDifference(FunctionFactory & factory)
|
||||
factory.registerFunction<FunctionPolygonsSymDifference<GeographicPoint>>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,18 +22,11 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION;
|
||||
extern const int BAD_ARGUMENTS;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int ILLEGAL_COLUMN;
|
||||
}
|
||||
|
||||
template <typename Point>
|
||||
class FunctionPolygonsWithin : public IFunction
|
||||
{
|
||||
public:
|
||||
static inline const char * name = "polygonsWithin";
|
||||
static inline const char * name;
|
||||
|
||||
explicit FunctionPolygonsWithin() = default;
|
||||
|
||||
@ -64,35 +57,22 @@ public:
|
||||
|
||||
ColumnPtr executeImpl(const ColumnsWithTypeAndName & arguments, const DataTypePtr & /*result_type*/, size_t input_rows_count) const override
|
||||
{
|
||||
auto get_parser = [&arguments] (size_t i) {
|
||||
const auto * const_col =
|
||||
checkAndGetColumn<ColumnConst>(arguments[i].column.get());
|
||||
|
||||
bool is_const = static_cast<bool>(const_col);
|
||||
|
||||
return std::pair<bool, GeometryFromColumnParser<CartesianPoint>>{is_const, is_const ?
|
||||
makeGeometryFromColumnParser<CartesianPoint>(ColumnWithTypeAndName(const_col->getDataColumnPtr(), arguments[i].type, arguments[i].name)) :
|
||||
makeGeometryFromColumnParser<CartesianPoint>(arguments[i])};
|
||||
};
|
||||
|
||||
auto [is_first_polygon_const, first_parser] = get_parser(0);
|
||||
auto first_parser = makeGeometryFromColumnParser<Point>(arguments[0]);
|
||||
auto first_container = createContainer(first_parser);
|
||||
|
||||
auto [is_second_polygon_const, second_parser] = get_parser(1);
|
||||
auto second_parser = makeGeometryFromColumnParser<Point>(arguments[1]);
|
||||
auto second_container = createContainer(second_parser);
|
||||
|
||||
auto res_column = ColumnUInt8::create();
|
||||
|
||||
for (size_t i = 0; i < input_rows_count; i++)
|
||||
{
|
||||
if (!is_first_polygon_const || i == 0)
|
||||
get(first_parser, first_container, i);
|
||||
if (!is_second_polygon_const || i == 0)
|
||||
get(second_parser, second_container, i);
|
||||
get(first_parser, first_container, i);
|
||||
get(second_parser, second_container, i);
|
||||
|
||||
bool within = boost::geometry::within(
|
||||
boost::get<CartesianMultiPolygon>(first_container),
|
||||
boost::get<CartesianMultiPolygon>(second_container));
|
||||
boost::get<MultiPolygon<Point>>(first_container),
|
||||
boost::get<MultiPolygon<Point>>(second_container));
|
||||
|
||||
res_column->insertValue(within);
|
||||
}
|
||||
@ -107,9 +87,13 @@ public:
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
const char * FunctionPolygonsWithin<CartesianPoint>::name = "polygonsWithinCartesian";
|
||||
|
||||
|
||||
void registerFunctionPolygonsWithin(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionPolygonsWithin>();
|
||||
factory.registerFunction<FunctionPolygonsWithin<CartesianPoint>>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,7 @@ namespace DB
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int BAD_ARGUMENT;
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
}
|
||||
|
||||
template <class DataType, class Geometry, class Serializer>
|
||||
|
@ -10,7 +10,9 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes {
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
extern const int TOO_MANY_ARGUMENTS_FOR_FUNCTION;
|
||||
extern const int TOO_FEW_ARGUMENTS_FOR_FUNCTION;
|
||||
}
|
||||
@ -48,7 +50,8 @@ public:
|
||||
{
|
||||
throw Exception("Too many arguments", ErrorCodes::TOO_MANY_ARGUMENTS_FOR_FUNCTION);
|
||||
}
|
||||
else if (arguments.empty()) {
|
||||
else if (arguments.empty())
|
||||
{
|
||||
throw Exception("Too few arguments", ErrorCodes::TOO_FEW_ARGUMENTS_FOR_FUNCTION);
|
||||
}
|
||||
else if (arguments.size() == 2 && checkAndGetDataType<DataTypeString>(arguments[1].get()) == nullptr)
|
||||
@ -75,13 +78,13 @@ public:
|
||||
|
||||
bool has_style = arguments.size() > 1;
|
||||
ColumnPtr style;
|
||||
if (has_style) {
|
||||
if (has_style)
|
||||
style = arguments[1].column;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < input_rows_count; i++)
|
||||
{
|
||||
std::stringstream str;
|
||||
/// FIXME
|
||||
std::stringstream str; // STYLE_CHECK_ALLOW_STD_STRING_STREAM
|
||||
if (!geo_column_is_const || i == 0)
|
||||
get(parser, container, i);
|
||||
|
||||
|
@ -45,7 +45,8 @@ public:
|
||||
|
||||
for (size_t i = 0; i < input_rows_count; i++)
|
||||
{
|
||||
std::stringstream str;
|
||||
/// FIXME
|
||||
std::stringstream str; // STYLE_CHECK_ALLOW_STD_STRING_STREAM
|
||||
get(parser, container, i);
|
||||
str << boost::geometry::wkt(container);
|
||||
std::string serialized = str.str();
|
||||
|
@ -1,2 +1,2 @@
|
||||
select polygonsWithin([[[(0, 0),(0, 3),(1, 2.9),(2, 2.6),(2.6, 2),(2.9, 1),(3, 0),(0, 0)]]], [[[(1, 1),(1, 4),(4, 4),(4, 1),(1, 1)]]]);
|
||||
select polygonsWithin([[[(2, 2), (2, 3), (3, 3), (3, 2)]]], [[[(1, 1),(1, 4),(4, 4),(4, 1),(1, 1)]]])
|
||||
select polygonsWithinCartesian([[[(0, 0),(0, 3),(1, 2.9),(2, 2.6),(2.6, 2),(2.9, 1),(3, 0),(0, 0)]]], [[[(1, 1),(1, 4),(4, 4),(4, 1),(1, 1)]]]);
|
||||
select polygonsWithinCartesian([[[(2, 2), (2, 3), (3, 3), (3, 2)]]], [[[(1, 1),(1, 4),(4, 4),(4, 1),(1, 1)]]])
|
||||
|
@ -1,2 +1,2 @@
|
||||
select polygonsEquals([[[(0, 0),(0, 3),(1, 2.9),(2, 2.6),(2.6, 2),(2.9, 1),(3, 0),(0, 0)]]], [[[(1, 1),(1, 4),(4, 4),(4, 1),(1, 1)]]]);
|
||||
select polygonsEquals([[[(1, 1),(1, 4),(4, 4),(4, 1)]]], [[[(1, 1),(1, 4),(4, 4),(4, 1),(1, 1)]]])
|
||||
select polygonsEqualsCartesian([[[(0, 0),(0, 3),(1, 2.9),(2, 2.6),(2.6, 2),(2.9, 1),(3, 0),(0, 0)]]], [[[(1, 1),(1, 4),(4, 4),(4, 1),(1, 1)]]]);
|
||||
select polygonsEqualsCartesian([[[(1, 1),(1, 4),(4, 4),(4, 1)]]], [[[(1, 1),(1, 4),(4, 4),(4, 1),(1, 1)]]]);
|
Loading…
Reference in New Issue
Block a user