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

Method checkIfNodeHasRels

src/storage/table/rel_table_data.cpp:197–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197bool RelTableData::checkIfNodeHasRels(Transaction* transaction,
198 ValueVector* srcNodeIDVector) const {
199 DASSERT(srcNodeIDVector->state->isFlat());
200 const auto nodeIDPos = srcNodeIDVector->state->getSelVector()[0];
201 const auto nodeOffset = srcNodeIDVector->getValue<nodeID_t>(nodeIDPos).offset;
202 const auto nodeGroupIdx = StorageUtils::getNodeGroupIdx(nodeOffset);
203 if (nodeGroupIdx >= getNumNodeGroups()) {
204 return false;
205 }
206 DataChunk scanChunk(1);
207 // RelID output vector.
208 scanChunk.insert(0, std::make_shared<ValueVector>(LogicalType::INTERNAL_ID()));
209 std::vector columnIDs = {REL_ID_COLUMN_ID};
210 std::vector<const Column*> columns{getColumn(REL_ID_COLUMN_ID)};
211 auto scanState = std::make_unique<RelTableScanState>(*mm, srcNodeIDVector,
212 std::vector{&scanChunk.getValueVectorMutable(0)}, scanChunk.state, true /*randomLookup*/);
213 scanState->setToTable(transaction, &table, columnIDs, {}, direction);
214 scanState->initState(transaction, getNodeGroup(nodeGroupIdx));
215 while (true) {
216 const auto scanResult = scanState->nodeGroup->scan(transaction, *scanState);
217 if (scanResult == NODE_GROUP_SCAN_EMPTY_RESULT) {
218 break;
219 }
220 if (scanState->outState->getSelVector().getSelSize() > 0) {
221 return true;
222 }
223 }
224 return false;
225}
226
227// NOLINTNEXTLINE(readability-make-member-function-const): Semantically non-const.
228void RelTableData::pushInsertInfo(const Transaction* transaction, const CSRNodeGroup& nodeGroup,

Callers

nothing calls this directly

Calls 9

getNumNodeGroupsFunction · 0.85
getNodeGroupFunction · 0.85
initStateMethod · 0.80
getSelSizeMethod · 0.80
getColumnFunction · 0.50
isFlatMethod · 0.45
insertMethod · 0.45
setToTableMethod · 0.45
scanMethod · 0.45

Tested by

no test coverage detected