github.com/petermattis/pebble@v0.0.0-20190905164901-ab51a2166067/tool/make_test_sstables.go (about) 1 // Copyright 2019 The LevelDB-Go and Pebble Authors. All rights reserved. Use 2 // of this source code is governed by a BSD-style license that can be found in 3 // the LICENSE file. 4 5 // +build make_test_sstables 6 7 // Run using: go run -tags make_test_sstables make_test_sstables.go 8 package main 9 10 import ( 11 "log" 12 13 "github.com/petermattis/pebble/sstable" 14 "github.com/petermattis/pebble/vfs" 15 ) 16 17 func makeOutOfOrder() { 18 fs := vfs.Default 19 f, err := fs.Create("testdata/out-of-order.sst") 20 if err != nil { 21 log.Fatal(err) 22 } 23 w := sstable.NewWriter(f, nil, sstable.TableOptions{}) 24 25 set := func(key string) { 26 if err := w.Set([]byte(key), nil); err != nil { 27 log.Fatal(err) 28 } 29 } 30 31 // NB: The check for out-of-order keys needs to be disabled in order for this 32 // to work without error. Currently this is in sstable/Writer.addPoint. 33 set("a") 34 set("c") 35 set("b") 36 37 if err := w.Close(); err != nil { 38 log.Fatal(err) 39 } 40 } 41 42 func main() { 43 makeOutOfOrder() 44 }