forked from yihuang/grocksdb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
options_compaction_test.go
61 lines (44 loc) · 1.63 KB
/
options_compaction_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package grocksdb
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestOptionCompactions(t *testing.T) {
co := NewCompactRangeOptions()
defer co.Destroy()
co.SetFullHistoryTsLow([]byte{1, 2, 3})
require.EqualValues(t, false, co.GetExclusiveManualCompaction())
co.SetExclusiveManualCompaction(true)
require.EqualValues(t, true, co.GetExclusiveManualCompaction())
require.EqualValues(t, KIfHaveCompactionFilter, co.BottommostLevelCompaction())
co.SetBottommostLevelCompaction(KForce)
require.EqualValues(t, KForce, co.BottommostLevelCompaction())
require.EqualValues(t, false, co.ChangeLevel())
co.SetChangeLevel(true)
require.EqualValues(t, true, co.ChangeLevel())
require.EqualValues(t, -1, co.TargetLevel())
co.SetTargetLevel(2)
require.EqualValues(t, 2, co.TargetLevel())
}
func TestFifoCompactOption(t *testing.T) {
fo := NewDefaultFIFOCompactionOptions()
defer fo.Destroy()
fo.SetMaxTableFilesSize(2 << 10)
require.EqualValues(t, 2<<10, fo.GetMaxTableFilesSize())
}
func TestUniversalCompactOption(t *testing.T) {
uo := NewDefaultUniversalCompactionOptions()
defer uo.Destroy()
uo.SetSizeRatio(2)
require.EqualValues(t, 2, uo.GetSizeRatio())
uo.SetMinMergeWidth(3)
require.EqualValues(t, 3, uo.GetMinMergeWidth())
uo.SetMaxMergeWidth(123)
require.EqualValues(t, 123, uo.GetMaxMergeWidth())
uo.SetMaxSizeAmplificationPercent(20)
require.EqualValues(t, 20, uo.GetMaxSizeAmplificationPercent())
uo.SetCompressionSizePercent(18)
require.EqualValues(t, 18, uo.GetCompressionSizePercent())
uo.SetStopStyle(CompactionStopStyleTotalSize)
require.EqualValues(t, CompactionStopStyleTotalSize, uo.GetStopStyle())
}