func GetOptions(create bool, config dvid.Config) (*lmdbOptions, error) { sizeInGB, found, err := config.GetInt("Size") if err != nil { return nil, err } if !found && create { return nil, fmt.Errorf("Must specify 'Size=...' in gigabytes during Lightning MDB creation.") } if found { return &lmdbOptions{GBytes: sizeInGB}, nil } return &lmdbOptions{}, nil }
func getOptions(config dvid.Config) (*leveldbOptions, error) { opt := &leveldbOptions{ Options: levigo.NewOptions(), ReadOptions: levigo.NewReadOptions(), WriteOptions: levigo.NewWriteOptions(), env: levigo.NewDefaultEnv(), } opt.WriteOptions.SetSync(DefaultSync) // Huge performance penalty to set sync to true // Set flags based on create parameter opt.SetCreateIfMissing(true) opt.SetErrorIfExists(false) // Create associated data structures with default values bloomBits, found, err := config.GetInt("BloomFilterBitsPerKey") if err != nil { return nil, err } if !found { bloomBits = DefaultBloomBits } opt.SetBloomFilterBitsPerKey(bloomBits) cacheSize, found, err := config.GetInt("CacheSize") if err != nil { return nil, err } if !found { cacheSize = DefaultCacheSize } else { cacheSize *= dvid.Mega } dvid.Infof("leveldb cache size: %s\n", humanize.Bytes(uint64(cacheSize))) opt.SetLRUCacheSize(cacheSize) writeBufferSize, found, err := config.GetInt("WriteBufferSize") if err != nil { return nil, err } if !found { writeBufferSize = DefaultWriteBufferSize } else { writeBufferSize *= dvid.Mega } dvid.Infof("leveldb write buffer size: %s\n", humanize.Bytes(uint64(writeBufferSize))) opt.SetWriteBufferSize(writeBufferSize) maxOpenFiles, found, err := config.GetInt("MaxOpenFiles") if err != nil { return nil, err } if !found { maxOpenFiles = DefaultMaxOpenFiles } opt.SetMaxOpenFiles(maxOpenFiles) blockSize, found, err := config.GetInt("BlockSize") if err != nil { return nil, err } if !found { blockSize = DefaultBlockSize } opt.SetBlockSize(blockSize) opt.SetInfoLog(nil) opt.SetParanoidChecks(false) //opt.SetBlockRestartInterval(8) // Don't bother with compression on leveldb side because it will be // selectively applied on DVID side. We may return and then transmit // Snappy-compressed data without ever decompressing on server-side. opt.SetCompression(levigo.NoCompression) // (levigo.SnappyCompression) return opt, nil }