Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
baabeetaa authored Aug 27, 2022
1 parent 1feecd5 commit 31989c1
Showing 1 changed file with 7 additions and 40 deletions.
47 changes: 7 additions & 40 deletions pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,48 +69,15 @@ type PebbleDB struct {

var _ DB = (*PebbleDB)(nil)

func NewPebbleDB(name string, dir string) (DB, error) {
dbPath := filepath.Join(dir, name+".db")
// cache := pebble.NewCache(1024 * 1024 * 32)
// defer cache.Unref()
opts := &pebble.Options{
// Cache: cache,
// FormatMajorVersion: pebble.FormatNewest,
// L0CompactionThreshold: 2,
// L0StopWritesThreshold: 1000,
// LBaseMaxBytes: 64 << 20, // 64 MB
// Levels: make([]pebble.LevelOptions, 7),
// MaxConcurrentCompactions: 3,
// MaxOpenFiles: 1024,
// MemTableSize: 64 << 20,
// MemTableStopWritesThreshold: 4,
}
/*
for i := 0; i < len(opts.Levels); i++ {
l := &opts.Levels[i]
l.BlockSize = 32 << 10 // 32 KB
l.IndexBlockSize = 256 << 10 // 256 KB
l.FilterPolicy = bloom.FilterPolicy(10)
l.FilterType = pebble.TableFilter
if i > 0 {
l.TargetFileSize = opts.Levels[i-1].TargetFileSize * 2
}
l.EnsureDefaults()
}
*/
// opts.Levels[6].FilterPolicy = nil
// opts.FlushSplitBytes = opts.Levels[0].TargetFileSize

//for i := 0; i < len(opts.Levels); i++ {
// l := &opts.Levels[i]
// l.Compression = pebble.NoCompression
// l.EnsureDefaults()
//}
//
//opts.DisableAutomaticCompactions = true

func NewPebbleDB(name string, dir string) (*PebbleDB, error) {
opts := &pebble.Options{}
opts.EnsureDefaults()
return NewPebbleDBWithOpts(name, dir, opts)
}

func NewPebbleDBWithOpts(name string, dir string, opts *pebble.Options) (*PebbleDB, error) {
dbPath := filepath.Join(dir, name+".db")
opts.EnsureDefaults()
p, err := pebble.Open(dbPath, opts)
if err != nil {
return nil, err
Expand Down

0 comments on commit 31989c1

Please sign in to comment.