-
Notifications
You must be signed in to change notification settings - Fork 66
/
options_compaction_test.go
71 lines (50 loc) · 1.79 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
62
63
64
65
66
67
68
69
70
71
package grocksdb
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestOptionCompactions(t *testing.T) {
t.Parallel()
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) {
t.Parallel()
fo := NewDefaultFIFOCompactionOptions()
defer fo.Destroy()
fo.SetMaxTableFilesSize(2 << 10)
require.EqualValues(t, 2<<10, fo.GetMaxTableFilesSize())
require.False(t, fo.AllowCompaction())
fo.SetAllowCompaction(true)
require.True(t, fo.AllowCompaction())
}
func TestUniversalCompactOption(t *testing.T) {
t.Parallel()
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())
}