-
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.
add recursive join no track path optimization
- Loading branch information
1 parent
d8d5152
commit fa8dcd6
Showing
18 changed files
with
470 additions
and
267 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
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
56 changes: 56 additions & 0 deletions
56
src/include/processor/operator/recursive_extend/frontier.h
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,56 @@ | ||
#pragma once | ||
|
||
#include <unordered_map> | ||
|
||
#include "common/types/types_include.h" | ||
|
||
namespace kuzu { | ||
namespace processor { | ||
|
||
/* | ||
* A Frontier can stores dst node offsets, its multiplicity and its bwd edges. Note that we don't | ||
* need to track all information in BFS computation. | ||
* | ||
* Computation | Information tracked | ||
* Shortest path track path | nodeOffsets & bwdEdges | ||
* Shortest path NOT track path | nodeOffsets | ||
* Var length track path | nodeOffsets & bwdEdges | ||
* Var length NOT track path | nodeOffsets & offsetToMultiplicity | ||
*/ | ||
struct Frontier { | ||
std::vector<common::offset_t> nodeOffsets; | ||
std::unordered_map<common::offset_t, std::vector<common::offset_t>> bwdEdges; | ||
std::unordered_map<common::offset_t, uint64_t> offsetToMultiplicity; | ||
|
||
inline void resetState() { | ||
nodeOffsets.clear(); | ||
bwdEdges.clear(); | ||
offsetToMultiplicity.clear(); | ||
} | ||
|
||
inline void addNode(common::offset_t offset) { nodeOffsets.push_back(offset); } | ||
|
||
inline void addEdge(common::offset_t boundOffset, common::offset_t nbrOffset) { | ||
if (!bwdEdges.contains(nbrOffset)) { | ||
nodeOffsets.push_back(nbrOffset); | ||
bwdEdges.insert({nbrOffset, std::vector<common::offset_t>{}}); | ||
} | ||
bwdEdges.at(nbrOffset).push_back(boundOffset); | ||
} | ||
|
||
inline void addNodeWithMultiplicity(common::offset_t offset, uint64_t multiplicity) { | ||
if (offsetToMultiplicity.contains(offset)) { | ||
offsetToMultiplicity.at(offset) += multiplicity; | ||
} else { | ||
offsetToMultiplicity.insert({offset, multiplicity}); | ||
nodeOffsets.push_back(offset); | ||
} | ||
} | ||
|
||
inline uint64_t getMultiplicity(common::offset_t offset) const { | ||
return offsetToMultiplicity.empty() ? 1 : offsetToMultiplicity.at(offset); | ||
} | ||
}; | ||
|
||
} // namespace processor | ||
} // namespace kuzu |
Oops, something went wrong.