Skip to content

Commit

Permalink
Fix on review
Browse files Browse the repository at this point in the history
  • Loading branch information
manh9203 committed Apr 5, 2024
1 parent 33cf40b commit 2f898b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/include/function/hash/functions/md5_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ namespace kuzu {
namespace function {

struct MD5Operator {
static inline void operation(
ku_string_t& operand, ku_string_t& result, ValueVector& resultVector) {
static void operation(ku_string_t& operand, ku_string_t& result, ValueVector& resultVector) {
MD5 hasher;
hasher.addToMD5(reinterpret_cast<const char*>(operand.getData()));
StringVector::addString(&resultVector, result, std::string(hasher.finishMD5()));
Expand Down
4 changes: 1 addition & 3 deletions src/include/function/hash/functions/sha256_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ namespace kuzu {
namespace function {

struct SHA256Operator {
static inline void operation(
ku_string_t& operand, ku_string_t& result, ValueVector& resultVector) {
static void operation(ku_string_t& operand, ku_string_t& result, ValueVector& resultVector) {
StringVector::reserveString(&resultVector, result, SHA256::SHA256_HASH_LENGTH_TEXT);

SHA256 hasher;
hasher.addString(operand.getAsString());
hasher.finishSHA256(reinterpret_cast<char*>(result.getDataUnsafe()));
Expand Down
20 changes: 15 additions & 5 deletions test/test_files/function/hash/hash.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

-CASE HashFuncTests

# Bool
-LOG HashBool
-STATEMENT RETURN hash(true);
---- 1
4717996019076358352
Expand All @@ -14,7 +14,7 @@
---- 1
0

# Integer
-LOG HashInteger
-STATEMENT RETURN hash(123213213);
---- 1
5409473644860454233
Expand All @@ -23,17 +23,27 @@
---- 1
6017956686658665710

# Double
-LOG HashDouble
-STATEMENT RETURN hash(3.145454);
---- 1
7162734438776005526

# Interval
-LOG HashString
-STATEMENT RETURN hash('abc');
---- 1
-5315477578366381819

-LOG HashInterval
-STATEMENT RETURN hash(interval("1 years 2 months 3 hours"));
---- 1
-5050076354121952078

# List
-LOG HashStruct
-STATEMENT RETURN hash({name: 'Bob', age: 25});
---- 1
-8624809801234475505

-LOG HashList
-STATEMENT RETURN hash(list_creation(1,2,3,4,5,56,2));
---- 1
5340394995802248375

0 comments on commit 2f898b9

Please sign in to comment.