Skip to content

Commit

Permalink
expression: let expression.Column take Sel into account wh… (ping…
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 authored and zz-jason committed Oct 14, 2019
1 parent 1fe25e0 commit 5466a3c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions expression/builtin_vectorized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,26 @@ func (s *testEvaluatorSuite) TestFloat32ColVec(c *C) {
c.Assert(v, Equals, result.GetFloat64(i))
i++
}

// set Sel
n := chk.NumRows()
sel := make([]int, n/2)
for i := 0; i < n; i += 2 {
sel = append(sel, i)
}
chk.SetSel(sel)
c.Assert(col.VecEvalReal(ctx, chk, result), IsNil)
i = 0
for row := it.Begin(); row != it.End(); row = it.Next() {
v, _, err := col.EvalReal(ctx, row)
c.Assert(err, IsNil)
c.Assert(v, Equals, result.GetFloat64(i))
i++
}

// set an empty Sel
sel = sel[:0]
c.Assert(col.VecEvalReal(ctx, chk, result), IsNil)
}

func BenchmarkFloat32ColRow(b *testing.B) {
Expand Down
11 changes: 11 additions & 0 deletions expression/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ func (col *Column) VecEvalReal(ctx sessionctx.Context, input *chunk.Chunk, resul
result.ResizeFloat64(n, false)
f32s := src.Float32s()
f64s := result.Float64s()
sel := input.Sel()
if sel != nil {
for i, j := range sel {
if src.IsNull(j) {
result.SetNull(i, true)
} else {
f64s[i] = float64(f32s[j])
}
}
return nil
}
for i := range f32s {
// TODO(zhangyuanjia): speed up the way to manipulate null-bitmaps.
if src.IsNull(i) {
Expand Down

0 comments on commit 5466a3c

Please sign in to comment.