#include #include #include #include #include "logstore.h" #include "datapage.cpp" #include "logiterators.cpp" #include "merger.h" #include #include #include #include #include #include #undef begin #undef end #include "check_util.h" void insertProbeIter(int NUM_ENTRIES) { //data generation std::vector data_arr; std::vector key_arr; preprandstr(NUM_ENTRIES, data_arr, 10*8192, true); preprandstr(NUM_ENTRIES+200, key_arr, 100, true); std::sort(key_arr.begin(), key_arr.end(), &mycmp); removeduplicates(key_arr); if(key_arr.size() > NUM_ENTRIES) key_arr.erase(key_arr.begin()+NUM_ENTRIES, key_arr.end()); NUM_ENTRIES=key_arr.size(); if(data_arr.size() > NUM_ENTRIES) data_arr.erase(data_arr.begin()+NUM_ENTRIES, data_arr.end()); std::set rbtree; int64_t datasize = 0; std::vector dsp; for(int i = 0; i < NUM_ENTRIES; i++) { //prepare the key datatuple newtuple; uint32_t keylen = key_arr[i].length()+1; newtuple.keylen = (uint32_t*)malloc(sizeof(uint32_t)); *newtuple.keylen = keylen; newtuple.key = (datatuple::key_t) malloc(keylen); for(int j=0; jprint_tree(xid); printf("datasize: %d\n", datasize); printf("Stage 2: Looking up %d keys:\n", NUM_ENTRIES); int found_tuples=0; for(int i=NUM_ENTRIES-1; i>=0; i--) { int ri = i; //get the key uint32_t keylen = key_arr[ri].length()+1; datatuple::key_t rkey = (datatuple::key_t) malloc(keylen); for(int j=0; jkeylen) == key_arr[ri].length()+1); assert(*(ret_tuple->datalen) == data_arr[ri].length()+1); free(barr); free(ret_tuple); } else { printf("Not in scratch_tree\n"); } free(search_tuple.keylen); free(rkey); } printf("found %d\n", found_tuples); } /** @test */ int main() { insertProbeIter(250); return 0; }