Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execinfra: extract out some packages to break dependencies #79938

Merged
merged 2 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ ALL_TESTS = [
"//pkg/sql/catalog/typedesc:typedesc_test",
"//pkg/sql/catalog:catalog_test",
"//pkg/sql/colcontainer:colcontainer_test",
"//pkg/sql/colconv:colconv_disallowed_imports_test",
"//pkg/sql/colconv:colconv_test",
"//pkg/sql/colencoding:colencoding_test",
"//pkg/sql/colexec/colbuilder:colbuilder_test",
Expand Down Expand Up @@ -283,6 +284,7 @@ ALL_TESTS = [
"//pkg/sql/execinfra:execinfra_test",
"//pkg/sql/execinfrapb:execinfrapb_disallowed_imports_test",
"//pkg/sql/execinfrapb:execinfrapb_test",
"//pkg/sql/execstats:execstats_disallowed_imports_test",
"//pkg/sql/execstats:execstats_test",
"//pkg/sql/flowinfra:flowinfra_disallowed_imports_test",
"//pkg/sql/flowinfra:flowinfra_test",
Expand Down
2 changes: 1 addition & 1 deletion pkg/col/coldatatestutils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ go_library(
"//pkg/sql/colexecerror",
"//pkg/sql/colexecop",
"//pkg/sql/colmem",
"//pkg/sql/execinfra",
"//pkg/sql/execinfra/execopnode",
"//pkg/sql/randgen",
"//pkg/sql/types",
"//pkg/util/duration",
Expand Down
8 changes: 4 additions & 4 deletions pkg/col/coldatatestutils/random_testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/colexecerror"
"github.com/cockroachdb/cockroach/pkg/sql/colexecop"
"github.com/cockroachdb/cockroach/pkg/sql/colmem"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra/execopnode"
"github.com/cockroachdb/cockroach/pkg/sql/randgen"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/cockroach/pkg/util/duration"
Expand Down Expand Up @@ -420,13 +420,13 @@ func (o *RandomDataOp) Next() coldata.Batch {
}
}

// ChildCount implements the execinfra.OpNode interface.
// ChildCount implements the execopnode.OpNode interface.
func (o *RandomDataOp) ChildCount(verbose bool) int {
return 0
}

// Child implements the execinfra.OpNode interface.
func (o *RandomDataOp) Child(nth int, verbose bool) execinfra.OpNode {
// Child implements the execopnode.OpNode interface.
func (o *RandomDataOp) Child(nth int, verbose bool) execopnode.OpNode {
colexecerror.InternalError(errors.AssertionFailedf("invalid index %d", nth))
// This code is unreachable, but the compiler cannot infer that.
return nil
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ go_library(
"//pkg/sql/distsql",
"//pkg/sql/enum",
"//pkg/sql/execinfra",
"//pkg/sql/execinfra/execopnode",
"//pkg/sql/execinfrapb",
"//pkg/sql/execstats",
"//pkg/sql/faketreeeval",
Expand Down
8 changes: 7 additions & 1 deletion pkg/sql/colconv/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//pkg/sql/colexecop:EXECGEN.bzl", "eg_go_filegroup", "gen_eg_go_rules")
load("//pkg/testutils/buildutil:buildutil.bzl", "disallowed_imports_test")

go_library(
name = "colconv",
Expand All @@ -13,7 +14,7 @@ go_library(
"//pkg/col/coldata",
"//pkg/col/typeconv", # keep
"//pkg/sql/colexecerror", # keep
"//pkg/sql/execinfra", # keep
"//pkg/sql/execinfra/execreleasable", # keep
"//pkg/sql/rowenc", # keep
"//pkg/sql/sem/tree", # keep
"//pkg/sql/types", # keep
Expand Down Expand Up @@ -52,3 +53,8 @@ eg_go_filegroup(

# Define gen rules for individual eg.go files.
gen_eg_go_rules(targets)

disallowed_imports_test(
"colconv",
["//pkg/sql/execinfra"],
)
4 changes: 2 additions & 2 deletions pkg/sql/colconv/vec_to_datum.eg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/sql/colconv/vec_to_datum_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/col/coldata"
"github.com/cockroachdb/cockroach/pkg/col/typeconv"
"github.com/cockroachdb/cockroach/pkg/sql/colexecerror"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra/execreleasable"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/cockroach/pkg/util/json"
Expand Down Expand Up @@ -68,7 +68,7 @@ type VecToDatumConverter struct {
da tree.DatumAlloc
}

var _ execinfra.Releasable = &VecToDatumConverter{}
var _ execreleasable.Releasable = &VecToDatumConverter{}

var vecToDatumConverterPool = sync.Pool{
New: func() interface{} {
Expand Down
2 changes: 2 additions & 0 deletions pkg/sql/colexec/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ go_library(
"//pkg/sql/colexecop",
"//pkg/sql/colmem",
"//pkg/sql/execinfra",
"//pkg/sql/execinfra/execopnode",
"//pkg/sql/execinfra/execreleasable",
"//pkg/sql/execinfrapb",
"//pkg/sql/memsize",
"//pkg/sql/rowenc",
Expand Down
14 changes: 7 additions & 7 deletions pkg/sql/colexec/and_or_projection.eg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/sql/colexec/and_or_projection_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/colexecerror"
"github.com/cockroachdb/cockroach/pkg/sql/colexecop"
"github.com/cockroachdb/cockroach/pkg/sql/colmem"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra/execopnode"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/errors"
)
Expand Down Expand Up @@ -130,7 +130,7 @@ func (o *_OP_LOWERProjOp) ChildCount(verbose bool) int {
return 3
}

func (o *_OP_LOWERProjOp) Child(nth int, verbose bool) execinfra.OpNode {
func (o *_OP_LOWERProjOp) Child(nth int, verbose bool) execopnode.OpNode {
switch nth {
case 0:
return o.input
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/colexec/builtin_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/colexecerror"
"github.com/cockroachdb/cockroach/pkg/sql/colexecop"
"github.com/cockroachdb/cockroach/pkg/sql/colmem"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra/execreleasable"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/errors"
Expand All @@ -39,7 +39,7 @@ type defaultBuiltinFuncOperator struct {
}

var _ colexecop.Operator = &defaultBuiltinFuncOperator{}
var _ execinfra.Releasable = &defaultBuiltinFuncOperator{}
var _ execreleasable.Releasable = &defaultBuiltinFuncOperator{}

func (b *defaultBuiltinFuncOperator) Next() coldata.Batch {
batch := b.Input.Next()
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/colexec/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/colexecerror"
"github.com/cockroachdb/cockroach/pkg/sql/colexecop"
"github.com/cockroachdb/cockroach/pkg/sql/colmem"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra/execopnode"
"github.com/cockroachdb/cockroach/pkg/sql/types"
"github.com/cockroachdb/errors"
)
Expand Down Expand Up @@ -111,7 +111,7 @@ func (c *caseOp) ChildCount(verbose bool) int {
return 1 + len(c.caseOps) + 1
}

func (c *caseOp) Child(nth int, verbose bool) execinfra.OpNode {
func (c *caseOp) Child(nth int, verbose bool) execopnode.OpNode {
if nth == 0 {
return c.buffer
} else if nth < len(c.caseOps)+1 {
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/colexec/colbuilder/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ go_library(
"//pkg/sql/colfetcher",
"//pkg/sql/colmem",
"//pkg/sql/execinfra",
"//pkg/sql/execinfra/execreleasable",
"//pkg/sql/execinfrapb",
"//pkg/sql/sem/tree",
"//pkg/sql/sem/tree/treecmp",
Expand Down
29 changes: 15 additions & 14 deletions pkg/sql/colexec/colbuilder/execplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/colfetcher"
"github.com/cockroachdb/cockroach/pkg/sql/colmem"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra"
"github.com/cockroachdb/cockroach/pkg/sql/execinfra/execreleasable"
"github.com/cockroachdb/cockroach/pkg/sql/execinfrapb"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree/treecmp"
Expand Down Expand Up @@ -69,9 +70,9 @@ func wrapRowSources(
newToWrap func([]execinfra.RowSource) (execinfra.RowSource, error),
materializerSafeToRelease bool,
factory coldata.ColumnFactory,
) (*colexec.Columnarizer, []execinfra.Releasable, error) {
) (*colexec.Columnarizer, []execreleasable.Releasable, error) {
var toWrapInputs []execinfra.RowSource
var releasables []execinfra.Releasable
var releasables []execreleasable.Releasable
for i := range inputs {
// Optimization: if the input is a Columnarizer, its input is
// necessarily a execinfra.RowSource, so remove the unnecessary
Expand Down Expand Up @@ -1619,7 +1620,7 @@ func (r *postProcessResult) planPostProcessSpec(
args *colexecargs.NewColOperatorArgs,
post *execinfrapb.PostProcessSpec,
factory coldata.ColumnFactory,
releasables *[]execinfra.Releasable,
releasables *[]execreleasable.Releasable,
) error {
if post.Projection {
r.Op, r.ColumnTypes = addProjection(r.Op, r.ColumnTypes, post.OutputColumns)
Expand Down Expand Up @@ -1718,7 +1719,7 @@ func planFilterExpr(
acc *mon.BoundAccount,
factory coldata.ColumnFactory,
helper *colexecargs.ExprHelper,
releasables *[]execinfra.Releasable,
releasables *[]execreleasable.Releasable,
) (colexecop.Operator, error) {
expr, err := helper.ProcessExpr(filter, flowCtx.EvalCtx, columnTypes)
if err != nil {
Expand Down Expand Up @@ -1767,7 +1768,7 @@ func planSelectionOperators(
input colexecop.Operator,
acc *mon.BoundAccount,
factory coldata.ColumnFactory,
releasables *[]execinfra.Releasable,
releasables *[]execreleasable.Releasable,
) (op colexecop.Operator, resultIdx int, typs []*types.T, err error) {
switch t := expr.(type) {
case *tree.AndExpr:
Expand Down Expand Up @@ -1838,7 +1839,7 @@ func planSelectionOperators(
op, err = colexecsel.GetSelectionConstOperator(
cmpOp, leftOp, ct, leftIdx, constArg, evalCtx, t,
)
if r, ok := op.(execinfra.Releasable); ok {
if r, ok := op.(execreleasable.Releasable); ok {
*releasables = append(*releasables, r)
}
}
Expand All @@ -1853,7 +1854,7 @@ func planSelectionOperators(
op, err = colexecsel.GetSelectionOperator(
cmpOp, rightOp, ct, leftIdx, rightIdx, evalCtx, t,
)
if r, ok := op.(execinfra.Releasable); ok {
if r, ok := op.(execreleasable.Releasable); ok {
*releasables = append(*releasables, r)
}
return op, resultIdx, ct, err
Expand Down Expand Up @@ -1957,7 +1958,7 @@ func planProjectionOperators(
input colexecop.Operator,
acc *mon.BoundAccount,
factory coldata.ColumnFactory,
releasables *[]execinfra.Releasable,
releasables *[]execreleasable.Releasable,
) (op colexecop.Operator, resultIdx int, typs []*types.T, err error) {
// projectDatum is a helper function that adds a new constant projection
// operator for the given datum. typs are updated accordingly.
Expand Down Expand Up @@ -2162,7 +2163,7 @@ func planProjectionOperators(
op, err = colexec.NewBuiltinFunctionOperator(
colmem.NewAllocator(ctx, acc, factory), evalCtx, t, typs, inputCols, resultIdx, op,
)
if r, ok := op.(execinfra.Releasable); ok {
if r, ok := op.(execreleasable.Releasable); ok {
*releasables = append(*releasables, r)
}
typs = appendOneType(typs, t.ResolvedType())
Expand Down Expand Up @@ -2249,7 +2250,7 @@ func planProjectionOperators(
op = colexec.NewTupleProjOp(
colmem.NewAllocator(ctx, acc, factory), typs, tupleContentsIdxs, outputType, input, resultIdx,
)
*releasables = append(*releasables, op.(execinfra.Releasable))
*releasables = append(*releasables, op.(execreleasable.Releasable))
typs = appendOneType(typs, outputType)
return op, resultIdx, typs, err
default:
Expand Down Expand Up @@ -2301,7 +2302,7 @@ func planProjectionExpr(
factory coldata.ColumnFactory,
binFn tree.TwoArgFn,
cmpExpr *tree.ComparisonExpr,
releasables *[]execinfra.Releasable,
releasables *[]execreleasable.Releasable,
) (op colexecop.Operator, resultIdx int, typs []*types.T, err error) {
if err := checkSupportedProjectionExpr(left, right); err != nil {
return nil, resultIdx, typs, err
Expand Down Expand Up @@ -2437,7 +2438,7 @@ func planProjectionExpr(
if err != nil {
return op, resultIdx, typs, err
}
if r, ok := op.(execinfra.Releasable); ok {
if r, ok := op.(execreleasable.Releasable); ok {
*releasables = append(*releasables, r)
}
typs = appendOneType(typs, outputType)
Expand All @@ -2454,7 +2455,7 @@ func planLogicalProjectionOp(
input colexecop.Operator,
acc *mon.BoundAccount,
factory coldata.ColumnFactory,
releasables *[]execinfra.Releasable,
releasables *[]execreleasable.Releasable,
) (op colexecop.Operator, resultIdx int, typs []*types.T, err error) {
// Add a new boolean column that will store the result of the projection.
resultIdx = len(columnTypes)
Expand Down Expand Up @@ -2523,7 +2524,7 @@ func planIsNullProjectionOp(
acc *mon.BoundAccount,
negate bool,
factory coldata.ColumnFactory,
releasables *[]execinfra.Releasable,
releasables *[]execreleasable.Releasable,
) (op colexecop.Operator, resultIdx int, typs []*types.T, err error) {
op, resultIdx, typs, err = planProjectionOperators(
ctx, evalCtx, expr, columnTypes, input, acc, factory, releasables,
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/colexec/colexecargs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ go_library(
"//pkg/sql/colexecerror",
"//pkg/sql/colexecop",
"//pkg/sql/execinfra",
"//pkg/sql/execinfra/execreleasable",
"//pkg/sql/execinfrapb",
"//pkg/sql/sem/tree",
"//pkg/sql/types",
Expand Down
Loading