-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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: support MAX/MIN in new evaluation framework partially #6971
Changes from 2 commits
0904a62
c0bef2d
740c63c
661dcd8
ed6cb9d
208e283
4f2e0a4
93bbe1d
f714f16
b14296c
85a7cda
ab1895a
ec9fa07
6db67e7
cdd3980
70e5c45
b65776e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ type partialResult4MaxMinUint struct { | |
} | ||
|
||
type partialResult4MaxMinDecimal struct { | ||
val *types.MyDecimal | ||
val types.MyDecimal | ||
isNull bool | ||
} | ||
|
||
|
@@ -138,14 +138,14 @@ func (e *maxMin4Uint) UpdatePartialResult(sctx sessionctx.Context, rowsInGroup [ | |
if isNull { | ||
continue | ||
} | ||
i := uint64(input) | ||
uintVal := uint64(input) | ||
if p.isNull { | ||
p.val = i | ||
p.val = uintVal | ||
p.isNull = false | ||
continue | ||
} | ||
if e.isMax && i > p.val || !e.isMax && i < p.val { | ||
p.val = i | ||
if e.isMax && uintVal > p.val || !e.isMax && uintVal < p.val { | ||
p.val = uintVal | ||
} | ||
} | ||
return nil | ||
|
@@ -255,13 +255,14 @@ type maxMin4Decimal struct { | |
|
||
func (e *maxMin4Decimal) AllocPartialResult() PartialResult { | ||
p := new(partialResult4MaxMinDecimal) | ||
p.val = *new(types.MyDecimal) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This operation can be removed? since we only set it once the first non-NULL value comes. |
||
p.isNull = true | ||
return PartialResult(p) | ||
} | ||
|
||
func (e *maxMin4Decimal) ResetPartialResult(pr PartialResult) { | ||
p := (*partialResult4MaxMinDecimal)(pr) | ||
p.val = new(types.MyDecimal) | ||
p.val = *new(types.MyDecimal) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
p.isNull = true | ||
} | ||
|
||
|
@@ -271,7 +272,7 @@ func (e *maxMin4Decimal) AppendFinalResult2Chunk(sctx sessionctx.Context, pr Par | |
chk.AppendNull(e.ordinal) | ||
return nil | ||
} | ||
chk.AppendMyDecimal(e.ordinal, p.val) | ||
chk.AppendMyDecimal(e.ordinal, &p.val) | ||
return nil | ||
} | ||
|
||
|
@@ -286,13 +287,13 @@ func (e *maxMin4Decimal) UpdatePartialResult(sctx sessionctx.Context, rowsInGrou | |
continue | ||
} | ||
if p.isNull { | ||
p.val = input | ||
p.val = *input | ||
p.isNull = false | ||
continue | ||
} | ||
cmp := input.Compare(p.val) | ||
cmp := input.Compare(&p.val) | ||
if e.isMax && cmp == 1 || !e.isMax && cmp == -1 { | ||
p.val = input | ||
p.val = *input | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cmp := input.Compare(*p)
if e.isMax && cmp == 1 || !e.isMax && cmp == -1 {
*p = input
} |
||
} | ||
return nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.