Size chunk range storage to the emitted windows
This commit is contained in:
@@ -63,9 +63,15 @@ func (c *Chunker) PrepareChunk(ctx context.Context, req contracts.ChunkInput) (c
|
||||
}
|
||||
|
||||
step := c.options.MaxUnits - c.options.OverlapUnits
|
||||
count := len(req.Source.Units) / step
|
||||
if len(req.Source.Units)%step != 0 {
|
||||
count++
|
||||
// The first range covers MaxUnits; stop once a range reaches the end,
|
||||
// rather than reserving trailing windows that overlap the final range.
|
||||
count := 1
|
||||
if len(req.Source.Units) > c.options.MaxUnits {
|
||||
remaining := len(req.Source.Units) - c.options.MaxUnits
|
||||
count += remaining / step
|
||||
if remaining%step != 0 {
|
||||
count++
|
||||
}
|
||||
}
|
||||
ranges := make([]source.ChunkRange, 0, count)
|
||||
for start := 0; start < len(req.Source.Units); start += step {
|
||||
|
||||
Reference in New Issue
Block a user