Skip to content

Commit 0c90a2f

Browse files
authored
improve scorch config parsing of forced zap version (#1401)
previous version did not correctly handle integer values stored in a float64 due to JSON parsing
1 parent 04c39ad commit 0c90a2f

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

index/scorch/scorch.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,18 @@ func NewScorch(storeName string,
142142
// configForceSegmentTypeVersion checks if the caller has requested a
143143
// specific segment type/version
144144
func configForceSegmentTypeVersion(config map[string]interface{}) (string, uint32, error) {
145-
forcedSegmentVersion, ok := config["forceSegmentVersion"].(int)
146-
if ok {
147-
forcedSegmentType, ok2 := config["forceSegmentType"].(string)
148-
if !ok2 {
149-
return "", 0, fmt.Errorf(
150-
"forceSegmentVersion set to %d, must also specify forceSegmentType", forcedSegmentVersion)
151-
}
145+
forcedSegmentVersion, err := parseToInteger(config["forceSegmentVersion"])
146+
if err != nil {
147+
return "", 0, nil
148+
}
152149

153-
return forcedSegmentType, uint32(forcedSegmentVersion), nil
150+
forcedSegmentType, ok := config["forceSegmentType"].(string)
151+
if !ok {
152+
return "", 0, fmt.Errorf(
153+
"forceSegmentVersion set to %d, must also specify forceSegmentType", forcedSegmentVersion)
154154
}
155-
return "", 0, nil
155+
156+
return forcedSegmentType, uint32(forcedSegmentVersion), nil
156157
}
157158

158159
func (s *Scorch) paused() uint64 {

0 commit comments

Comments
 (0)