Skip to content

Commit

Permalink
Vary segment/skew thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
jamii committed Oct 30, 2023
1 parent 4f537bb commit 0890877
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions vng/vng_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

"github.com/brimdata/zed"
"github.com/brimdata/zed/pkg/nano"
"github.com/brimdata/zed/pkg/units"
"github.com/brimdata/zed/vng"
"github.com/brimdata/zed/zcode"
"github.com/brimdata/zed/zio/vngio"
"github.com/brimdata/zed/zson"
Expand All @@ -26,11 +28,29 @@ func FuzzVngRoundtrip(f *testing.F) {
context := zed.NewContext()
types := genTypes(bytesReader, context, 3)
values := genValues(bytesReader, types)
roundtrip(t, values)
ColumnThresh := int(binary.LittleEndian.Uint64(genBytes(bytesReader, 8)))
if ColumnThresh == 0 {
ColumnThresh = 1
}
if ColumnThresh > vng.MaxSegmentThresh {
ColumnThresh = vng.MaxSegmentThresh
}
SkewThresh := int(binary.LittleEndian.Uint64(genBytes(bytesReader, 8)))
if SkewThresh == 0 {
SkewThresh = 1
}
if SkewThresh > vng.MaxSkewThresh {
SkewThresh = vng.MaxSkewThresh
}
writerOpts := vngio.WriterOpts{
ColumnThresh: units.Bytes(ColumnThresh),
SkewThresh: units.Bytes(SkewThresh),
}
roundtrip(t, values, writerOpts)
})
}

func roundtrip(t *testing.T, valuesIn []zed.Value) {
func roundtrip(t *testing.T, valuesIn []zed.Value, writerOpts vngio.WriterOpts) {
// Debug
//for i := range valuesIn {
// t.Logf("value: in[%v].Bytes()=%v", i, valuesIn[i].Bytes())
Expand All @@ -39,7 +59,7 @@ func roundtrip(t *testing.T, valuesIn []zed.Value) {

// Write
var fileIn mockFile
writer, err := vngio.NewWriter(&fileIn, vngio.WriterOpts{ColumnThresh: vngio.DefaultColumnThresh, SkewThresh: vngio.DefaultSkewThresh})
writer, err := vngio.NewWriter(&fileIn, writerOpts)
if err != nil {
t.Fatalf("%v", err)
}
Expand Down

0 comments on commit 0890877

Please sign in to comment.