Skip to content

Commit

Permalink
internal/manifest: fix Overlaps L0 expansion with exclusive-end
Browse files Browse the repository at this point in the history
When Version.Overlaps is called for L0, the overlap window is
iteratively expanded until stable. In #1432, the Overlaps function was
adjusted to allow specifying that the end bound should be considered
exclusive. However, #1432 failed to update the exclusivity of the end
bound when the range widened. This improperly excluded files with
largest keys that exactly equaled the new widened end bound.

This commit also transforms the TestOverlaps test into a datadriven
test, introducing a few helpers for parsing the DebugString output of a
Version.

Fix #1459.
  • Loading branch information
jbowens committed Jan 21, 2022
1 parent a4a6fe8 commit a241910
Show file tree
Hide file tree
Showing 4 changed files with 602 additions and 189 deletions.
13 changes: 13 additions & 0 deletions internal/base/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,16 @@ type prettyInternalKey struct {
func (k prettyInternalKey) Format(s fmt.State, c rune) {
fmt.Fprintf(s, "%s#%d,%s", k.formatKey(k.UserKey), k.SeqNum(), k.Kind())
}

// ParsePrettyInternalKey parses the pretty string representation of an
// internal key. The format is <user-key>#<seq-num>,<kind>.
func ParsePrettyInternalKey(s string) InternalKey {
x := strings.FieldsFunc(s, func(c rune) bool { return c == '#' || c == ',' })
ukey := x[0]
kind, ok := kindsMap[x[2]]
if !ok {
panic(fmt.Sprintf("unknown kind: %q", x[2]))
}
seqNum, _ := strconv.ParseUint(x[1], 10, 64)
return MakeInternalKey([]byte(ukey), seqNum, kind)
}
Loading

0 comments on commit a241910

Please sign in to comment.