Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/manifest: rework printing and parsing #1558

Merged
merged 4 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions compaction_picker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func TestCompactionPickerL0(t *testing.T) {
picker.initLevelMaxBytes(inProgressCompactions)

var buf bytes.Buffer
fmt.Fprint(&buf, version.DebugString(base.DefaultFormatter))
fmt.Fprint(&buf, version.String())
if len(inProgressCompactions) > 0 {
fmt.Fprintln(&buf, "compactions")
for _, c := range inProgressCompactions {
Expand Down Expand Up @@ -711,7 +711,7 @@ func TestCompactionPickerConcurrency(t *testing.T) {
vs.picker = picker

var buf bytes.Buffer
fmt.Fprint(&buf, version.DebugString(base.DefaultFormatter))
fmt.Fprint(&buf, version.String())
if len(inProgressCompactions) > 0 {
fmt.Fprintln(&buf, "compactions")
for _, c := range inProgressCompactions {
Expand Down Expand Up @@ -852,7 +852,7 @@ func TestCompactionPickerPickReadTriggered(t *testing.T) {
vs.picker = picker

var buf bytes.Buffer
fmt.Fprint(&buf, vers.DebugString(base.DefaultFormatter))
fmt.Fprint(&buf, vers.String())
return buf.String()

case "add-read-compaction":
Expand Down Expand Up @@ -1206,7 +1206,7 @@ func TestCompactionOutputFileSize(t *testing.T) {
vs.picker = picker

var buf bytes.Buffer
fmt.Fprint(&buf, vers.DebugString(base.DefaultFormatter))
fmt.Fprint(&buf, vers.String())
return buf.String()

case "pick-auto":
Expand Down
20 changes: 10 additions & 10 deletions compaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ func TestManualCompaction(t *testing.T) {
}

d.mu.Lock()
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s

Expand Down Expand Up @@ -1283,7 +1283,7 @@ func TestManualCompaction(t *testing.T) {
return
}
d.mu.Lock()
s = d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s = d.mu.versions.currentVersion().String()
d.mu.Unlock()
close(ch)
}()
Expand Down Expand Up @@ -1579,7 +1579,7 @@ func TestCompactionFindL0Limit(t *testing.T) {
flushSplitKeys := vers.L0Sublevels.FlushSplitKeys()

var buf strings.Builder
buf.WriteString(vers.DebugString(base.DefaultFormatter))
buf.WriteString(vers.String())
buf.WriteString("flush split keys:\n")
for _, key := range flushSplitKeys {
fmt.Fprintf(&buf, "\t%s\n", base.DefaultFormatter(key))
Expand Down Expand Up @@ -1763,7 +1763,7 @@ func TestCompactionDeleteOnlyHints(t *testing.T) {
t = t.Add(time.Second)
return t
}
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s

Expand Down Expand Up @@ -1875,7 +1875,7 @@ func TestCompactionDeleteOnlyHints(t *testing.T) {
}
d.mu.Lock()
compactInfo = nil
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s

Expand Down Expand Up @@ -1994,7 +1994,7 @@ func TestCompactionTombstones(t *testing.T) {
t = t.Add(time.Second)
return t
}
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s

Expand Down Expand Up @@ -2037,7 +2037,7 @@ func TestCompactionTombstones(t *testing.T) {

case "version":
d.mu.Lock()
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s

Expand Down Expand Up @@ -2182,7 +2182,7 @@ func TestCompactionReadTriggered(t *testing.T) {
t = t.Add(time.Second)
return t
}
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s

Expand Down Expand Up @@ -2247,7 +2247,7 @@ func TestCompactionReadTriggered(t *testing.T) {

case "version":
d.mu.Lock()
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s

Expand Down Expand Up @@ -2308,7 +2308,7 @@ func TestCompactionInuseKeyRanges(t *testing.T) {
}
}
c.version = newVersion(opts, files)
return c.version.DebugString(c.formatKey)
return c.version.String()

case "inuse-key-ranges":
var buf bytes.Buffer
Expand Down
2 changes: 1 addition & 1 deletion data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ func runIngestCmd(td *datadriven.TestData, d *DB, fs vfs.FS) error {

func runLSMCmd(td *datadriven.TestData, d *DB) string {
d.mu.Lock()
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s
}
4 changes: 2 additions & 2 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,13 @@ func TestLargeBatch(t *testing.T) {

// Verify this results in one L0 table being created.
require.NoError(t, try(100*time.Microsecond, 20*time.Second,
verifyLSM("0.0:\n 000005:[a-a]\n")))
verifyLSM("0.0:\n 000005:[a#1,SET-a#1,SET]\n")))

require.NoError(t, d.Set([]byte("b"), bytes.Repeat([]byte("b"), 512), nil))

// Verify this results in a second L0 table being created.
require.NoError(t, try(100*time.Microsecond, 20*time.Second,
verifyLSM("0.0:\n 000005:[a-a]\n 000007:[b-b]\n")))
verifyLSM("0.0:\n 000005:[a#1,SET-a#1,SET]\n 000007:[b#2,SET-b#2,SET]\n")))

// Allocate a bunch of batches to exhaust the batchPool. None of these
// batches should have a non-zero count.
Expand Down
3 changes: 1 addition & 2 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"testing"

"github.com/cockroachdb/errors"
"github.com/cockroachdb/pebble/internal/base"
"github.com/cockroachdb/pebble/internal/errorfs"
"github.com/cockroachdb/pebble/vfs"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -76,7 +75,7 @@ func expectLSM(expected string, d *DB, t *testing.T) {
t.Helper()
expected = strings.TrimSpace(expected)
d.mu.Lock()
actual := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
actual := d.mu.versions.currentVersion().String()
d.mu.Unlock()
actual = strings.TrimSpace(actual)
if expected != actual {
Expand Down
5 changes: 2 additions & 3 deletions flush_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"github.com/cockroachdb/errors"
"github.com/cockroachdb/pebble/internal/base"
"github.com/cockroachdb/pebble/internal/datadriven"
"github.com/cockroachdb/pebble/vfs"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -47,7 +46,7 @@ func TestManualFlush(t *testing.T) {
}

d.mu.Lock()
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s

Expand All @@ -73,7 +72,7 @@ func TestManualFlush(t *testing.T) {
}

d.mu.Lock()
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s

Expand Down
4 changes: 2 additions & 2 deletions ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ func TestIngestTargetLevel(t *testing.T) {
readState.unref()

d.mu.Lock()
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s

Expand Down Expand Up @@ -827,7 +827,7 @@ func TestConcurrentIngestCompact(t *testing.T) {

lsm := func() string {
d.mu.Lock()
s := d.mu.versions.currentVersion().DebugString(base.DefaultFormatter)
s := d.mu.versions.currentVersion().String()
d.mu.Unlock()
return s
}
Expand Down
30 changes: 9 additions & 21 deletions internal/manifest/testdata/file_metadata_bounds
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
extend-point-key-bounds
a.SET.0 - z.DEL.42
----
combined: [a#0,1-z#42,0]
points: [a#0,1-z#42,0]
000000:[a#0,SET-z#42,DEL] points:[a#0,SET-z#42,DEL]

# Rangedels only (single update).

Expand All @@ -14,8 +13,7 @@ reset
extend-point-key-bounds
a.RANGEDEL.0:z
----
combined: [a#0,15-z#72057594037927935,15]
points: [a#0,15-z#72057594037927935,15]
000000:[a#0,RANGEDEL-z#72057594037927935,RANGEDEL] points:[a#0,RANGEDEL-z#72057594037927935,RANGEDEL]

# Range keys only (single update).

Expand All @@ -25,8 +23,7 @@ reset
extend-range-key-bounds
a.RANGEKEYSET.0:z
----
combined: [a#0,21-z#72057594037927935,21]
ranges: [a#0,21-z#72057594037927935,21]
000000:[a#0,RANGEKEYSET-z#72057594037927935,RANGEKEYSET] ranges:[a#0,RANGEKEYSET-z#72057594037927935,RANGEKEYSET]

# Multiple updates with various key kinds.

Expand All @@ -36,50 +33,41 @@ reset
extend-point-key-bounds
m.SET.0 - n.SET.0
----
combined: [m#0,1-n#0,1]
points: [m#0,1-n#0,1]
000000:[m#0,SET-n#0,SET] points:[m#0,SET-n#0,SET]

# Extend the lower point key bound.

extend-point-key-bounds
j.SET.0 - k.SET.0
----
combined: [j#0,1-n#0,1]
points: [j#0,1-n#0,1]
000000:[j#0,SET-n#0,SET] points:[j#0,SET-n#0,SET]

# Extend the upper point key bound with a rangedel.

extend-point-key-bounds
k.RANGEDEL.0:o
----
combined: [j#0,1-o#72057594037927935,15]
points: [j#0,1-o#72057594037927935,15]
000000:[j#0,SET-o#72057594037927935,RANGEDEL] points:[j#0,SET-o#72057594037927935,RANGEDEL]

# Extend the lower bounds bound with a range key.

extend-range-key-bounds
a.RANGEKEYSET.42:m
----
combined: [a#42,21-o#72057594037927935,15]
points: [j#0,1-o#72057594037927935,15]
ranges: [a#42,21-m#72057594037927935,21]
000000:[a#42,RANGEKEYSET-o#72057594037927935,RANGEDEL] points:[j#0,SET-o#72057594037927935,RANGEDEL] ranges:[a#42,RANGEKEYSET-m#72057594037927935,RANGEKEYSET]

# Extend again with a wide range key (equal keys tiebreak on seqnums descending,
# so the overall lower bound is unchanged).

extend-range-key-bounds
a.RANGEKEYSET.0:z
----
combined: [a#42,21-z#72057594037927935,21]
points: [j#0,1-o#72057594037927935,15]
ranges: [a#42,21-z#72057594037927935,21]
000000:[a#42,RANGEKEYSET-z#72057594037927935,RANGEKEYSET] points:[j#0,SET-o#72057594037927935,RANGEDEL] ranges:[a#42,RANGEKEYSET-z#72057594037927935,RANGEKEYSET]

# Extend again with a wide rangedel over the same range (equal keys and sequnums
# tiebreak on key kind descending, so the overall upper bound is updated).

extend-point-key-bounds
a.RANGEDEL.0:z
----
combined: [a#42,21-z#72057594037927935,15]
points: [a#0,15-z#72057594037927935,15]
ranges: [a#42,21-z#72057594037927935,21]
000000:[a#42,RANGEKEYSET-z#72057594037927935,RANGEDEL] points:[a#0,RANGEDEL-z#72057594037927935,RANGEDEL] ranges:[a#42,RANGEKEYSET-z#72057594037927935,RANGEKEYSET]
Loading