| 86 | } |
| 87 | |
| 88 | func newOptions(cfg *config.LevelDBConfig) *opt.Options { |
| 89 | opts := &opt.Options{} |
| 90 | opts.ErrorIfMissing = false |
| 91 | |
| 92 | opts.BlockCacheCapacity = cfg.CacheSize |
| 93 | |
| 94 | //must use bloomfilter |
| 95 | opts.Filter = filter.NewBloomFilter(10) |
| 96 | |
| 97 | if !cfg.Compression { |
| 98 | opts.Compression = opt.NoCompression |
| 99 | } else { |
| 100 | opts.Compression = opt.SnappyCompression |
| 101 | } |
| 102 | |
| 103 | opts.BlockSize = cfg.BlockSize |
| 104 | opts.WriteBuffer = cfg.WriteBufferSize |
| 105 | opts.OpenFilesCacheCapacity = cfg.MaxOpenFiles |
| 106 | |
| 107 | // here we use default value, later add config support |
| 108 | opts.CompactionTableSize = 32 * 1024 * 1024 |
| 109 | opts.WriteL0SlowdownTrigger = 16 |
| 110 | opts.WriteL0PauseTrigger = 64 |
| 111 | |
| 112 | return opts |
| 113 | } |
| 114 | |
| 115 | func (s Store) Repair(path string, cfg *config.Config) error { |
| 116 | db, err := s.Open(path, cfg) |