func (o *Options) SetCompactionStyle(style CompactionStyle) { C.rocksdb_options_set_compaction_style(o.Opt, C.int(style)) // TODO this will leak if Options is discarded uco := C.rocksdb_universal_compaction_options_create() //C.rocksdb_universal_compaction_options_set_size_ratio(uco, ratio) //C.rocksdb_universal_compaction_options_set_min_merge_width(uco, w) C.rocksdb_universal_compaction_options_set_max_merge_width(uco, 16) // Trigger compaction if size amplification exceeds 110% C.rocksdb_universal_compaction_options_set_max_size_amplification_percent(uco, 110) // TODO tune this so that we don't compress initially //C.rocksdb_universal_compaction_options_set_compression_size_percent(uco, p) //C.rocksdb_universal_compaction_options_set_stop_style(uco, style) C.rocksdb_options_set_universal_compaction_options(o.Opt, uco) }
// The size amplification is defined as the amount (in percentage) of // additional storage needed to store a single byte of data in the database. // For example, a size amplification of 2% means that a database that // contains 100 bytes of user-data may occupy upto 102 bytes of // physical storage. By this definition, a fully compacted database has // a size amplification of 0%. Rocksdb uses the following heuristic // to calculate size amplification: it assumes that all files excluding // the earliest file contribute to the size amplification. // Default: 200, which means that a 100 byte database could require upto // 300 bytes of storage. func (self *UniversalCompactionOptions) SetMaxSizeAmplificationPercent(value uint) { C.rocksdb_universal_compaction_options_set_max_size_amplification_percent(self.c, C.int(value)) }