github.com/cockroachdb/pebble@v1.1.2/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 //go:build make_test_sstables 6 // +build make_test_sstables 7 8 // Run using: go run -tags make_test_sstables ./tool/make_test_sstables.go 9 package main 10 11 import ( 12 "log" 13 14 "github.com/cockroachdb/pebble/internal/private" 15 "github.com/cockroachdb/pebble/objstorage/objstorageprovider" 16 "github.com/cockroachdb/pebble/sstable" 17 "github.com/cockroachdb/pebble/vfs" 18 ) 19 20 func makeOutOfOrder() { 21 fs := vfs.Default 22 f, err := fs.Create("tool/testdata/out-of-order.sst") 23 if err != nil { 24 log.Fatal(err) 25 } 26 w := sstable.NewWriter(objstorageprovider.NewFileWritable(f), sstable.WriterOptions{}) 27 private.SSTableWriterDisableKeyOrderChecks(w) 28 29 set := func(key string) { 30 if err := w.Set([]byte(key), nil); err != nil { 31 log.Fatal(err) 32 } 33 } 34 35 set("a") 36 set("c") 37 set("b") 38 39 if err := w.Close(); err != nil { 40 log.Fatal(err) 41 } 42 } 43 44 func main() { 45 makeOutOfOrder() 46 }