Support H3 in Arcadia

This commit is contained in:
Ivan Lezhankin 2020-06-19 13:06:42 +03:00
parent d29e1ce986
commit 747a3bb0e8
16 changed files with 137 additions and 173 deletions

View File

@ -6,6 +6,24 @@ add_headers_and_sources(clickhouse_functions .)
list(REMOVE_ITEM clickhouse_functions_sources IFunctionImpl.cpp FunctionFactory.cpp FunctionHelpers.cpp)
list(REMOVE_ITEM clickhouse_functions_headers IFunctionImpl.h FunctionFactory.h FunctionHelpers.h)
if (NOT USE_H3)
list (REMOVE_ITEM clickhouse_functions_sources
geoToH3.cpp
h3EdgeAngle.cpp
h3EdgeLengthM.cpp
h3GetBaseCell.cpp
h3GetResolution.cpp
h3HexAreaM2.cpp
h3IndexesAreNeighbors.cpp
h3IsValid.cpp
h3kRing.cpp
h3ToChildren.cpp
h3ToParent.cpp
h3ToString.cpp
stringToH3.cpp
)
endif ()
add_library(clickhouse_functions ${clickhouse_functions_sources})
target_link_libraries(clickhouse_functions

View File

@ -1,5 +1,3 @@
#include "config_functions.h"
#if USE_H3
#include <array>
#include <math.h>
#include <Columns/ColumnConst.h>
@ -10,11 +8,7 @@
#include <Common/typeid_cast.h>
#include <ext/range.h>
#if __has_include(<h3/h3api.h>)
# include <h3/h3api.h>
#else
# include <h3api.h>
#endif
#include <h3api.h>
namespace DB
@ -97,4 +91,3 @@ void registerFunctionGeoToH3(FunctionFactory & factory)
}
}
#endif

View File

@ -1,20 +1,13 @@
#include "config_functions.h"
#if USE_H3
# include <Columns/ColumnsNumber.h>
# include <DataTypes/DataTypesNumber.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <Common/typeid_cast.h>
# include <IO/WriteHelpers.h>
# include <ext/range.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <IO/WriteHelpers.h>
#include <Common/typeid_cast.h>
#include <ext/range.h>
# if __has_include(<h3/h3api.h>)
# include <h3/h3api.h>
# include <h3/constants.h>
# else
# include <h3api.h>
# include <constants.h>
# endif
#include <constants.h>
#include <h3api.h>
namespace DB
@ -80,4 +73,3 @@ void registerFunctionH3EdgeAngle(FunctionFactory & factory)
}
}
#endif

View File

@ -1,20 +1,13 @@
#include "config_functions.h"
#if USE_H3
# include <Columns/ColumnsNumber.h>
# include <DataTypes/DataTypesNumber.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <IO/WriteHelpers.h>
# include <Common/typeid_cast.h>
# include <ext/range.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <IO/WriteHelpers.h>
#include <Common/typeid_cast.h>
#include <ext/range.h>
# if __has_include(<h3/h3api.h>)
# include <h3/h3api.h>
# include <h3/constants.h>
# else
# include <h3api.h>
# include <constants.h>
# endif
#include <constants.h>
#include <h3api.h>
namespace DB
@ -85,4 +78,3 @@ void registerFunctionH3EdgeLengthM(FunctionFactory & factory)
}
}
#endif

View File

@ -1,13 +1,11 @@
#include "config_functions.h"
#if USE_H3
# include <Columns/ColumnsNumber.h>
# include <DataTypes/DataTypesNumber.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <Common/typeid_cast.h>
# include <ext/range.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <Common/typeid_cast.h>
#include <ext/range.h>
# include <h3api.h>
#include <h3api.h>
namespace DB
@ -67,4 +65,3 @@ void registerFunctionH3GetBaseCell(FunctionFactory & factory)
}
}
#endif

View File

@ -1,17 +1,11 @@
#include "config_functions.h"
#if USE_H3
# include <Columns/ColumnsNumber.h>
# include <DataTypes/DataTypesNumber.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <Common/typeid_cast.h>
# include <ext/range.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <Common/typeid_cast.h>
#include <ext/range.h>
# if __has_include(<h3/h3api.h>)
# include <h3/h3api.h>
# else
# include <h3api.h>
# endif
#include <h3api.h>
namespace DB
@ -71,4 +65,3 @@ void registerFunctionH3GetResolution(FunctionFactory & factory)
}
}
#endif

