github.com/cockroachdb/pebble@v0.0.0-20231214172447-ab4952c5f87b/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 opts := sstable.WriterOptions{ 27 TableFormat: sstable.TableFormatPebblev1, 28 } 29 w := sstable.NewWriter(objstorageprovider.NewFileWritable(f), opts) 30 private.SSTableWriterDisableKeyOrderChecks(w) 31 32 set := func(key string) { 33 if err := w.Set([]byte(key), nil); err != nil { 34 log.Fatal(err) 35 } 36 } 37 38 set("a") 39 set("c") 40 set("b") 41 42 if err := w.Close(); err != nil { 43 log.Fatal(err) 44 } 45 } 46 47 func main() { 48 makeOutOfOrder() 49 }