fix: 修复 file.ReadLineWithParallel 函数由于错误的读取数量导致重复读和效率低下的问题

This commit is contained in:
kercylan98 2023-12-09 10:26:51 +08:00
parent 342d3cd75f
commit f19e7ccefa
1 changed files with 3 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package file
import (
"bufio"
"fmt"
"github.com/kercylan98/minotaur/utils/slice"
"io"
"os"
@ -186,7 +187,8 @@ func ReadLineWithParallel(filename string, chunkSize int64, handlerFunc func(str
end = e + 1
}
endMutex.Unlock()
r := io.NewSectionReader(file, chunk[0], e)
r := io.NewSectionReader(file, chunk[0], e-chunk[0])
fmt.Println(chunk[0], e)
scanner := bufio.NewScanner(r)
for scanner.Scan() {