@@ -95,10 +95,40 @@ func TestSSTableManagerSelectCompactionCandidates(t *testing.T) {
95
95
path : "4" ,
96
96
})
97
97
98
- assertCompactionAction (t , 0 , []string {"4" }, manager .candidateTablesForCompaction (25 ))
99
- assertCompactionAction (t , 105 , []string {"2" , "3" , "4" }, manager .candidateTablesForCompaction (51 ))
100
- assertCompactionAction (t , 115 , []string {"1" , "2" , "3" , "4" }, manager .candidateTablesForCompaction (101 ))
101
- assertCompactionAction (t , 115 , []string {"1" , "2" , "3" , "4" }, manager .candidateTablesForCompaction (1500 ))
98
+ assertCompactionAction (t , 0 , []string {"4" }, manager .candidateTablesForCompaction (25 , 1 ))
99
+ assertCompactionAction (t , 105 , []string {"2" , "3" , "4" }, manager .candidateTablesForCompaction (51 , 1 ))
100
+ assertCompactionAction (t , 115 , []string {"1" , "2" , "3" , "4" }, manager .candidateTablesForCompaction (101 , 1 ))
101
+ assertCompactionAction (t , 115 , []string {"1" , "2" , "3" , "4" }, manager .candidateTablesForCompaction (1500 , 1 ))
102
+ }
103
+
104
+ func TestSSTableManagerSelectCompactionCandidatesTombstoneRatios (t * testing.T ) {
105
+ manager := NewSSTableManager (skiplist.BytesComparator {}, & sync.RWMutex {}, "" )
106
+
107
+ manager .addReader (& MockSSTableReader {
108
+ metadata : & proto.MetaData {NumRecords : 10 , NullValues : 8 , TotalBytes : 1000 },
109
+ path : "1" ,
110
+ })
111
+
112
+ manager .addReader (& MockSSTableReader {
113
+ metadata : & proto.MetaData {NumRecords : 5 , NullValues : 0 , TotalBytes : 1000 },
114
+ path : "2" ,
115
+ })
116
+
117
+ manager .addReader (& MockSSTableReader {
118
+ metadata : & proto.MetaData {NumRecords : 100 , NullValues : 10 , TotalBytes : 1000 },
119
+ path : "3" ,
120
+ })
121
+
122
+ manager .addReader (& MockSSTableReader {
123
+ metadata : & proto.MetaData {NumRecords : 0 , NullValues : 0 , TotalBytes : 1000 },
124
+ path : "4" ,
125
+ })
126
+
127
+ assertCompactionAction (t , 10 , []string {"1" }, manager .candidateTablesForCompaction (999 , 0.2 ))
128
+ // 1 and 3 should be selected by ratio, 2 is here for the ride because of flood filling
129
+ assertCompactionAction (t , 115 , []string {"1" , "2" , "3" }, manager .candidateTablesForCompaction (999 , 0.1 ))
130
+ assertCompactionAction (t , 115 , []string {"1" , "2" , "3" }, manager .candidateTablesForCompaction (999 , 0 ))
131
+ assertCompactionAction (t , 0 , nil , manager .candidateTablesForCompaction (999 , 1 ))
102
132
}
103
133
104
134
func TestSSTableManagerSelectCompactionCandidatesEmptyStart (t * testing.T ) {
@@ -124,8 +154,8 @@ func TestSSTableManagerSelectCompactionCandidatesEmptyStart(t *testing.T) {
124
154
path : "4" ,
125
155
})
126
156
127
- assertCompactionAction (t , 5 , []string {"1" , "2" , "3" }, manager .candidateTablesForCompaction (100 ))
128
- assertCompactionAction (t , 30 , []string {"1" , "2" , "3" , "4" }, manager .candidateTablesForCompaction (200 ))
157
+ assertCompactionAction (t , 5 , []string {"1" , "2" , "3" }, manager .candidateTablesForCompaction (100 , 1 ))
158
+ assertCompactionAction (t , 30 , []string {"1" , "2" , "3" , "4" }, manager .candidateTablesForCompaction (200 , 1 ))
129
159
}
130
160
131
161
func TestSSTableManagerSelectCompactionCandidatesTombstonedHoles (t * testing.T ) {
@@ -151,7 +181,7 @@ func TestSSTableManagerSelectCompactionCandidatesTombstonedHoles(t *testing.T) {
151
181
path : "4" ,
152
182
})
153
183
154
- assertCompactionAction (t , 3010 , []string {"2" , "3" , "4" }, manager .candidateTablesForCompaction (2000 ))
184
+ assertCompactionAction (t , 3010 , []string {"2" , "3" , "4" }, manager .candidateTablesForCompaction (2000 , 1 ))
155
185
}
156
186
157
187
func assertCompactionAction (t * testing.T , numRecords int , paths []string , actualAction compactionAction ) {
0 commit comments