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

Method mapScanNodeTable

src/processor/map/map_scan_node_table.cpp:20–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18namespace processor {
19
20std::unique_ptr<PhysicalOperator> PlanMapper::mapScanNodeTable(
21 const LogicalOperator* logicalOperator) {
22 auto storageManager = storage::StorageManager::Get(*clientContext);
23 auto catalog = catalog::Catalog::Get(*clientContext);
24 auto transaction = transaction::Transaction::Get(*clientContext);
25 auto& scan = logicalOperator->constCast<LogicalScanNodeTable>();
26 const auto outSchema = scan.getSchema();
27 auto nodeIDPos = getDataPos(*scan.getNodeID(), *outSchema);
28 std::vector<DataPos> outVectorsPos;
29 for (auto& expression : scan.getProperties()) {
30 outVectorsPos.emplace_back(getDataPos(*expression, *outSchema));
31 }
32 auto scanInfo = ScanOpInfo(nodeIDPos, outVectorsPos);
33 const auto tableIDs = scan.getTableIDs();
34 std::vector<std::string> tableNames;
35 std::vector<ScanNodeTableInfo> tableInfos;
36 auto binder = Binder(clientContext);
37 auto expressionBinder = ExpressionBinder(&binder, clientContext);
38 for (const auto& tableID : tableIDs) {
39 auto tableEntry = catalog->getTableCatalogEntry(transaction, tableID);
40 tableNames.push_back(tableEntry->getName());
41 auto table = storageManager->getTable(tableID)->ptrCast<storage::NodeTable>();
42 auto tableInfo = ScanNodeTableInfo(table, copyVector(scan.getPropertyPredicates()));
43 for (auto& expr : scan.getProperties()) {
44 auto& property = expr->constCast<PropertyExpression>();
45 if (property.hasProperty(tableEntry->getTableID())) {
46 auto propertyName = property.getPropertyName();
47 if (!tableEntry->containsProperty(propertyName) &&
48 tableEntry->containsProperty("data")) {
49 auto columnCaster = ColumnCaster(LogicalType::JSON());
50 columnCaster.setJSONExtract(propertyName);
51 tableInfo.addColumnInfo(tableEntry->getColumnID("data"),
52 std::move(columnCaster));
53 continue;
54 }
55 auto& columnType = tableEntry->getProperty(propertyName).getType();
56 auto columnCaster = ColumnCaster(columnType.copy());
57 if (property.getDataType() != columnType) {
58 auto columnExpr = std::make_shared<PropertyExpression>(property);
59 columnExpr->dataType = columnType.copy();
60 columnCaster.setCastExpr(
61 expressionBinder.forceCast(columnExpr, property.getDataType()));
62 }
63 tableInfo.addColumnInfo(tableEntry->getColumnID(propertyName),
64 std::move(columnCaster));
65 } else {
66 tableInfo.addColumnInfo(INVALID_COLUMN_ID, ColumnCaster(LogicalType::ANY()));
67 }
68 }
69 tableInfos.push_back(std::move(tableInfo));
70 }
71 std::vector<std::shared_ptr<ScanNodeTableSharedState>> sharedStates;
72 for (auto& tableID : tableIDs) {
73 auto table = storageManager->getTable(tableID)->ptrCast<storage::NodeTable>();
74 auto semiMask = SemiMaskUtil::createMask(table->getNumTotalRows(transaction));
75 sharedStates.push_back(std::make_shared<ScanNodeTableSharedState>(std::move(semiMask)));
76 }
77 auto alias = scan.getNodeID()->cast<PropertyExpression>().getRawVariableName();

Callers

nothing calls this directly

Calls 15

ScanOpInfoClass · 0.85
ScanNodeTableInfoClass · 0.85
copyVectorFunction · 0.85
ColumnCasterClass · 0.85
getOperatorIDFunction · 0.85
ExpressionMapperClass · 0.85
emplace_backMethod · 0.80
getTableCatalogEntryMethod · 0.80
hasPropertyMethod · 0.80
containsPropertyMethod · 0.80
setJSONExtractMethod · 0.80
addColumnInfoMethod · 0.80

Tested by

no test coverage detected