示例#1
0
文件: flags.go 项目: unigraph/rdb
func setCompression(dbOptions *rdb.Options, compressionType string) {
	switch compressionType {
	case "none":
		dbOptions.SetCompression(rdb.NoCompression)
	case "snappy":
		dbOptions.SetCompression(rdb.SnappyCompression)
	case "zlib":
		dbOptions.SetCompression(rdb.ZLibCompression)
	case "bzip":
		dbOptions.SetCompression(rdb.Bz2Compression)
	case "lz4":
		dbOptions.SetCompression(rdb.Lz4Compression)
	default:
		dbOptions.SetCompression(rdb.Lz4Compression)
	}
}
示例#2
0
文件: flags.go 项目: unigraph/rdb
func (o *Options) SetOptions(dbOptions *rdb.Options) {
	setCompression(dbOptions, o.CompressionType)
	if o.Bulk {
		dbOptions.PrepareForBulkLoad()
		// this is what happens internaly for bulk load
		// see https://github.com/facebook/rocksdb/blob/master/util/options.cc#L625
		/*
			dbOptions.SetLevel0FileNumCompactionTrigger(1 << 30)
			dbOptions.SetLevel0SlowdownWritesTrigger(1 << 30)
			dbOptions.SetLevel0StopWritesTrigger(1 << 30)
			dbOptions.SetDisableAutoCompactions(true)
			dbOptions.SetDisableDataSync(true)
			dbOptions.SetSourceCompactionFactor(1 << 30)
			dbOptions.SetNumLevels(2)
			dbOptions.SetMaxWriteBufferNumber(6)
			dbOptions.SetMinWriteBufferNumberToMerge(1)
			dbOptions.SetMaxBackgroundFlushes(4)
			dbOptions.SetMaxBackgroundCompactions(4)
			dbOptions.SetTargetFileSizeBase(256 * 1024 * 1024)
		*/

	}
	dbOptions.SetNumLevels(o.NumLevels)
	dbOptions.SetWriteBufferSize(int(o.WriteBufferSize))
	dbOptions.SetMaxWriteBufferNumber(o.MaxWriteBufferNumber)
	dbOptions.SetMinWriteBufferNumberToMerge(o.MinWriteBufferNumberToMerge)
	//
	dbOptions.SetLevel0FileNumCompactionTrigger(o.Level0FileNumCompactionTrigger)
	dbOptions.SetLevel0SlowdownWritesTrigger(o.Level0SlowdownWritesTrigger)
	dbOptions.SetLevel0StopWritesTrigger(o.Level0StopWritesTrigger)
	dbOptions.SetMaxBytesForLevelBase(uint64(o.MaxBytesForLevelBase))
	dbOptions.SetMaxBytesForLevelMultiplier(o.MaxBytesForLevelMultiplier)
	dbOptions.SetTargetFileSizeBase(uint64(o.TargetFileSizeBase))
	dbOptions.SetTargetFileSizeMultiplier(o.TargetFileSizeMultiplier)
	dbOptions.SetSourceCompactionFactor(o.SourceCompactionFactor)
	dbOptions.SetDisableAutoCompactions(o.DisableAutoCompactions)

}