From dce814d7490ee9972eedd2e6b940dea07348afe3 Mon Sep 17 00:00:00 2001 From: Aaron Son Date: Tue, 5 Mar 2024 12:04:06 -0800 Subject: [PATCH] go/store/datas/pull: pull_chunk_tracker.go: PR feedback: Round out the last batch returned from GetChunksToFetch. --- go/store/datas/pull/pull_chunk_tracker.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/go/store/datas/pull/pull_chunk_tracker.go b/go/store/datas/pull/pull_chunk_tracker.go index 7d91fe1510..1e6a5bf772 100644 --- a/go/store/datas/pull/pull_chunk_tracker.go +++ b/go/store/datas/pull/pull_chunk_tracker.go @@ -194,9 +194,17 @@ func (t *PullChunkTracker) reqRespThread(initial hash.HashSet) { req.hs = absent[0] var i int for i = 1; i < len(absent); i++ { - if len(req.hs)+len(absent[i]) < t.cfg.BatchSize { + l := len(absent[i]) + if len(req.hs)+l < t.cfg.BatchSize { req.hs.InsertAll(absent[i]) } else { + for h := range absent[i] { + if len(req.hs) >= t.cfg.BatchSize { + break + } + req.hs.Insert(h) + absent[i].Remove(h) + } break } }