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

Method bindRelGroupEntries

src/binder/bind/bind_graph_pattern.cpp:747–795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

745}
746
747std::vector<TableCatalogEntry*> Binder::bindRelGroupEntries(
748 const std::vector<std::string>& tableNames) const {
749 auto transaction = transaction::Transaction::Get(*clientContext);
750 auto useInternal = clientContext->useInternalCatalogEntry();
751
752 // Check if there's a default graph set and use its catalog
753 auto dbManager = main::DatabaseManager::Get(*clientContext);
754 catalog::Catalog* catalog = nullptr;
755 auto defaultGraphCatalog = dbManager->getDefaultGraphCatalog();
756 if (defaultGraphCatalog != nullptr) {
757 catalog = defaultGraphCatalog;
758 } else {
759 catalog = Catalog::Get(*clientContext);
760 }
761
762 table_catalog_entry_set_t entrySet;
763 if (tableNames.empty()) { // Rewrite as all rel groups in database.
764 for (auto entry : catalog->getRelGroupEntries(transaction, useInternal)) {
765 entrySet.insert(entry);
766 }
767 for (auto attachedDB : dbManager->getAttachedDatabases()) {
768 auto attachedCatalog = attachedDB->getCatalog();
769 for (auto entry : attachedCatalog->getRelGroupEntries(transaction, useInternal)) {
770 entrySet.insert(entry);
771 }
772 }
773 } else {
774 for (auto& name : tableNames) {
775 if (catalog->containsTable(transaction, name)) {
776 auto entry = catalog->getTableCatalogEntry(transaction, name, useInternal);
777 if (entry->getType() != CatalogEntryType::REL_GROUP_ENTRY) {
778 throw BinderException(std::format(
779 "Cannot bind {} as a relationship pattern label.", entry->getName()));
780 }
781 entrySet.insert(entry);
782 } else {
783 // Check if this is an ANY graph (has _edges table)
784 // In ANY graphs, labels are stored dynamically in the _edges table
785 if (catalog->containsTable(transaction, "_edges", useInternal)) {
786 auto entry = catalog->getTableCatalogEntry(transaction, "_edges", useInternal);
787 entrySet.insert(entry);
788 } else {
789 throw BinderException(std::format("Table {} does not exist.", name));
790 }
791 }
792 }
793 }
794 return sortEntries(entrySet);
795}
796
797} // namespace binder
798} // namespace lbug

Callers

nothing calls this directly

Calls 11

sortEntriesFunction · 0.85
getRelGroupEntriesMethod · 0.80
getAttachedDatabasesMethod · 0.80
getCatalogMethod · 0.80
containsTableMethod · 0.80
getTableCatalogEntryMethod · 0.80
emptyMethod · 0.45
insertMethod · 0.45
getTypeMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected