Skip to content

Commit 831c174

Browse files
E2ern1tyfansehep
andauthored
fix cmake error in pr #5846 (#5955)
* feat(function): support md5 (cherry picked from commit 84bb690) * format code Signed-off-by: alexsehep <[email protected]> (cherry picked from commit d2b17d4) * clean cmake option Signed-off-by: alexsehep <[email protected]> (cherry picked from commit 993bea6) * fix cmake Signed-off-by: alexsehep <[email protected]> (cherry picked from commit e607095) * fix cmake error in #5846 --------- Co-authored-by: alexsehep <[email protected]>
1 parent 41b095e commit 831c174

File tree

8 files changed

+39
-3
lines changed

8 files changed

+39
-3
lines changed

src/common/base/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ nebula_add_executable(
120120
LIBRARIES
121121
follybenchmark
122122
${THRIFT_LIBRARIES}
123+
${PROXYGEN_LIBRARIES}
123124
)
124125

125126
nebula_add_test(

src/common/datatypes/test/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ nebula_add_test(
5252
LIBRARIES
5353
gtest
5454
${THRIFT_LIBRARIES}
55+
${PROXYGEN_LIBRARIES}
5556
)
5657

5758

@@ -73,6 +74,7 @@ nebula_add_test(
7374
LIBRARIES
7475
gtest
7576
${THRIFT_LIBRARIES}
77+
${PROXYGEN_LIBRARIES}
7678
)
7779

7880
nebula_add_test(
@@ -122,6 +124,7 @@ nebula_add_test(
122124
LIBRARIES
123125
gtest
124126
${THRIFT_LIBRARIES}
127+
${PROXYGEN_LIBRARIES}
125128
)
126129

127130
nebula_add_executable(

src/common/expression/test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ nebula_add_executable(
138138
follybenchmark
139139
boost_regex
140140
${THRIFT_LIBRARIES}
141+
${PROXYGEN_LIBRARIES}
141142
)
142143

143144
nebula_add_executable(
@@ -163,4 +164,5 @@ nebula_add_executable(
163164
follybenchmark
164165
boost_regex
165166
${THRIFT_LIBRARIES}
167+
${PROXYGEN_LIBRARIES}
166168
)

src/common/function/FunctionManager.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <float.h>
99
#include <folly/json.h>
10+
#include <proxygen/lib/utils/CryptUtil.h>
1011

1112
#include <boost/algorithm/string.hpp>
1213
#include <boost/algorithm/string/replace.hpp>
@@ -442,9 +443,9 @@ std::unordered_map<std::string, std::vector<TypeSignature>> FunctionManager::typ
442443
{TypeSignature({Value::Type::STRING}, Value::Type::MAP),
443444
TypeSignature({Value::Type::STRING}, Value::Type::NULLVALUE)}},
444445
{"score", {TypeSignature({}, Value::Type::__EMPTY__)}},
446+
{"md5", {TypeSignature({Value::Type::STRING}, Value::Type::STRING)}},
445447
};
446448

447-
// static
448449
StatusOr<Value::Type> FunctionManager::getReturnType(const std::string &funcName,
449450
const std::vector<Value::Type> &argsType) {
450451
auto func = funcName;
@@ -3000,6 +3001,26 @@ FunctionManager::FunctionManager() {
30003001
return Value::kNullValue;
30013002
};
30023003
}
3004+
{
3005+
auto &attr = functions_["md5"];
3006+
attr.minArity_ = 1;
3007+
attr.maxArity_ = 1;
3008+
attr.isAlwaysPure_ = true;
3009+
attr.body_ = [](const auto &args) -> Value {
3010+
switch (args[0].get().type()) {
3011+
case Value::Type::NULLVALUE: {
3012+
return Value::kNullValue;
3013+
}
3014+
case Value::Type::STRING: {
3015+
std::string value(args[0].get().getStr());
3016+
return proxygen::md5Encode(folly::StringPiece(value));
3017+
}
3018+
default: {
3019+
return Value::kNullBadType;
3020+
}
3021+
}
3022+
};
3023+
}
30033024
} // NOLINT
30043025

30053026
// static

src/common/function/test/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ nebula_add_test(
1919
LIBRARIES
2020
gtest
2121
gtest_main
22+
${PROXYGEN_LIBRARIES}
2223
)
2324

2425
nebula_add_test(
@@ -37,6 +38,7 @@ nebula_add_test(
3738
$<TARGET_OBJECTS:fs_obj>
3839
LIBRARIES
3940
gtest
41+
${PROXYGEN_LIBRARIES}
4042
)
4143

4244
nebula_add_test(
@@ -52,5 +54,6 @@ nebula_add_test(
5254
LIBRARIES
5355
gtest
5456
gtest_main
57+
${PROXYGEN_LIBRARIES}
5558
)
5659

src/common/function/test/FunctionManagerTest.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ std::unordered_map<std::string, std::vector<Value>> FunctionManagerTest::args_ =
170170
{"json_extract1", {"{\"a\": 1, \"b\": 0.2, \"c\": {\"d\": true}}"}},
171171
{"json_extract2", {"_"}},
172172
{"json_extract3", {"{a: 1, \"b\": 0.2}"}},
173-
{"json_extract4", {"{\"a\": \"foo\", \"b\": 0.2, \"c\": {\"d\": {\"e\": 0.1}}}"}}};
174-
173+
{"json_extract4", {"{\"a\": \"foo\", \"b\": 0.2, \"c\": {\"d\": {\"e\": 0.1}}}"}},
174+
{"md5", {"abcdefghijkl"}}};
175175
#define TEST_FUNCTION(expr, ...) \
176176
do { \
177177
EXPECT_TRUE(testFunction(#expr, __VA_ARGS__)); \
@@ -248,6 +248,7 @@ TEST_F(FunctionManagerTest, testNull) {
248248
TEST_FUNCTION(concat, args_["nullvalue"], Value::kNullValue);
249249
TEST_FUNCTION(concat_ws, std::vector<Value>({Value::kNullValue, 1, 2}), Value::kNullValue);
250250
TEST_FUNCTION(concat_ws, std::vector<Value>({1, 1, 2}), Value::kNullValue);
251+
TEST_FUNCTION(md5, args_["nullvalue"], Value::kNullValue);
251252
}
252253

253254
TEST_F(FunctionManagerTest, functionCall) {
@@ -474,6 +475,7 @@ TEST_F(FunctionManagerTest, functionCall) {
474475
args_["json_extract4"],
475476
Value(Map({{"a", Value("foo")}, {"b", Value(0.2)}, {"c", Value(Map())}})));
476477
}
478+
{ TEST_FUNCTION(md5, args_["md5"], "9fc9d606912030dca86582ed62595cf7"); }
477479
{
478480
auto result = FunctionManager::get("hash", 1);
479481
ASSERT_TRUE(result.ok());

src/common/geo/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ nebula_add_test(
1818
LIBRARIES
1919
gtest
2020
gtest_main
21+
${PROXYGEN_LIBRARIES}
2122
)
2223

2324
nebula_add_test(

src/common/utils/test/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ nebula_add_test(
4040
LIBRARIES
4141
gtest
4242
${THRIFT_LIBRARIES}
43+
${PROXYGEN_LIBRARIES}
4344
)
4445

4546
nebula_add_test(
@@ -80,6 +81,7 @@ nebula_add_test(
8081
LIBRARIES
8182
gtest
8283
${THRIFT_LIBRARIES}
84+
${PROXYGEN_LIBRARIES}
8385
)
8486

8587
nebula_add_test(
@@ -123,6 +125,7 @@ nebula_add_test(
123125
LIBRARIES
124126
gtest
125127
${THRIFT_LIBRARIES}
128+
${PROXYGEN_LIBRARIES}
126129
)
127130

128131
nebula_add_test(

0 commit comments

Comments
 (0)