Skip to content

Commit

Permalink
colexec: update the allocator with the internal memory usage
Browse files Browse the repository at this point in the history
This commit removes `InternalMemoryOperator` interface that was put
in-place for the operators to register their static memory usage. This
was introduced before we had the allocator object (I think), and now we
can remove that interface and simply update the allocators with the
corresponding internal memory usage. There were only two operators that
actually implemented the interface, and both of them were converted to
the new pattern.

This commit also removes the separation of streaming memory accounts in
the vectorized flow setup and merges them with all other accounts.

Release note: None
  • Loading branch information
yuzefovich committed Nov 6, 2020
1 parent 8ac12ae commit 0220f65
Show file tree
Hide file tree
Showing 20 changed files with 131 additions and 208 deletions.
9 changes: 3 additions & 6 deletions pkg/sql/colexec/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type caseOp struct {
prevSel []int
}

var _ InternalMemoryOperator = &caseOp{}
var _ colexecbase.Operator = &caseOp{}

func (c *caseOp) ChildCount(verbose bool) int {
return 1 + len(c.caseOps) + 1
Expand All @@ -65,11 +65,6 @@ func (c *caseOp) Child(nth int, verbose bool) execinfra.OpNode {
return nil
}

func (c *caseOp) InternalMemoryUsage() int {
// We internally use two selection vectors, origSel and prevSel.
return 2 * colmem.SizeOfBatchSizeSelVector
}

// NewCaseOp returns an operator that runs a case statement.
// buffer is a bufferOp that will return the input batch repeatedly.
// caseOps is a list of operator chains, one per branch in the case statement.
Expand All @@ -89,6 +84,8 @@ func NewCaseOp(
outputIdx int,
typ *types.T,
) colexecbase.Operator {
// We internally use two selection vectors, origSel and prevSel.
allocator.AdjustMemoryUsage(int64(2 * colmem.SizeOfBatchSizeSelVector))
return &caseOp{
allocator: allocator,
buffer: buffer.(*bufferOp),
Expand Down
Loading

0 comments on commit 0220f65

Please sign in to comment.