Skip to content

Commit

Permalink
sstable: reorganize sstable buffers and structs
Browse files Browse the repository at this point in the history
This pr aims to serve as a first step towards unifying the parallel compression vs
on parallel compression code paths, as suggested in this pr:
#1383 (review).

This pr organizes the buffers in the Writer in a way which makes it easier to reason
about the ownership of buffers/slices.

Future prs will add, a writeQueue, a compressionQueue, a mechanism to schedule parallel
compression based on cpu utilization.
  • Loading branch information
bananabrick committed Jan 19, 2022
1 parent 20f8dd0 commit 7f1a70d
Show file tree
Hide file tree
Showing 3 changed files with 201 additions and 113 deletions.
46 changes: 32 additions & 14 deletions sstable/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,20 +824,38 @@ func (errorPropCollector) Name() string {
}

func TestTablePropertyCollectorErrors(t *testing.T) {
mem := vfs.NewMem()
f, err := mem.Create("foo")
require.NoError(t, err)

var opts WriterOptions
opts.TablePropertyCollectors = append(opts.TablePropertyCollectors,
func() TablePropertyCollector {
return errorPropCollector{}
})
var testcases map[string]func(w *Writer) error = map[string]func(w *Writer) error{
"add a#0,1 failed": func(w *Writer) error {
return w.Set([]byte("a"), []byte("b"))
},
"add c#0,0 failed": func(w *Writer) error {
return w.Delete([]byte("c"))
},
"add d#0,15 failed": func(w *Writer) error {
return w.DeleteRange([]byte("d"), []byte("e"))
},
"add f#0,2 failed": func(w *Writer) error {
return w.Merge([]byte("f"), []byte("g"))
},
"finish failed": func(w *Writer) error {
return w.Close()
},
}

for e, fun := range testcases {
mem := vfs.NewMem()
f, err := mem.Create("foo")
require.NoError(t, err)

w := NewWriter(f, opts)
require.Regexp(t, `add a#0,1 failed`, w.Set([]byte("a"), []byte("b")))
require.Regexp(t, `add c#0,0 failed`, w.Delete([]byte("c")))
require.Regexp(t, `add d#0,15 failed`, w.DeleteRange([]byte("d"), []byte("e")))
require.Regexp(t, `add f#0,2 failed`, w.Merge([]byte("f"), []byte("g")))
require.Regexp(t, `finish failed`, w.Close())
var opts WriterOptions
opts.TablePropertyCollectors = append(opts.TablePropertyCollectors,
func() TablePropertyCollector {
return errorPropCollector{}
})

w := NewWriter(f, opts)

require.Regexp(t, e, fun(w))
}
}
Loading

0 comments on commit 7f1a70d

Please sign in to comment.