View File

@ -1,21 +1,13 @@
#include "config_functions.h"
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <IO/WriteHelpers.h>
#include <Common/typeid_cast.h>
#include <ext/range.h>
#if USE_H3
# include <Columns/ColumnsNumber.h>
# include <DataTypes/DataTypesNumber.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <IO/WriteHelpers.h>
# include <Common/typeid_cast.h>
# include <ext/range.h>
# if __has_include(<h3/h3api.h>)
# include <h3/h3api.h>
# include <h3/constants.h>
# else
# include <h3api.h>
# include <constants.h>
# endif
#include <constants.h>
#include <h3api.h>
namespace DB
@ -81,4 +73,3 @@ void registerFunctionH3HexAreaM2(FunctionFactory & factory)
}
}
#endif

View File

@ -1,13 +1,11 @@
#include "config_functions.h"
#if USE_H3
# include <Columns/ColumnsNumber.h>
# include <DataTypes/DataTypesNumber.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <Common/typeid_cast.h>
# include <ext/range.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <Common/typeid_cast.h>
#include <ext/range.h>
# include <h3api.h>
#include <h3api.h>
namespace DB
@ -75,4 +73,3 @@ void registerFunctionH3IndexesAreNeighbors(FunctionFactory & factory)
}
}
#endif

View File

@ -1,17 +1,11 @@
#include "config_functions.h"
#if USE_H3
# include <Columns/ColumnsNumber.h>
# include <DataTypes/DataTypesNumber.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <Common/typeid_cast.h>
# include <ext/range.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <Common/typeid_cast.h>
#include <ext/range.h>
# if __has_include(<h3/h3api.h>)
# include <h3/h3api.h>
# else
# include <h3api.h>
# endif
#include <h3api.h>
namespace DB
@ -71,4 +65,3 @@ void registerFunctionH3IsValid(FunctionFactory & factory)
}
}
#endif

View File

@ -1,15 +1,13 @@
#include "config_functions.h"
#if USE_H3
# include <Columns/ColumnArray.h>
# include <Columns/ColumnsNumber.h>
# include <DataTypes/DataTypeArray.h>
# include <DataTypes/DataTypesNumber.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <Common/typeid_cast.h>
# include <ext/range.h>
#include <Columns/ColumnArray.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypeArray.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <Common/typeid_cast.h>
#include <ext/range.h>
# include <h3api.h>
#include <h3api.h>
namespace DB
@ -92,4 +90,3 @@ void registerFunctionH3ToChildren(FunctionFactory & factory)
}
}
#endif

View File

@ -1,13 +1,11 @@
#include "config_functions.h"
#if USE_H3
# include <Columns/ColumnsNumber.h>
# include <DataTypes/DataTypesNumber.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <Common/typeid_cast.h>
# include <ext/range.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <Common/typeid_cast.h>
#include <ext/range.h>
# include <h3api.h>
#include <h3api.h>
namespace DB
@ -75,4 +73,3 @@ void registerFunctionH3ToParent(FunctionFactory & factory)
}
}
#endif

View File

@ -1,14 +1,12 @@
#include "config_functions.h"
#if USE_H3
# include <Columns/ColumnString.h>
# include <DataTypes/DataTypeString.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <Common/typeid_cast.h>
#include <Columns/ColumnString.h>
#include <DataTypes/DataTypeString.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <Common/typeid_cast.h>
# include <h3api.h>
#include <h3api.h>
# define H3_INDEX_STRING_LENGTH 17 // includes \0 terminator
#define H3_INDEX_STRING_LENGTH 17 // includes \0 terminator
namespace DB
{
@ -83,4 +81,3 @@ void registerFunctionH3ToString(FunctionFactory & factory)
}
}
#endif

View File

@ -1,21 +1,15 @@
#include "config_functions.h"
#if USE_H3
# include <vector>
# include <Columns/ColumnArray.h>
# include <Columns/ColumnsNumber.h>
# include <DataTypes/DataTypeArray.h>
# include <DataTypes/DataTypesNumber.h>
# include <DataTypes/IDataType.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <Common/typeid_cast.h>
# include <ext/range.h>
#include <vector>
#include <Columns/ColumnArray.h>
#include <Columns/ColumnsNumber.h>
#include <DataTypes/DataTypeArray.h>
#include <DataTypes/DataTypesNumber.h>
#include <DataTypes/IDataType.h>
#include <Functions/FunctionFactory.h>
#include <Functions/IFunction.h>
#include <Common/typeid_cast.h>
#include <ext/range.h>
# if __has_include(<h3/h3api.h>)
# include <h3/h3api.h>
# else
# include <h3api.h>
# endif
#include <h3api.h>
namespace DB
@ -98,4 +92,3 @@ void registerFunctionH3KRing(FunctionFactory & factory)
}
}
#endif

