Skip to content

Commit

Permalink
Run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
ray6080 committed Jan 2, 2025
1 parent c6820ba commit b960c0b
Show file tree
Hide file tree
Showing 26 changed files with 84 additions and 64 deletions.
3 changes: 2 additions & 1 deletion extension/fts/src/function/fts_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ catalog::NodeTableCatalogEntry& FTSUtils::bindTable(const std::string& tableName
if (!context->getCatalog()->containsTable(context->getTransaction(), tableName)) {
throw common::BinderException{common::stringFormat("Table {} does not exist.", tableName)};
}
auto tableEntry = context->getCatalog()->getTableCatalogEntry(context->getTransaction(), tableName);
auto tableEntry =
context->getCatalog()->getTableCatalogEntry(context->getTransaction(), tableName);
if (tableEntry->getTableType() != common::TableType::NODE) {
switch (operation) {
case IndexOperation::CREATE:
Expand Down
10 changes: 6 additions & 4 deletions extension/fts/src/function/query_fts_gds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,12 @@ void QFTSAlgorithm::bind(const GDSBindInput& input, main::ClientContext& context
auto& tableEntry =
FTSUtils::bindTable(inputTableName, &context, indexName, FTSUtils::IndexOperation::QUERY);
FTSUtils::validateIndexExistence(context, tableEntry.getTableID(), indexName);
auto& ftsIndexEntry = context.getCatalog()
->getIndex(context.getTransaction(), tableEntry.getTableID(), indexName)
->constCast<FTSIndexCatalogEntry>();
auto entry = context.getCatalog()->getTableCatalogEntry(context.getTransaction(), inputTableName);
auto& ftsIndexEntry =
context.getCatalog()
->getIndex(context.getTransaction(), tableEntry.getTableID(), indexName)
->constCast<FTSIndexCatalogEntry>();
auto entry =
context.getCatalog()->getTableCatalogEntry(context.getTransaction(), inputTableName);
auto nodeOutput = bindNodeOutput(input.binder, {entry});

auto termsEntry = context.getCatalog()->getTableCatalogEntry(context.getTransaction(),
Expand Down
3 changes: 2 additions & 1 deletion src/binder/bind/bind_export_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ std::unique_ptr<BoundStatement> Binder::bindExportDatabaseClause(const Statement
auto& exportDB = statement.constCast<ExportDB>();
auto boundFilePath =
clientContext->getVFSUnsafe()->expandPath(clientContext, exportDB.getFilePath());
auto exportData = getExportInfo(*clientContext->getCatalog(), clientContext->getTransaction(), this);
auto exportData =
getExportInfo(*clientContext->getCatalog(), clientContext->getTransaction(), this);
auto parsedOptions = bindParsingOptions(exportDB.getParsingOptionsRef());
auto fileTypeInfo = getFileType(parsedOptions);
switch (fileTypeInfo.fileType) {
Expand Down
4 changes: 2 additions & 2 deletions src/binder/bind/bind_standalone_call_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ std::unique_ptr<BoundStatement> Binder::bindStandaloneCallFunction(
callStatement.getFunctionExpression()->constCast<parser::ParsedFunctionExpression>();
auto funcName = funcExpr.getFunctionName();
auto catalogSet = clientContext->getCatalog()->getFunctions(clientContext->getTransaction());
auto entry = function::BuiltInFunctionsUtils::getFunctionCatalogEntry(clientContext->getTransaction(),
funcName, catalogSet);
auto entry = function::BuiltInFunctionsUtils::getFunctionCatalogEntry(
clientContext->getTransaction(), funcName, catalogSet);
if (entry->getType() != catalog::CatalogEntryType::STANDALONE_TABLE_FUNCTION_ENTRY) {
throw common::BinderException(
"Only standalone table functions can be called without return statement.");
Expand Down
6 changes: 3 additions & 3 deletions src/binder/bind/copy/bind_copy_to.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ std::unique_ptr<BoundStatement> Binder::bindCopyToClause(const Statement& statem
auto functions = clientContext->getCatalog()->getFunctions(clientContext->getTransaction());
auto fileTypeStr = fileTypeInfo.fileTypeStr;
auto name = common::stringFormat("COPY_{}", fileTypeStr);
auto exportFunc =
function::BuiltInFunctionsUtils::matchFunction(clientContext->getTransaction(), name, functions)
->constPtrCast<function::ExportFunction>();
auto exportFunc = function::BuiltInFunctionsUtils::matchFunction(
clientContext->getTransaction(), name, functions)
->constPtrCast<function::ExportFunction>();
for (auto& column : columns) {
auto columnName = column->hasAlias() ? column->getAlias() : column->toString();
columnNames.push_back(columnName);
Expand Down
8 changes: 4 additions & 4 deletions src/binder/bind_expression/bind_function_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ std::shared_ptr<Expression> ExpressionBinder::bindLabelFunction(const Expression
return createLiteralExpression("");
}
if (!node.isMultiLabeled()) {
auto labelName =
catalog->getTableName(context->getTransaction(), node.getSingleEntry()->getTableID());
auto labelName = catalog->getTableName(context->getTransaction(),
node.getSingleEntry()->getTableID());
return createLiteralExpression(Value(LogicalType::STRING(), labelName));
}
auto nodeTableIDs = catalog->getNodeTableIDs(context->getTransaction());
Expand All @@ -283,8 +283,8 @@ std::shared_ptr<Expression> ExpressionBinder::bindLabelFunction(const Expression
return createLiteralExpression("");
}
if (!rel.isMultiLabeled()) {
auto labelName =
catalog->getTableName(context->getTransaction(), rel.getSingleEntry()->getTableID());
auto labelName = catalog->getTableName(context->getTransaction(),
rel.getSingleEntry()->getTableID());
return createLiteralExpression(Value(LogicalType::STRING(), labelName));
}
auto relTableIDs = catalog->getRelTableIDs(context->getTransaction());
Expand Down
4 changes: 2 additions & 2 deletions src/catalog/catalog_entry/rel_group_catalog_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ std::string RelGroupCatalogEntry::toCypher(ClientContext* clientContext) const {
for (auto i = 1u; i < relTableIDs.size(); ++i) {
ss << stringFormat(", {}", getFromToStr(relTableIDs[i], clientContext));
}
auto childRelEntry =
clientContext->getCatalog()->getTableCatalogEntry(clientContext->getTransaction(), relTableIDs[0]);
auto childRelEntry = clientContext->getCatalog()->getTableCatalogEntry(
clientContext->getTransaction(), relTableIDs[0]);
if (childRelEntry->getNumProperties() > 1) { // skip internal id property.
auto propertyStr = stringFormat(", {}", childRelEntry->propertiesToCypher());
propertyStr.resize(propertyStr.size() - 1);
Expand Down
10 changes: 6 additions & 4 deletions src/function/date/date_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ namespace kuzu {
namespace function {

void CurrentDate::operation(common::date_t& result, void* dataPtr) {
auto currentTS =
reinterpret_cast<FunctionBindData*>(dataPtr)->clientContext->getTransaction()->getCurrentTS();
auto currentTS = reinterpret_cast<FunctionBindData*>(dataPtr)
->clientContext->getTransaction()
->getCurrentTS();
result = common::Timestamp::getDate(common::timestamp_tz_t(currentTS));
}

void CurrentTimestamp::operation(common::timestamp_tz_t& result, void* dataPtr) {
auto currentTS =
reinterpret_cast<FunctionBindData*>(dataPtr)->clientContext->getTransaction()->getCurrentTS();
auto currentTS = reinterpret_cast<FunctionBindData*>(dataPtr)
->clientContext->getTransaction()
->getCurrentTS();
result = common::timestamp_tz_t(currentTS);
}

Expand Down
3 changes: 2 additions & 1 deletion src/function/gds/page_rank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ class PageRank final : public GDSAlgorithm {
auto numNodes = graph->getNumNodes(context->clientContext->getTransaction());
for (auto tableID : graph->getNodeTableIDs()) {
for (auto offset = 0u;
offset < graph->getNumNodes(context->clientContext->getTransaction(), tableID); ++offset) {
offset < graph->getNumNodes(context->clientContext->getTransaction(), tableID);
++offset) {
auto nodeID = nodeID_t{offset, tableID};
ranks.insert({nodeID, 1.0 / numNodes});
}
Expand Down
3 changes: 2 additions & 1 deletion src/function/table/call/create_project_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ static std::vector<TableCatalogEntry*> getTableEntries(const std::vector<std::st
CatalogEntryType expectedType, const main::ClientContext& context) {
std::vector<TableCatalogEntry*> entries;
for (auto& tableName : tableNames) {
auto entry = context.getCatalog()->getTableCatalogEntry(context.getTransaction(), tableName);
auto entry =
context.getCatalog()->getTableCatalogEntry(context.getTransaction(), tableName);
if (entry->getType() != expectedType) {
throw BinderException(stringFormat("Expect catalog entry type {} but got {}.",
CatalogEntryTypeUtils::toString(expectedType),
Expand Down
3 changes: 2 additions & 1 deletion src/function/table/call/show_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ static std::unique_ptr<TableFuncBindData> bindFunc(const main::ClientContext* co
for (auto attachedDatabase : databaseManager->getAttachedDatabases()) {
auto databaseName = attachedDatabase->getDBName();
auto databaseType = attachedDatabase->getDBType();
for (auto& entry : attachedDatabase->getCatalog()->getTableEntries(context->getTransaction())) {
for (auto& entry :
attachedDatabase->getCatalog()->getTableEntries(context->getTransaction())) {
auto tableInfo = TableInfo{entry->getName(), entry->getTableID(),
TableTypeUtils::toString(entry->getTableType()),
stringFormat("{}({})", databaseName, databaseType), entry->getComment()};
Expand Down
10 changes: 5 additions & 5 deletions src/function/vector_cast_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,11 +1058,11 @@ static std::unique_ptr<FunctionBindData> castBindFunc(ScalarBindFuncInput input)
std::vector<LogicalType> typeVec;
typeVec.push_back(input.arguments[0]->getDataType().copy());
try {
func->execFunc =
BuiltInFunctionsUtils::matchFunction(input.context->getTransaction(), func->name, typeVec,
input.context->getCatalog()->getFunctions(input.context->getTransaction()))
->constPtrCast<ScalarFunction>()
->execFunc;
func->execFunc = BuiltInFunctionsUtils::matchFunction(input.context->getTransaction(),
func->name, typeVec,
input.context->getCatalog()->getFunctions(input.context->getTransaction()))
->constPtrCast<ScalarFunction>()
->execFunc;
return std::make_unique<function::CastFunctionBindData>(targetType.copy());
} catch (...) { // NOLINT
// If there's no user defined casting function for the corresponding user defined type,
Expand Down
18 changes: 10 additions & 8 deletions src/graph/on_disk_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ OnDiskGraphNbrScanStates::OnDiskGraphNbrScanStates(ClientContext* context,
// TODO(bmwinger): If there are both a predicate and a custom edgePropertyIndex, they will
// currently be scanned twice. The propertyVector could simply be one of the vectors used
// for the predicate.
auto catalogEntry =
context->getCatalog()->getTableCatalogEntry(context->getTransaction(), tables[0]->getTableID());
auto catalogEntry = context->getCatalog()->getTableCatalogEntry(context->getTransaction(),
tables[0]->getTableID());
propertyVector = std::make_unique<ValueVector>(
catalogEntry->getProperty(*edgePropertyIndex).getType().copy(),
context->getMemoryManager());
Expand All @@ -119,12 +119,12 @@ OnDiskGraphNbrScanStates::OnDiskGraphNbrScanStates(ClientContext* context,
scanStates.reserve(tables.size());
for (auto table : tables) {
auto relEntry = graphEntry.getRelEntry(table->getTableID());
auto fwdState = getRelScanState(context->getTransaction(), *context->getMemoryManager(), *relEntry,
*table, RelDataDirection::FWD, srcNodeIDVector.get(), dstNodeIDVector.get(),
auto fwdState = getRelScanState(context->getTransaction(), *context->getMemoryManager(),
*relEntry, *table, RelDataDirection::FWD, srcNodeIDVector.get(), dstNodeIDVector.get(),
relIDVector.get(), graphEntry.getRelProperties(), edgePropertyID, propertyVector.get(),
schema, resultSet);
auto bwdState = getRelScanState(context->getTransaction(), *context->getMemoryManager(), *relEntry,
*table, RelDataDirection::BWD, srcNodeIDVector.get(), dstNodeIDVector.get(),
auto bwdState = getRelScanState(context->getTransaction(), *context->getMemoryManager(),
*relEntry, *table, RelDataDirection::BWD, srcNodeIDVector.get(), dstNodeIDVector.get(),
relIDVector.get(), graphEntry.getRelProperties(), edgePropertyID, propertyVector.get(),
schema, resultSet);
scanStates.emplace_back(table->getTableID(),
Expand Down Expand Up @@ -319,7 +319,8 @@ OnDiskGraphVertexScanState::OnDiskGraphVertexScanState(ClientContext& context,
numNodesScanned{0}, tableID{tableID}, currentOffset{0}, endOffsetExclusive{0} {
std::vector<column_id_t> propertyColumnIDs;
propertyColumnIDs.reserve(propertyNames.size());
auto tableCatalogEntry = context.getCatalog()->getTableCatalogEntry(context.getTransaction(), tableID);
auto tableCatalogEntry =
context.getCatalog()->getTableCatalogEntry(context.getTransaction(), tableID);
std::vector<const Column*> columns;
std::vector<LogicalType> types;
for (const auto& property : propertyNames) {
Expand Down Expand Up @@ -347,7 +348,8 @@ bool OnDiskGraphVertexScanState::next() {
auto endOffset = std::min(endOffsetExclusive,
StorageUtils::getStartOffsetOfNodeGroup(tableScanState->nodeGroupIdx + 1));
numNodesScanned = std::min(endOffset - currentOffset, DEFAULT_VECTOR_CAPACITY);
auto result = tableScanState->scanNext(context.getTransaction(), currentOffset, numNodesScanned);
auto result =
tableScanState->scanNext(context.getTransaction(), currentOffset, numNodesScanned);
currentOffset += numNodesScanned;
return result;
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/storage_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ void StorageDriver::scan(const std::string& nodeName, const std::string& propert

uint64_t StorageDriver::getNumNodes(const std::string& nodeName) {
clientContext->query("BEGIN TRANSACTION READ ONLY;");
auto result = getTable(*clientContext, nodeName)->getNumTotalRows(clientContext->getTransaction());
auto result =
getTable(*clientContext, nodeName)->getNumTotalRows(clientContext->getTransaction());
clientContext->query("COMMIT");
return result;
}

uint64_t StorageDriver::getNumRels(const std::string& relName) {
clientContext->query("BEGIN TRANSACTION READ ONLY;");
auto result = getTable(*clientContext, relName)->getNumTotalRows(clientContext->getTransaction());
auto result =
getTable(*clientContext, relName)->getNumTotalRows(clientContext->getTransaction());
clientContext->query("COMMIT");
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/planner/plan/plan_port_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ std::unique_ptr<LogicalPlan> Planner::planExportDatabase(const BoundStatement& s
auto copyToSuffix = "." + fileTypeStr;
auto functions = clientContext->getCatalog()->getFunctions(clientContext->getTransaction());
std::string name = common::stringFormat("COPY_{}", FileTypeUtils::toString(fileType));
auto func =
function::BuiltInFunctionsUtils::matchFunction(clientContext->getTransaction(), name, functions);
auto func = function::BuiltInFunctionsUtils::matchFunction(clientContext->getTransaction(),
name, functions);
KU_ASSERT(func != nullptr);
auto exportFunc = *func->constPtrCast<function::ExportFunction>();
for (auto& exportTableData : *exportData) {
Expand Down
4 changes: 2 additions & 2 deletions src/planner/plan/plan_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ void Planner::planGDSCall(const BoundReadingClause& readingClause,
if (!properties.empty()) {
auto& node = bindData->getNodeOutput()->constCast<NodeExpression>();
auto scanPlan = LogicalPlan();
cardinalityEstimator.addNodeIDDomAndStats(clientContext->getTransaction(), *node.getInternalID(),
node.getTableIDs());
cardinalityEstimator.addNodeIDDomAndStats(clientContext->getTransaction(),
*node.getInternalID(), node.getTableIDs());
appendScanNodeTable(node.getInternalID(), node.getTableIDs(), properties, scanPlan);
expression_vector joinConditions;
joinConditions.push_back(node.getInternalID());
Expand Down
3 changes: 2 additions & 1 deletion src/processor/map/create_factorized_table_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ std::unique_ptr<PhysicalOperator> PlanMapper::createFTableScan(const expression_
auto bindData =
std::make_unique<FTableScanBindData>(table, std::move(colIndices), maxMorselSize);
auto function = function::BuiltInFunctionsUtils::matchFunction(clientContext->getTransaction(),
FTableScan::name, clientContext->getCatalog()->getFunctions(clientContext->getTransaction()));
FTableScan::name,
clientContext->getCatalog()->getFunctions(clientContext->getTransaction()));
auto info = TableFunctionCallInfo();
info.function = *ku_dynamic_cast<TableFunction*>(function);
info.bindData = std::move(bindData);
Expand Down
3 changes: 2 additions & 1 deletion src/processor/map/map_recursive_extend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ std::unique_ptr<PhysicalOperator> PlanMapper::mapRecursiveExtend(LogicalOperator
} else {
dataInfo.pathPos = DataPos::getInvalidPos();
}
for (auto& entry : clientContext->getCatalog()->getTableEntries(clientContext->getTransaction())) {
for (auto& entry :
clientContext->getCatalog()->getTableEntries(clientContext->getTransaction())) {
dataInfo.tableIDToName.insert({entry->getTableID(), entry->getName()});
}
// Info
Expand Down
3 changes: 2 additions & 1 deletion src/processor/operator/ddl/create_sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ void CreateSequence::executeDDLInternal(ExecutionContext* context) {
auto catalog = context->clientContext->getCatalog();
switch (info.onConflict) {
case common::ConflictAction::ON_CONFLICT_DO_NOTHING: {
if (catalog->containsSequence(context->clientContext->getTransaction(), info.sequenceName)) {
if (catalog->containsSequence(context->clientContext->getTransaction(),
info.sequenceName)) {
return;
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/processor/operator/ddl/drop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ bool isValidEntry(parser::DropInfo& dropInfo, main::ClientContext* context) {
bool validEntry = false;
switch (dropInfo.dropType) {
case common::DropType::SEQUENCE: {
validEntry = context->getCatalog()->containsSequence(context->getTransaction(), dropInfo.name);
validEntry =
context->getCatalog()->containsSequence(context->getTransaction(), dropInfo.name);
} break;
// TODO(Ziyi): If the table has indexes, we should drop those indexes as well.
case common::DropType::TABLE: {
Expand All @@ -36,8 +37,8 @@ void Drop::executeDDLInternal(ExecutionContext* context) {
dropInfo.name);
} break;
case common::DropType::TABLE: {
context->clientContext->getCatalog()->dropTableEntry(context->clientContext->getTransaction(),
dropInfo.name);
context->clientContext->getCatalog()->dropTableEntry(
context->clientContext->getTransaction(), dropInfo.name);
} break;
default:
KU_UNREACHABLE;
Expand Down
4 changes: 2 additions & 2 deletions src/processor/operator/persistent/node_batch_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ void NodeBatchInsertSharedState::initPKIndex(const ExecutionContext* context) {
}
auto* nodeTable = ku_dynamic_cast<NodeTable*>(table);
nodeTable->getPKIndex()->bulkReserve(numRows);
globalIndexBuilder = IndexBuilder(
std::make_shared<IndexBuilderSharedState>(context->clientContext->getTransaction(), nodeTable));
globalIndexBuilder = IndexBuilder(std::make_shared<IndexBuilderSharedState>(
context->clientContext->getTransaction(), nodeTable));
}

void NodeBatchInsert::initGlobalStateInternal(ExecutionContext* context) {
Expand Down
4 changes: 2 additions & 2 deletions src/processor/operator/persistent/rel_batch_insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ void RelBatchInsert::executeInternal(ExecutionContext* context) {
->getOrCreateNodeGroup(context->clientContext->getTransaction(),
relLocalState->nodeGroupIdx, relInfo->direction)
->cast<CSRNodeGroup>();
appendNodeGroup(context->clientContext->getTransaction(), nodeGroup, *relInfo, *relLocalState,
*sharedState, *partitionerSharedState);
appendNodeGroup(context->clientContext->getTransaction(), nodeGroup, *relInfo,
*relLocalState, *sharedState, *partitionerSharedState);
updateProgress(context);
}
}
Expand Down
Loading

0 comments on commit b960c0b

Please sign in to comment.