Skip to content

Commit 4059c8c

Browse files
committed
opt: use a consistent name for the unbounded cardinality penalty
`memo.UnboundedCardinality` has been renamed to `memo.UnboundedCardinalityPenalty` to be consistent with the names of the other cost penalties. Release note: None
1 parent 29b6dfc commit 4059c8c

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

pkg/sql/opt/memo/cost.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Cost struct {
2828
// member will have a lower cost.
2929
var MaxCost = Cost{
3030
C: math.Inf(+1),
31-
Penalties: HugeCostPenalty | FullScanPenalty | UnboundedCardinality,
31+
Penalties: HugeCostPenalty | FullScanPenalty | UnboundedCardinalityPenalty,
3232
}
3333

3434
// Less returns true if this cost is lower than the given cost.
@@ -95,10 +95,10 @@ const (
9595
// plan is possible.
9696
FullScanPenalty
9797

98-
// UnboundedCardinality is true if the operator or any of its descendants
99-
// have no guaranteed upperbound on the number of rows that they can
100-
// produce. See props.AnyCardinality.
101-
UnboundedCardinality
98+
// UnboundedCardinalityPenalty is true if the operator or any of its
99+
// descendants have no guaranteed upperbound on the number of rows that they
100+
// can produce. See props.AnyCardinality.
101+
UnboundedCardinalityPenalty
102102

103103
// NoPenalties represents no penalties.
104104
NoPenalties Penalties = 0

pkg/sql/opt/memo/cost_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func TestCostLess(t *testing.T) {
3535
{MaxCost, MaxCost, false},
3636
{MaxCost, Cost{C: 1.0, Penalties: FullScanPenalty}, false},
3737
{Cost{C: 1.0, Penalties: HugeCostPenalty}, MaxCost, true},
38-
{Cost{C: 2.0}, Cost{C: 1.0, Penalties: UnboundedCardinality}, true},
39-
{Cost{C: 1.0, Penalties: UnboundedCardinality}, Cost{C: 2.0}, false},
38+
{Cost{C: 2.0}, Cost{C: 1.0, Penalties: UnboundedCardinalityPenalty}, true},
39+
{Cost{C: 1.0, Penalties: UnboundedCardinalityPenalty}, Cost{C: 2.0}, false},
4040
// Auxiliary information should not affect the comparison.
4141
{Cost{C: 1.0, aux: testAux{0}}, Cost{C: 1.0, aux: testAux{1}}, false},
4242
}
@@ -57,7 +57,7 @@ func TestCostAdd(t *testing.T) {
5757
{Cost{C: 1.5}, Cost{C: 2.5}, Cost{C: 4.0}},
5858
{Cost{C: 1.0, Penalties: FullScanPenalty}, Cost{C: 2.0}, Cost{C: 3.0, Penalties: FullScanPenalty}},
5959
{Cost{C: 1.0}, Cost{C: 2.0, Penalties: HugeCostPenalty}, Cost{C: 3.0, Penalties: HugeCostPenalty}},
60-
{Cost{C: 1.0, Penalties: UnboundedCardinality}, Cost{C: 2.0, Penalties: HugeCostPenalty}, Cost{C: 3.0, Penalties: HugeCostPenalty | UnboundedCardinality}},
60+
{Cost{C: 1.0, Penalties: UnboundedCardinalityPenalty}, Cost{C: 2.0, Penalties: HugeCostPenalty}, Cost{C: 3.0, Penalties: HugeCostPenalty | UnboundedCardinalityPenalty}},
6161
{Cost{C: 1.0, aux: testAux{1}}, Cost{C: 1.0, aux: testAux{2}}, Cost{C: 2.0, aux: testAux{3}}},
6262
{Cost{C: 1.0, aux: testAux{200}}, Cost{C: 1.0, aux: testAux{100}}, Cost{C: 2.0, aux: testAux{255}}},
6363
}

pkg/sql/opt/memo/expr_format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ func (f *ExprFmtCtx) formatRelational(e RelExpr, tp treeprinter.Node) {
928928
if cost.Penalties&HugeCostPenalty != 0 {
929929
b.WriteString(" huge-cost-penalty")
930930
}
931-
if cost.Penalties&UnboundedCardinality != 0 {
931+
if cost.Penalties&UnboundedCardinalityPenalty != 0 {
932932
b.WriteString(" unbounded-cardinality")
933933
}
934934
tp.Child(b.String())

pkg/sql/opt/xform/coster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ func (c *coster) ComputeCost(candidate memo.RelExpr, required *physical.Required
645645
if candidate.Relational().Cardinality.IsUnbounded() {
646646
cost.C += cpuCostFactor
647647
if c.evalCtx.SessionData().OptimizerPreferBoundedCardinality {
648-
cost.Penalties |= memo.UnboundedCardinality
648+
cost.Penalties |= memo.UnboundedCardinalityPenalty
649649
}
650650
}
651651

0 commit comments

Comments
 (0)