From b94e8233e43bc067f5d75ed18de1fb403e39cb5c Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Tue, 9 Feb 2021 18:27:13 +0100 Subject: [PATCH] ChunkRows: replace float with int arithmetic --- connection/mysql_utils.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/connection/mysql_utils.go b/connection/mysql_utils.go index f32e9dc4..7e05ce8d 100644 --- a/connection/mysql_utils.go +++ b/connection/mysql_utils.go @@ -10,7 +10,6 @@ import ( "github.com/go-sql-driver/mysql" "io/ioutil" oldlog "log" - "math" "sort" "strconv" "strings" @@ -426,11 +425,14 @@ type Row interface { type RowFactory func() Row func ChunkRows(rows []Row, size int) [][]Row { - chunksLen := int(math.Ceil(float64(len(rows)) / float64(size))) + chunksLen := len(rows) / size + if len(rows)%size != 0 { + chunksLen++ + } chunks := make([][]Row, chunksLen) for i := 0; i < chunksLen; i++ { - start := i * size; + start := i * size end := start + size if end > len(rows) { end = len(rows)