Skip to content

Commit 7bd7344

Browse files
authored
Merge pull request #131 from orlangure/improve-slices-in-batch
Prevent unnecessary slices in Batch
2 parents efd120d + 3618253 commit 7bd7344

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

batch.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ func (b *batch) Run(ctx context.Context, inp, out chan Dataset) error {
3333
if sliceEnd > dataLen {
3434
sliceEnd = dataLen
3535
}
36-
delta := data.Slice(sliceStart, sliceEnd).(Dataset)
36+
delta := data
37+
if dataLen > rowsLeft || sliceStart > 0 {
38+
delta = data.Slice(sliceStart, sliceEnd).(Dataset)
39+
}
3740

3841
if delta.Len() == b.Size {
3942
out <- delta

0 commit comments

Comments
 (0)