View File

@ -1,15 +1,13 @@
#include "config_functions.h"
#if USE_H3
# include <Functions/GatherUtils/GatherUtils.h>
# include <Functions/GatherUtils/Sources.h>
# include <DataTypes/DataTypeString.h>
# include <DataTypes/DataTypesNumber.h>
# include <Columns/ColumnString.h>
# include <Functions/FunctionFactory.h>
# include <Functions/IFunction.h>
# include <Common/typeid_cast.h>
#include <Columns/ColumnString.h>
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypesNumber.h>
#include <Functions/FunctionFactory.h>
#include <Functions/GatherUtils/GatherUtils.h>
#include <Functions/GatherUtils/Sources.h>
#include <Functions/IFunction.h>
#include <Common/typeid_cast.h>
# include <h3api.h>
#include <h3api.h>
namespace DB
@ -99,4 +97,3 @@ void registerFunctionStringToH3(FunctionFactory & factory)
}
}
#endif

View File

@ -2,12 +2,13 @@
LIBRARY()
CFLAGS(
-DUSE_SSL -DUSE_XXHASH
-DUSE_H3 -DUSE_SSL -DUSE_XXHASH
)
ADDINCL(
library/cpp/consistent_hashing
contrib/libs/farmhash
contrib/libs/h3/h3lib/include
contrib/libs/hyperscan/src
contrib/libs/icu/common
contrib/libs/libdivide
@ -20,6 +21,7 @@ PEERDIR(
clickhouse/src/Dictionaries
contrib/libs/farmhash
contrib/libs/fastops/fastops
contrib/libs/h3
contrib/libs/hyperscan
contrib/libs/icu
contrib/libs/libdivide
@ -194,6 +196,7 @@ SRCS(
geohashDecode.cpp
geohashEncode.cpp
geohashesInBox.cpp
geoToH3.cpp
getMacro.cpp
getScalar.cpp
getSizeOfEnumType.cpp
@ -201,6 +204,17 @@ SRCS(
greater.cpp
greaterOrEquals.cpp
greatest.cpp
h3EdgeAngle.cpp
h3EdgeLengthM.cpp
h3GetBaseCell.cpp
h3GetResolution.cpp
h3HexAreaM2.cpp
h3IndexesAreNeighbors.cpp
h3IsValid.cpp
h3kRing.cpp
h3ToChildren.cpp
h3ToParent.cpp
h3ToString.cpp
hasColumnInTable.cpp
hasTokenCaseInsensitive.cpp
hasToken.cpp
@ -337,6 +351,7 @@ SRCS(
sleepEachRow.cpp
sqrt.cpp
startsWith.cpp
stringToH3.cpp
substring.cpp
subtractDays.cpp
subtractHours.cpp

View File

@ -1,12 +1,13 @@
LIBRARY()
CFLAGS(
-DUSE_SSL -DUSE_XXHASH
-DUSE_H3 -DUSE_SSL -DUSE_XXHASH
)
ADDINCL(
library/cpp/consistent_hashing
contrib/libs/farmhash
contrib/libs/h3/h3lib/include
contrib/libs/hyperscan/src
contrib/libs/icu/common
contrib/libs/libdivide
@ -19,6 +20,7 @@ PEERDIR(
clickhouse/src/Dictionaries
contrib/libs/farmhash
contrib/libs/fastops/fastops
contrib/libs/h3
contrib/libs/hyperscan
contrib/libs/icu
contrib/libs/libdivide
@ -30,7 +32,7 @@ PEERDIR(
# "Arcadia" build is slightly deficient. It lacks many libraries that we need.
SRCS(
<? find . -name '*.cpp' | grep -i -v -P 'tests|h3|Bitmap|sumbur' | sed 's/^\.\// /' | sort ?>
<? find . -name '*.cpp' | grep -i -v -P 'tests|Bitmap|sumbur' | sed 's/^\.\// /' | sort ?>
)
END()