本文整理汇总了Golang中github.com/janelia-flyem/dvid/dvid.Config.GetInt方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.GetInt方法的具体用法?Golang Config.GetInt怎么用?Golang Config.GetInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/janelia-flyem/dvid/dvid.Config
的用法示例。
在下文中一共展示了Config.GetInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetOptions
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
}
示例2: getOptions
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
}