MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / writeInternal

Method writeInternal

src/function/gds/awsp_paths.cpp:62–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60 }
61
62 void writeInternal(FactorizedTable& fTable, nodeID_t dstNodeID,
63 LimitCounter* counter) override {
64 if (dstNodeID == sourceNodeID_) { // Skip writing
65 return;
66 }
67 auto firstParent = bfsGraph.getParentListHead(dstNodeID.offset);
68 if (firstParent == nullptr) { // Skip if dst is not visited.
69 return;
70 }
71 if (firstParent->getCost() == std::numeric_limits<double>::max()) {
72 // Skip if dst is not visited.
73 return;
74 }
75 costVector->setValue<double>(0, firstParent->getCost());
76 std::vector<ParentList*> curPath;
77 curPath.push_back(firstParent);
78 auto backtracking = false;
79 while (!curPath.empty()) {
80 if (context->interrupted()) {
81 throw InterruptException{};
82 }
83 if (curPath[curPath.size() - 1]->getCost() == 0) { // Find source. Start writing path.
84 curPath.pop_back();
85 writePath(curPath);
86 fTable.append(vectors);
87 if (updateCounterAndTerminate(counter)) {
88 return;
89 }
90 backtracking = true;
91 }
92 auto topIdx = curPath.size() - 1;
93 if (backtracking) {
94 auto next = curPath[topIdx]->getNextPtr();
95 if (next != nullptr) { // Find next top node with the same cost.
96 DASSERT(curPath[topIdx]->getCost() == next->getCost());
97 curPath[topIdx] = next;
98 backtracking = false;
99 } else { // Move to next top.
100 curPath.pop_back();
101 }
102 } else { // Forward track fill path.
103 auto parent = bfsGraph.getParentListHead(curPath[topIdx]->getNodeID());
104 DASSERT(parent != nullptr);
105 curPath.push_back(parent);
106 backtracking = false;
107 }
108 }
109 }
110
111 std::unique_ptr<RJOutputWriter> copy() override {
112 return std::make_unique<AWSPPathsOutputWriter>(context, outputNodeMask, sourceNodeID_, info,

Callers

nothing calls this directly

Calls 9

getParentListHeadMethod · 0.80
getNextPtrMethod · 0.80
getCostMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
pop_backMethod · 0.45
appendMethod · 0.45
getNodeIDMethod · 0.45

Tested by

no test coverage detected