@@ -3691,6 +3691,14 @@ func (v *Vector) GetMinMaxValue() (ok bool, minv, maxv []byte) {
3691
3691
3692
3692
// InplaceSortAndCompact @todo optimization in the future
3693
3693
func (v * Vector ) InplaceSortAndCompact () {
3694
+ cleanDataNotResetArea := func () {
3695
+ if v .data != nil {
3696
+ v .length = 0
3697
+ }
3698
+ v .nsp .Reset ()
3699
+ v .sorted = true
3700
+ }
3701
+
3694
3702
switch v .GetType ().Oid {
3695
3703
case types .T_bool :
3696
3704
col := MustFixedCol [bool ](v )
@@ -3973,49 +3981,47 @@ func (v *Vector) InplaceSortAndCompact() {
3973
3981
newCol := slices .CompactFunc (col , func (a , b types.Varlena ) bool {
3974
3982
return bytes .Equal (a .GetByteSlice (area ), b .GetByteSlice (area ))
3975
3983
})
3984
+
3976
3985
if len (newCol ) != len (col ) {
3977
- v .CleanOnlyData ()
3978
- v .SetSorted (true )
3986
+ cleanDataNotResetArea ()
3979
3987
appendList (v , newCol , nil , nil )
3980
3988
}
3981
3989
3982
3990
case types .T_array_float32 :
3983
3991
col , area := MustVarlenaRawData (v )
3984
3992
sort .Slice (col , func (i , j int ) bool {
3985
- return moarray .Compare [ float32 ] (
3993
+ return moarray .Compare (
3986
3994
types .GetArray [float32 ](& col [i ], area ),
3987
3995
types .GetArray [float32 ](& col [j ], area ),
3988
3996
) < 0
3989
3997
})
3990
3998
newCol := slices .CompactFunc (col , func (a , b types.Varlena ) bool {
3991
- return moarray .Compare [ float32 ] (
3999
+ return moarray .Compare (
3992
4000
types .GetArray [float32 ](& a , area ),
3993
4001
types .GetArray [float32 ](& b , area ),
3994
4002
) == 0
3995
4003
})
3996
4004
if len (newCol ) != len (col ) {
3997
- v .CleanOnlyData ()
3998
- v .SetSorted (true )
4005
+ cleanDataNotResetArea ()
3999
4006
appendList (v , newCol , nil , nil )
4000
4007
}
4001
4008
4002
4009
case types .T_array_float64 :
4003
4010
col , area := MustVarlenaRawData (v )
4004
4011
sort .Slice (col , func (i , j int ) bool {
4005
- return moarray .Compare [ float64 ] (
4012
+ return moarray .Compare (
4006
4013
types .GetArray [float64 ](& col [i ], area ),
4007
4014
types .GetArray [float64 ](& col [j ], area ),
4008
4015
) < 0
4009
4016
})
4010
4017
newCol := slices .CompactFunc (col , func (a , b types.Varlena ) bool {
4011
- return moarray .Compare [ float64 ] (
4018
+ return moarray .Compare (
4012
4019
types .GetArray [float64 ](& a , area ),
4013
4020
types .GetArray [float64 ](& b , area ),
4014
4021
) == 0
4015
4022
})
4016
4023
if len (newCol ) != len (col ) {
4017
- v .CleanOnlyData ()
4018
- v .SetSorted (true )
4024
+ cleanDataNotResetArea ()
4019
4025
appendList (v , newCol , nil , nil )
4020
4026
}
4021
4027
}
0 commit comments