| 131 | } |
| 132 | |
| 133 | func newOptions(cfg *config.LevelDBConfig) *opt.Options { |
| 134 | opts := &opt.Options{} |
| 135 | opts.ErrorIfMissing = false |
| 136 | |
| 137 | opts.BlockCacheCapacity = cfg.CacheSize |
| 138 | |
| 139 | // we must use bloomfilter |
| 140 | opts.Filter = filter.NewBloomFilter(defaultFilterBits) |
| 141 | |
| 142 | if !cfg.Compression { |
| 143 | opts.Compression = opt.NoCompression |
| 144 | } else { |
| 145 | opts.Compression = opt.SnappyCompression |
| 146 | } |
| 147 | |
| 148 | opts.BlockSize = cfg.BlockSize |
| 149 | opts.WriteBuffer = cfg.WriteBufferSize |
| 150 | opts.OpenFilesCacheCapacity = cfg.MaxOpenFiles |
| 151 | |
| 152 | // here we use default value, later add config support |
| 153 | opts.CompactionTableSize = 32 * 1024 * 1024 |
| 154 | opts.WriteL0SlowdownTrigger = 16 |
| 155 | opts.WriteL0PauseTrigger = 64 |
| 156 | |
| 157 | return opts |
| 158 | } |
| 159 | |
| 160 | func (db *DB) Close() error { |
| 161 | db.cache.Close() |