2010-01-23 02:13:59 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
#include "logstore.h"
|
2010-01-27 23:15:47 +00:00
|
|
|
#include "datapage.h"
|
|
|
|
#include "logiterators.h"
|
2010-01-23 02:13:59 +00:00
|
|
|
#include "merger.h"
|
|
|
|
#include <assert.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#undef begin
|
|
|
|
#undef end
|
|
|
|
|
2010-01-26 03:37:07 +00:00
|
|
|
#include "check_util.h"
|
2010-01-23 02:13:59 +00:00
|
|
|
|
2010-01-27 23:34:33 +00:00
|
|
|
void insertProbeIter(size_t NUM_ENTRIES)
|
2010-01-23 02:13:59 +00:00
|
|
|
{
|
2010-02-10 21:49:50 +00:00
|
|
|
unlink("logfile.txt");
|
|
|
|
unlink("storefile.txt");
|
2010-01-23 02:13:59 +00:00
|
|
|
//data generation
|
|
|
|
std::vector<std::string> data_arr;
|
|
|
|
std::vector<std::string> 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());
|
|
|
|
|
2010-03-09 01:42:23 +00:00
|
|
|
memTreeComponent<datatuple>::rbtree_t rbtree;
|
2010-02-10 21:49:50 +00:00
|
|
|
|
2010-01-23 02:13:59 +00:00
|
|
|
int64_t datasize = 0;
|
|
|
|
std::vector<pageid_t> dsp;
|
2010-01-27 23:34:33 +00:00
|
|
|
for(size_t i = 0; i < NUM_ENTRIES; i++)
|
2010-01-23 02:13:59 +00:00
|
|
|
{
|
|
|
|
//prepare the key
|
2010-02-10 21:49:50 +00:00
|
|
|
datatuple *newtuple = datatuple::create(key_arr[i].c_str(), key_arr[i].length()+1,data_arr[i].c_str(), data_arr[i].length()+1);
|
|
|
|
|
|
|
|
datasize += newtuple->byte_length();
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
rbtree.insert(newtuple);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\nTREE STRUCTURE\n");
|
|
|
|
//ltable.get_tree_c1()->print_tree(xid);
|
2010-01-27 23:34:33 +00:00
|
|
|
printf("datasize: %lld\n", (long long)datasize);
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
printf("Stage 2: Looking up %d keys:\n", NUM_ENTRIES);
|
|
|
|
|
|
|
|
int found_tuples=0;
|
|
|
|
for(int i=NUM_ENTRIES-1; i>=0; i--)
|
|
|
|
{
|
|
|
|
//find the key with the given tuple
|
2010-02-10 21:49:50 +00:00
|
|
|
int ri = i;
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
//prepare a search tuple
|
2010-02-10 21:49:50 +00:00
|
|
|
datatuple *search_tuple = datatuple::create(key_arr[ri].c_str(), key_arr[ri].length()+1);
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
//step 1: look in tree_c0
|
|
|
|
|
2010-03-09 01:42:23 +00:00
|
|
|
memTreeComponent<datatuple>::rbtree_t::iterator rbitr = rbtree.find(search_tuple);
|
2010-01-23 02:13:59 +00:00
|
|
|
if(rbitr != rbtree.end())
|
|
|
|
{
|
2010-02-10 21:49:50 +00:00
|
|
|
datatuple *tuple = *rbitr;
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
found_tuples++;
|
2010-02-10 21:49:50 +00:00
|
|
|
assert(tuple->keylen() == key_arr[ri].length()+1);
|
|
|
|
assert(tuple->datalen() == data_arr[ri].length()+1);
|
2010-01-23 02:13:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf("Not in scratch_tree\n");
|
|
|
|
}
|
|
|
|
|
2010-02-10 21:49:50 +00:00
|
|
|
datatuple::freetuple(search_tuple);
|
2010-01-23 02:13:59 +00:00
|
|
|
}
|
|
|
|
printf("found %d\n", found_tuples);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @test
|
|
|
|
*/
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
insertProbeIter(250);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|