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

Method bindNodeTableEntries

src/binder/bind/bind_graph_pattern.cpp:658–694  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

656}
657
658std::pair<std::vector<TableCatalogEntry*>, std::unordered_map<TableCatalogEntry*, std::string>>
659Binder::bindNodeTableEntries(const std::vector<std::string>& tableNames) const {
660 auto transaction = transaction::Transaction::Get(*clientContext);
661 auto catalog = Catalog::Get(*clientContext);
662 auto useInternal = clientContext->useInternalCatalogEntry();
663 table_catalog_entry_set_t entrySet;
664 std::unordered_map<TableCatalogEntry*, std::string> dbNames;
665 if (tableNames.empty()) { // Rewrite as all node tables in database.
666 for (auto entry : catalog->getNodeTableEntries(transaction, useInternal)) {
667 entrySet.insert(entry);
668 }
669 auto dbManager = main::DatabaseManager::Get(*clientContext);
670 for (auto attachedDB : dbManager->getAttachedDatabases()) {
671 auto attachedCatalog = attachedDB->getCatalog();
672 for (auto entry : attachedCatalog->getTableEntries(transaction, useInternal)) {
673 if (entry->getType() == CatalogEntryType::FOREIGN_TABLE_ENTRY) {
674 entrySet.insert(entry);
675 dbNames[entry] = attachedDB->getDBName();
676 }
677 }
678 }
679 } else {
680 for (auto& name : tableNames) {
681 auto [entry, dbName] = bindNodeTableEntry(name);
682 if (entry->getType() != CatalogEntryType::NODE_TABLE_ENTRY &&
683 entry->getType() != CatalogEntryType::FOREIGN_TABLE_ENTRY) {
684 throw BinderException(
685 std::format("Cannot bind {} as a node pattern label.", entry->getName()));
686 }
687 entrySet.insert(entry);
688 if (!dbName.empty()) {
689 dbNames[entry] = dbName;
690 }
691 }
692 }
693 return {sortEntries(entrySet), std::move(dbNames)};
694}
695
696std::pair<TableCatalogEntry*, std::string> Binder::bindNodeTableEntry(
697 const std::string& name) const {

Callers

nothing calls this directly

Calls 10

sortEntriesFunction · 0.85
getNodeTableEntriesMethod · 0.80
getAttachedDatabasesMethod · 0.80
getCatalogMethod · 0.80
getTableEntriesMethod · 0.80
emptyMethod · 0.45
insertMethod · 0.45
getTypeMethod · 0.45
getDBNameMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected