MCPcopy Create free account
hub / github.com/cactus-compute/cactus / test_compact

Function test_compact

tests/test_index.cpp:175–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175bool test_compact() {
176 IndexFixture f("test_compact");
177 if (!f.init()) return false;
178
179 f.add_batch(0, 20);
180
181 struct stat st_before;
182 stat((f.path() + "/index.bin").c_str(), &st_before);
183
184 f.del({0, 2, 4, 6, 8, 10, 12, 14, 16, 18}); // Delete even IDs
185 f.compact();
186
187 struct stat st_after;
188 stat((f.path() + "/index.bin").c_str(), &st_after);
189
190 if (st_after.st_size >= st_before.st_size) return false;
191
192 if (f.get(1).second != "doc1") return false;
193 if (f.get(19).second != "doc19") return false;
194
195 if (f.get(0).first == 0) return false;
196
197 return true;
198}
199
200bool test_persistence() {
201 IndexFixture f("test_persist");

Callers 1

mainFunction · 0.85

Calls 6

add_batchMethod · 0.80
delMethod · 0.80
statClass · 0.70
initMethod · 0.45
compactMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected