#include "gqf.h" #include "bufferedMQF.h" #include /* printf, scanf, puts, NULL */ #include #include #include "catch.hpp" #include using namespace std; const uint64_t MemSize=50; TEST_CASE( "simple counting test(buffered)","[buffered]" ) { //except first item is inserted 5 times to full test _insert1 bufferedMQF qf; int counter_size=2; uint64_t qbits=5; uint64_t diskQbits=6; uint64_t num_hash_bits=qbits+8; uint64_t maximum_count=(1ULL<metadata->maximum_count=10; qf.disk->metadata->maximum_count=10; bufferedMQF_insert(&qf,100,100000,false,false); uint64_t count = bufferedMQF_count_key(&qf, 100); CHECK(count==10); bufferedMQF_insert(&qf,150,8,false,false); bufferedMQF_insert(&qf,150,8,false,false); count = bufferedMQF_count_key(&qf, 150); CHECK(count==10); } // TEST_CASE( "Big count(buffered)","[buffered]" ) { bufferedMQF qf; int counter_size=4; srand (1); uint64_t qbits=5; uint64_t diskQbits=6; uint64_t num_hash_bits=qbits+8; uint64_t maximum_count=(1ULL<metadata->range); } int loadFactor=bufferedMQF_space(&qf);; uint64_t insertedItems=0; bufferedMQF_insert(&qf,vals[0],1,false,false); bufferedMQF_insert(&qf,vals[0],1,false,false); bufferedMQF_insert(&qf,vals[0],1,false,false); bufferedMQF_insert(&qf,vals[0],1,false,false); // for(uint64_t i=0;i<32;i++) // { // cout<metadata->range); } int loadFactor=bufferedMQF_space(&qf);; uint64_t insertedItems=0; bufferedMQF_insert(&qf,vals[0],1,false,false); bufferedMQF_insert(&qf,vals[0],1,false,false); bufferedMQF_insert(&qf,vals[0],1,false,false); bufferedMQF_insert(&qf,vals[0],1,false,false); // for(uint64_t i=0;i<32;i++) // { // cout<70) { bufferedMQF_BatchQuery(&qf,inputBuffer); for(int j=start;j<=i;j++) { count=qf_count_key(inputBuffer,vals[j]); CHECK(count >= 1); } start=i+1; qf_reset(inputBuffer); qf_reset(outputBuffer); } count = bufferedMQF_count_key(&qf, vals[i]); } bufferedMQF_BatchQuery(&qf,inputBuffer); for(int j=start;j= 1); } // bufferedMQFIterator qfi; // bufferedMQF_iterator(&qf, &qfi, 0); // do { // uint64_t key, value, count; // qfi_get(&qfi, &key, &value, &count); // count=bufferedMQF_count_key(&qf, key); // if(key==vals[0]){ // CHECK(count >= 5); // } // else{ // CHECK(count >= 1); // } // // } while(!qfi_next(&qfi)); bufferedMQF_destroy(&qf); } // // // TEST_CASE( "Inserting items( repeated 50 times) in cqf(90% load factor )" ) { // bufferedMQF qf; // int counter_size=4; // uint64_t qbits=15; // uint64_t num_hash_bits=qbits+8; // uint64_t maximum_count=(1ULL<range); // } // double loadFactor=(double)qf.metadata->noccupied_slots/(double)qf.metadata->nslots; // uint64_t insertedItems=0; // uint64_t count; // while(loadFactor<0.9){ // bufferedMQF_insert(&qf,vals[insertedItems],50,false,false); // // insertedItems++; // loadFactor=(double)qf.metadata->noccupied_slots/(double)qf.metadata->nslots; // } // // for(uint64_t i=0;i= 50); // } // bufferedMQFIterator qfi; // bufferedMQF_iterator(&qf, &qfi, 0); // do { // uint64_t key, value, count; // qfi_get(&qfi, &key, &value, &count); // count=bufferedMQF_count_key(&qf, key); // CHECK(count >= 50); // } while(!qfi_next(&qfi)); // // bufferedMQF_destroy(&qf); // // } // // TEST_CASE( "Inserting items( repeated 1-1000 times) in cqf(90% load factor )(buffered)","[buffered]" ) { bufferedMQF qf; int counter_size=4; srand (1); uint64_t qbits=15; uint64_t diskQbits=16; uint64_t num_hash_bits=qbits+8; uint64_t maximum_count=(1ULL< gold; for(uint64_t i=0;imetadata->range); for(uint64_t j=0;jend()) { uint64_t key, value, count; qfi->get(&key, &value, &count); REQUIRE(count == gold[key]); gold.erase(key); if(key==vals[0]){ REQUIRE(count >= 5); } else{ REQUIRE(count >= 1); } qfi->next(); } REQUIRE(gold.size()==0); bufferedMQF_destroy(&qf); } TEST_CASE( "batch query" ,"[buffered]"){ bufferedMQF qf; int counter_size=4; srand (1); uint64_t qbits=15; uint64_t diskQbits=16; uint64_t num_hash_bits=qbits+8; uint64_t maximum_count=(1ULL<metadata->range); for(uint64_t j=0;j50) { bufferedMQF_BatchQuery(&qf,inputBuffer); for(int j=start;j<=i;j++) { count=qf_count_key(inputBuffer,vals[j]); INFO("value = "<= nRepetitions[j]); } start=i+1; qf_reset(inputBuffer); } } bufferedMQF_BatchQuery(&qf,inputBuffer); for(int j=start;j= nRepetitions[j]); } bufferedMQF_destroy(&qf); } // TEST_CASE( "Migrate(buffered)" ,"[buffered]" ) { bufferedMQF *qf,*qf2; qf=new bufferedMQF(); qf2=new bufferedMQF(); int counter_size=4; srand (1); uint64_t qbits=15; uint64_t diskQbits=16; uint64_t num_hash_bits=qbits+8; uint64_t maximum_count=(1ULL<disk->metadata->range); for(uint64_t j=0;jdisk->metadata->noccupied_slots/(double)qf2->disk->metadata->nslots; uint64_t insertedItems=0; while(insertedItemsrange); // // nRepetitions[i]=(rand())+1; // } // double loadFactor=(double)qf.metadata->noccupied_slots/(double)qf.metadata->nslots; // uint64_t insertedItems=0; // while(insertedItems= nRepetitions[i]); // } // // bufferedMQF_destroy(&qf); // // // } // // TEST_CASE( "Removing items from cqf(90% load factor )") { // bufferedMQF qf; // int counter_size=2; // uint64_t qbits=16; // uint64_t num_hash_bits=qbits+8; // uint64_t maximum_count=(1ULL<range); // for(uint64_t j=0;jnoccupied_slots/(double)qf.metadata->nslots; // uint64_t insertedItems=0; // while(loadFactor<0.9){ // // bufferedMQF_insert(&qf,vals[insertedItems],50,false,false); // insertedItems++; // loadFactor=(double)qf.metadata->noccupied_slots/(double)qf.metadata->nslots; // } // uint64_t count; // for(uint64_t i=0;i= 50); // } // else{ // if(count!=0){ // INFO("ERROR "<= 50); // } while(!qfi_next(&qfi)); // // bufferedMQF_destroy(&qf); // // }