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

executor: remove *MVMap from agg executor #7541

Merged
merged 6 commits into from
Sep 11, 2018
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
21 changes: 11 additions & 10 deletions executor/aggfuncs/func_avg.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/set"
)

// All the following avg function implementations return the decimal result,
Expand Down Expand Up @@ -138,7 +139,7 @@ func (e *avgPartial4Decimal) MergePartialResult(sctx sessionctx.Context, src Par

type partialResult4AvgDistinctDecimal struct {
partialResult4AvgDecimal
valSet decimalSet
valSet set.DecimalSet
}

type avgOriginal4DistinctDecimal struct {
Expand All @@ -147,7 +148,7 @@ type avgOriginal4DistinctDecimal struct {

func (e *avgOriginal4DistinctDecimal) AllocPartialResult() PartialResult {
p := &partialResult4AvgDistinctDecimal{
valSet: newDecimalSet(),
valSet: set.NewDecimalSet(),
}
return PartialResult(p)
}
Expand All @@ -156,7 +157,7 @@ func (e *avgOriginal4DistinctDecimal) ResetPartialResult(pr PartialResult) {
p := (*partialResult4AvgDistinctDecimal)(pr)
p.sum = *types.NewDecFromInt(0)
p.count = int64(0)
p.valSet = newDecimalSet()
p.valSet = set.NewDecimalSet()
}

func (e *avgOriginal4DistinctDecimal) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup []chunk.Row, pr PartialResult) error {
Expand All @@ -166,7 +167,7 @@ func (e *avgOriginal4DistinctDecimal) UpdatePartialResult(sctx sessionctx.Contex
if err != nil {
return errors.Trace(err)
}
if isNull || p.valSet.exist(input) {
if isNull || p.valSet.Exist(input) {
continue
}

Expand All @@ -177,7 +178,7 @@ func (e *avgOriginal4DistinctDecimal) UpdatePartialResult(sctx sessionctx.Contex
}
p.sum = *newSum
p.count++
p.valSet.insert(input)
p.valSet.Insert(input)
}
return nil
}
Expand Down Expand Up @@ -291,7 +292,7 @@ func (e *avgPartial4Float64) MergePartialResult(sctx sessionctx.Context, src Par

type partialResult4AvgDistinctFloat64 struct {
partialResult4AvgFloat64
valSet float64Set
valSet set.Float64Set
}

type avgOriginal4DistinctFloat64 struct {
Expand All @@ -300,7 +301,7 @@ type avgOriginal4DistinctFloat64 struct {

func (e *avgOriginal4DistinctFloat64) AllocPartialResult() PartialResult {
p := &partialResult4AvgDistinctFloat64{
valSet: newFloat64Set(),
valSet: set.NewFloat64Set(),
}
return PartialResult(p)
}
Expand All @@ -309,7 +310,7 @@ func (e *avgOriginal4DistinctFloat64) ResetPartialResult(pr PartialResult) {
p := (*partialResult4AvgDistinctFloat64)(pr)
p.sum = float64(0)
p.count = int64(0)
p.valSet = newFloat64Set()
p.valSet = set.NewFloat64Set()
}

func (e *avgOriginal4DistinctFloat64) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup []chunk.Row, pr PartialResult) error {
Expand All @@ -319,13 +320,13 @@ func (e *avgOriginal4DistinctFloat64) UpdatePartialResult(sctx sessionctx.Contex
if err != nil {
return errors.Trace(err)
}
if isNull || p.valSet.exist(input) {
if isNull || p.valSet.Exist(input) {
continue
}

p.sum += input
p.count++
p.valSet.insert(input)
p.valSet.Insert(input)
}
return nil
}
Expand Down
11 changes: 6 additions & 5 deletions executor/aggfuncs/func_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/types/json"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/set"
)

type baseCount struct {
Expand Down Expand Up @@ -220,20 +221,20 @@ type countOriginalWithDistinct struct {
type partialResult4CountWithDistinct struct {
count int64

valSet stringSet
valSet set.StringSet
}

func (e *countOriginalWithDistinct) AllocPartialResult() PartialResult {
return PartialResult(&partialResult4CountWithDistinct{
count: 0,
valSet: newStringSet(),
valSet: set.NewStringSet(),
})
}

func (e *countOriginalWithDistinct) ResetPartialResult(pr PartialResult) {
p := (*partialResult4CountWithDistinct)(pr)
p.count = 0
p.valSet = newStringSet()
p.valSet = set.NewStringSet()
}

func (e *countOriginalWithDistinct) AppendFinalResult2Chunk(sctx sessionctx.Context, pr PartialResult, chk *chunk.Chunk) error {
Expand Down Expand Up @@ -265,10 +266,10 @@ func (e *countOriginalWithDistinct) UpdatePartialResult(sctx sessionctx.Context,
}
}
encodedString := string(encodedBytes)
if hasNull || p.valSet.exist(encodedString) {
if hasNull || p.valSet.Exist(encodedString) {
continue
}
p.valSet.insert(encodedString)
p.valSet.Insert(encodedString)
p.count++
}

Expand Down
11 changes: 6 additions & 5 deletions executor/aggfuncs/func_group_concat.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/set"
)

type baseGroupConcat4String struct {
Expand Down Expand Up @@ -132,7 +133,7 @@ func (e *groupConcat) MergePartialResult(sctx sessionctx.Context, src, dst Parti
type partialResult4GroupConcatDistinct struct {
basePartialResult4GroupConcat
valsBuf *bytes.Buffer
valSet stringSet
valSet set.StringSet
}

type groupConcatDistinct struct {
Expand All @@ -142,13 +143,13 @@ type groupConcatDistinct struct {
func (e *groupConcatDistinct) AllocPartialResult() PartialResult {
p := new(partialResult4GroupConcatDistinct)
p.valsBuf = &bytes.Buffer{}
p.valSet = newStringSet()
p.valSet = set.NewStringSet()
return PartialResult(p)
}

func (e *groupConcatDistinct) ResetPartialResult(pr PartialResult) {
p := (*partialResult4GroupConcatDistinct)(pr)
p.buffer, p.valSet = nil, newStringSet()
p.buffer, p.valSet = nil, set.NewStringSet()
}

func (e *groupConcatDistinct) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup []chunk.Row, pr PartialResult) (err error) {
Expand All @@ -170,10 +171,10 @@ func (e *groupConcatDistinct) UpdatePartialResult(sctx sessionctx.Context, rowsI
continue
}
joinedVals := p.valsBuf.String()
if p.valSet.exist(joinedVals) {
if p.valSet.Exist(joinedVals) {
continue
}
p.valSet.insert(joinedVals)
p.valSet.Insert(joinedVals)
// write separator
if p.buffer == nil {
p.buffer = &bytes.Buffer{}
Expand Down
21 changes: 11 additions & 10 deletions executor/aggfuncs/func_sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/set"
)

type partialResult4SumFloat64 struct {
Expand All @@ -32,12 +33,12 @@ type partialResult4SumDecimal struct {

type partialResult4SumDistinctFloat64 struct {
partialResult4SumFloat64
valSet float64Set
valSet set.Float64Set
}

type partialResult4SumDistinctDecimal struct {
partialResult4SumDecimal
valSet decimalSet
valSet set.DecimalSet
}

type baseSumAggFunc struct {
Expand Down Expand Up @@ -173,14 +174,14 @@ type sum4DistinctFloat64 struct {
func (e *sum4DistinctFloat64) AllocPartialResult() PartialResult {
p := new(partialResult4SumDistinctFloat64)
p.isNull = true
p.valSet = newFloat64Set()
p.valSet = set.NewFloat64Set()
return PartialResult(p)
}

func (e *sum4DistinctFloat64) ResetPartialResult(pr PartialResult) {
p := (*partialResult4SumDistinctFloat64)(pr)
p.isNull = true
p.valSet = newFloat64Set()
p.valSet = set.NewFloat64Set()
}

func (e *sum4DistinctFloat64) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup []chunk.Row, pr PartialResult) error {
Expand All @@ -190,10 +191,10 @@ func (e *sum4DistinctFloat64) UpdatePartialResult(sctx sessionctx.Context, rowsI
if err != nil {
return errors.Trace(err)
}
if isNull || p.valSet.exist(input) {
if isNull || p.valSet.Exist(input) {
continue
}
p.valSet.insert(input)
p.valSet.Insert(input)
if p.isNull {
p.val = input
p.isNull = false
Expand Down Expand Up @@ -221,14 +222,14 @@ type sum4DistinctDecimal struct {
func (e *sum4DistinctDecimal) AllocPartialResult() PartialResult {
p := new(partialResult4SumDistinctDecimal)
p.isNull = true
p.valSet = newDecimalSet()
p.valSet = set.NewDecimalSet()
return PartialResult(p)
}

func (e *sum4DistinctDecimal) ResetPartialResult(pr PartialResult) {
p := (*partialResult4SumDistinctDecimal)(pr)
p.isNull = true
p.valSet = newDecimalSet()
p.valSet = set.NewDecimalSet()
}

func (e *sum4DistinctDecimal) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup []chunk.Row, pr PartialResult) error {
Expand All @@ -238,10 +239,10 @@ func (e *sum4DistinctDecimal) UpdatePartialResult(sctx sessionctx.Context, rowsI
if err != nil {
return errors.Trace(err)
}
if isNull || p.valSet.exist(input) {
if isNull || p.valSet.Exist(input) {
continue
}
p.valSet.insert(input)
p.valSet.Insert(input)
if p.isNull {
p.val = *input
p.isNull = false
Expand Down
61 changes: 0 additions & 61 deletions executor/aggfuncs/sets.go

This file was deleted.

Loading