[#473] Do not modify traverse plan when [0] copies number vector is provided

Signed-off-by: Alex Vanin <a.vanin@yadro.com>
This commit is contained in:
Alexey Vanin 2023-07-05 19:49:58 +03:00
parent b520a3049e
commit c6df6c84ae

View file

@ -97,10 +97,16 @@ func NewTraverser(opts ...Option) (*Traverser, error) {
} else {
rem = defaultCopiesVector(cfg.policy)
// compatibleZeroVector is a bool flag which is set when cfg.copyNumbers
// is [0]. In this case we should not modify `rem` slice unless track
// copies are ignored, because [0] means that all copies should be
// stored before returning OK to the client.
compatibleZeroVector := len(cfg.copyNumbers) == 1 && cfg.copyNumbers[0] == 0
for i := range rem {
if !cfg.trackCopies {
rem[i] = -1
} else if len(cfg.copyNumbers) > i {
} else if len(cfg.copyNumbers) > i && !compatibleZeroVector {
rem[i] = int(cfg.copyNumbers[i])
}
}