Skip to content

Commit

Permalink
Adding basic cardinality estimation and paramsToString method
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtenwolde committed Aug 29, 2024
1 parent a77b9df commit e323d12
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/core/operator/logical_path_finding_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ namespace duckpgq {
namespace core {

unique_ptr<PhysicalOperator> LogicalPathFindingOperator::CreatePlan(
ClientContext &, duckdb::PhysicalPlanGenerator &generator) {
ClientContext &context, duckdb::PhysicalPlanGenerator &generator) {
D_ASSERT(children.size() == 2);
estimated_cardinality = children[0]->EstimateCardinality(context);
auto left = generator.CreatePlan(std::move(children[0]));
auto right = generator.CreatePlan(std::move(children[1]));
return make_uniq<PhysicalPathFinding>(*this, std::move(left),
Expand Down
12 changes: 10 additions & 2 deletions src/core/operator/physical_path_finding_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ namespace core {
PhysicalPathFinding::PhysicalPathFinding(LogicalExtensionOperator &op,
unique_ptr<PhysicalOperator> left,
unique_ptr<PhysicalOperator> right)
: PhysicalComparisonJoin(op, TYPE, {}, JoinType::INNER, 0) {
: PhysicalComparisonJoin(op, TYPE, {}, JoinType::INNER, op.estimated_cardinality) {
children.push_back(std::move(left));
children.push_back(std::move(right));
expressions = std::move(op.expressions);
estimated_cardinality = op.estimated_cardinality;
auto &path_finding_op = op.Cast<LogicalPathFindingOperator>();
mode = path_finding_op.mode;
}
Expand Down Expand Up @@ -306,7 +307,6 @@ PhysicalPathFinding::Finalize(Pipeline &pipeline, Event &event,
context.TryGetCurrentSetting("experimental_path_finding_operator_task_size",
task_size_value);
gstate.global_bfs_state->split_size = task_size_value.GetValue<idx_t>();
;

// Schedule the first round of BFS tasks
if (all_pairs->size() > 0) {
Expand Down Expand Up @@ -369,6 +369,14 @@ void PhysicalPathFinding::ScheduleBFSEvent(Pipeline &pipeline, Event &event,
}
}

string PhysicalPathFinding::ParamsToString() const {
std::cout << "ParamsToString" << std::endl;
auto result = mode;
result += "\n[INFOSEPARATOR]\n";
result += StringUtil::Format("EC: %llu", estimated_cardinality);
return result;
}

//===--------------------------------------------------------------------===//
// Operator
//===--------------------------------------------------------------------===//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class PhysicalPathFinding : public PhysicalComparisonJoin {


public:
string ParamsToString() const override;

// CachingOperator Interface
OperatorResultType ExecuteInternal(ExecutionContext &context,
DataChunk &input, DataChunk &chunk,
Expand Down

0 comments on commit e323d12

Please sign in to comment.