-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1291 from kuzudb/offset-function
Add internal offset function
- Loading branch information
Showing
7 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include "common/type_utils.h" | ||
|
||
namespace kuzu { | ||
namespace function { | ||
namespace operation { | ||
|
||
struct Offset { | ||
static inline void operation(common::internalID_t& input, int64_t& result) { | ||
result = input.offset; | ||
} | ||
}; | ||
|
||
} // namespace operation | ||
} // namespace function | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include "function/vector_operations.h" | ||
#include "offset_operations.h" | ||
|
||
namespace kuzu { | ||
namespace function { | ||
|
||
struct OffsetVectorOperation : public VectorOperations { | ||
static void execFunction(const std::vector<std::shared_ptr<common::ValueVector>>& params, | ||
common::ValueVector& result) { | ||
assert(params.size() == 1); | ||
UnaryOperationExecutor::execute<common::internalID_t, int64_t, operation::Offset>( | ||
*params[0], result); | ||
} | ||
|
||
static std::vector<std::unique_ptr<VectorOperationDefinition>> getDefinitions() { | ||
std::vector<std::unique_ptr<VectorOperationDefinition>> definitions; | ||
definitions.push_back(make_unique<VectorOperationDefinition>(common::OFFSET_FUNC_NAME, | ||
std::vector<common::DataTypeID>{common::INTERNAL_ID}, common::INT64, | ||
OffsetVectorOperation::execFunction)); | ||
return definitions; | ||
} | ||
}; | ||
|
||
} // namespace function | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-NAME NodeOffsetTest1 | ||
-QUERY MATCH (a:person) RETURN id(a), offset(id(a)) | ||
---- 8 | ||
0:0|0 | ||
0:1|1 | ||
0:2|2 | ||
0:3|3 | ||
0:4|4 | ||
0:5|5 | ||
0:6|6 | ||
0:7|7 | ||
|
||
-NAME NodeOffsetTest2 | ||
-QUERY MATCH (a:organisation) RETURN id(a), offset(id(a)) | ||
---- 3 | ||
1:0|0 | ||
1:1|1 | ||
1:2|2 | ||
|
||
-NAME NodeOffsetTest3 | ||
-QUERY MATCH (a:person) WHERE offset(id(a))=0 RETURN a.fName | ||
---- 1 | ||
Alice | ||
|
||
-NAME RelOffsetTest2 | ||
-QUERY MATCH (:person)-[e:studyAt]->(:organisation) RETURN id(e), offset(id(e)) | ||
---- 3 | ||
4:0|0 | ||
4:1|1 | ||
4:2|2 |