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
|
|
|
{
|
|
|
|
srand(1000);
|
|
|
|
unlink("storefile.txt");
|
|
|
|
unlink("logfile.txt");
|
|
|
|
|
|
|
|
sync();
|
|
|
|
|
2010-02-15 23:02:01 +00:00
|
|
|
logtree::init_stasis();
|
2010-02-11 20:04:42 +00:00
|
|
|
|
2010-01-23 02:13:59 +00:00
|
|
|
//data generation
|
|
|
|
// std::vector<std::string> * data_arr = new std::vector<std::string>;
|
|
|
|
std::vector<std::string> * key_arr = new std::vector<std::string>;
|
|
|
|
|
|
|
|
// preprandstr(NUM_ENTRIES, data_arr, 10*8192);
|
2010-01-26 03:37:07 +00:00
|
|
|
preprandstr(NUM_ENTRIES+200, key_arr, 100, true);
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
int xid = Tbegin();
|
|
|
|
|
|
|
|
merge_scheduler mscheduler;
|
|
|
|
logtable ltable;
|
|
|
|
|
|
|
|
int pcount = 100;
|
|
|
|
ltable.set_fixed_page_count(pcount);
|
|
|
|
|
|
|
|
recordid table_root = ltable.allocTable(xid);
|
|
|
|
|
|
|
|
Tcommit(xid);
|
|
|
|
|
|
|
|
//xid = Tbegin();
|
|
|
|
|
|
|
|
int lindex = mscheduler.addlogtable(<able);
|
|
|
|
ltable.setMergeData(mscheduler.getMergeData(lindex));
|
|
|
|
|
|
|
|
mscheduler.startlogtable(lindex);
|
|
|
|
|
|
|
|
printf("Stage 1: Writing %d keys\n", NUM_ENTRIES);
|
|
|
|
|
|
|
|
struct timeval start_tv, stop_tv, ti_st, ti_end;
|
|
|
|
double insert_time = 0;
|
|
|
|
int64_t datasize = 0;
|
|
|
|
std::vector<pageid_t> dsp;
|
|
|
|
gettimeofday(&start_tv,0);
|
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 data
|
|
|
|
std::string ditem;
|
|
|
|
getnextdata(ditem, 10*8192);
|
2010-02-10 21:49:50 +00:00
|
|
|
|
|
|
|
//prepare the tuple
|
|
|
|
datatuple *newtuple = datatuple::create((*key_arr)[i].c_str(), (*key_arr)[i].length()+1, ditem.c_str(), ditem.length()+1);
|
|
|
|
|
|
|
|
datasize += newtuple->byte_length();
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
gettimeofday(&ti_st,0);
|
|
|
|
ltable.insertTuple(newtuple);
|
|
|
|
gettimeofday(&ti_end,0);
|
|
|
|
insert_time += tv_to_double(ti_end) - tv_to_double(ti_st);
|
|
|
|
|
2010-02-10 21:49:50 +00:00
|
|
|
datatuple::freetuple(newtuple);
|
2010-01-23 02:13:59 +00:00
|
|
|
}
|
|
|
|
gettimeofday(&stop_tv,0);
|
|
|
|
printf("insert time: %6.1f\n", insert_time);
|
|
|
|
printf("insert time: %6.1f\n", (tv_to_double(stop_tv) - tv_to_double(start_tv)));
|
|
|
|
|
|
|
|
printf("\nTREE STRUCTURE\n");
|
|
|
|
//ltable.get_tree_c1()->print_tree(xid);
|
|
|
|
printf("datasize: %lld\n", datasize);
|
|
|
|
|
|
|
|
mscheduler.shutdown();
|
|
|
|
printf("merge threads finished.\n");
|
|
|
|
gettimeofday(&stop_tv,0);
|
|
|
|
printf("run time: %6.1f\n", (tv_to_double(stop_tv) - tv_to_double(start_tv)));
|
|
|
|
|
|
|
|
//Tcommit(xid);
|
|
|
|
|
2010-02-15 23:02:01 +00:00
|
|
|
logtree::deinit_stasis();
|
2010-01-23 02:13:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @test
|
|
|
|
*/
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
insertProbeIter(25000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|