-
Notifications
You must be signed in to change notification settings - Fork 0
/
merger_test.cpp
35 lines (28 loc) · 919 Bytes
/
merger_test.cpp
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
#define BOOST_TEST_MODULE merger
#include <boost/test/included/unit_test.hpp>
#include <filesystem>
#include <vector>
#include "database.h"
namespace fs = std::filesystem;
BOOST_AUTO_TEST_CASE( merger ) {
fs::remove_all("test");
fs::create_directory("test");
auto m1 = MemorySegment::newMemoryOnlySegment();
for(int i=0;i<100000;i++) {
m1->put("mykey"+std::to_string(i),"myvalue"+std::to_string(i));
}
auto m2 = MemorySegment::newMemoryOnlySegment();
for(int i=100000;i<200000;i++) {
m1->put("mykey"+std::to_string(i),"myvalue"+std::to_string(i));
}
Merger merger;
Deleter deleter;
auto segments = std::vector<SegmentRef>{m1,m2};
auto merged = merger.mergeSegments1(deleter,"test",segments,false);
auto itr = merged->lookup("","");
int count=0;
while(!itr->next().key.empty()) {
count++;
}
BOOST_TEST( count==200000);
}