#include "gqf.h" #include "onDiskMQF.h" #include /* printf, scanf, puts, NULL */ #include #include #include "catch.hpp" using namespace std; using namespace onDiskMQF_Namespace; const uint64_t MemSize=50; TEST_CASE( "simple counting test(onDisk)","[onDisk] ") { //except first item is inserted 5 times to full test _insert1 onDiskMQF* 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<((1ULL<insert(100,1,false,false); count = qf->count_key(100); //fixed_counter=qf_get_fixed_counter(&qf,100); INFO("Counter = "<metadata->maximum_count=10; qf->insert(100,100000,false,false); uint64_t count = qf->count_key(100); CHECK(count==10); qf->insert(150,8,false,false); qf->insert(150,8,false,false); count = qf->count_key(150); CHECK(count==10); delete qf; } // // TEST_CASE( "Big count(onDisk)","[onDisk]" ) { onDiskMQF* 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<insert(100,100000,false,false); uint64_t count = qf->count_key(100); CHECK(count==100000); delete qf; } TEST_CASE( "Inserting items( repeated 1 time) in cqf(90% load factor )(onDisk)" ,"[onDisk]") { //except first item is inserted 5 times to full test _insert1 onDiskMQF* qf; int counter_size=2; uint64_t qbits=15; uint64_t num_hash_bits=qbits+9; uint64_t maximum_count=(1ULL<metadata->range); } int loadFactor=qf->space();; uint64_t insertedItems=0; // onDiskMQF_dump(&qf); qf->insert(vals[0],1,false,false); qf->insert(vals[0],1,false,false); qf->insert(vals[0],1,false,false); qf->insert(vals[0],1,false,false); // for(uint64_t i=0;i<32;i++) // { // cout<insert(vals[insertedItems],1,false,false); //onDiskMQF_dump(&qf); count = qf->count_key(vals[insertedItems]); CHECK(count >= 1); // for(uint64_t i=0;i<32;i++) // { // cout<space(); //cout<<"loadFactor "<metadata->range); } double loadFactor=(double)qf->metadata->noccupied_slots/(double)qf->metadata->nslots; uint64_t insertedItems=0; uint64_t count; while(loadFactor<0.9){ qf->insert(vals[insertedItems],50,false,false); insertedItems++; loadFactor=(double)qf->metadata->noccupied_slots/(double)qf->metadata->nslots; } for(uint64_t i=0;icount_key(vals[i]); CHECK(count >= 50); } delete qf; // onDiskMQFIterator qfi; // onDiskMQF_iterator(&qf, &qfi, 0); // do { // uint64_t key, value, count; // qfi_get(&qfi, &key, &value, &count); // count=qf->count_key(key); // CHECK(count >= 50); // } while(!qfi_next(&qfi)); // onDiskMQF_destroy(&qf); } // // TEST_CASE( "copy (onDisk)","[onDisk][!hide]" ) { onDiskMQF* qf,*qf2; 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;jspace(); uint64_t insertedItems=0; while(insertedItemsinsert(vals[insertedItems],nRepetitions[insertedItems],false,false); //qf_dump(&qf); INFO("Load factor = "<metadata->range); for(uint64_t j=0;jspace(); uint64_t insertedItems=0; while(insertedItemsinsert(vals[insertedItems],nRepetitions[insertedItems],false,false); //qf_dump(&qf); INFO("Load factor = "<metadata->range); for(uint64_t j=0;jmetadata->noccupied_slots/(double)qf->metadata->nslots; uint64_t insertedItems=0; while(insertedItemsinsert(vals[insertedItems],nRepetitions[insertedItems],false,false); //qf_dump(&qf); INFO("Load factor = "<metadata->range); nRepetitions[i]=(rand())+1; } double loadFactor=(double)qf->metadata->noccupied_slots/(double)qf->metadata->nslots; uint64_t insertedItems=0; while(insertedItemsinsert(vals[insertedItems],nRepetitions[insertedItems],false,false); //onDiskMQF_dump(&qf); INFO("Load factor = "<= nRepetitions[i]); } delete qf; } // TEST_CASE( "Removing items from cqf(90% load factor )(onDisk)","[onDisk] ") { onDiskMQF* qf; int counter_size=2; uint64_t qbits=16; uint64_t num_hash_bits=qbits+8; uint64_t maximum_count=(1ULL<metadata->range); for(uint64_t j=0;jmetadata->noccupied_slots/(double)qf->metadata->nslots; uint64_t insertedItems=0; while(loadFactor<0.9){ qf->insert(vals[insertedItems],50,false,false); insertedItems++; loadFactor=(double)qf->metadata->noccupied_slots/(double)qf->metadata->nslots; } uint64_t count; for(uint64_t i=0;icount_key(vals[i]); if(count==100){ printf("coubn ==100\n" ); } qf->remove(vals[i],50,false,false); count = qf->count_key(vals[i]); CHECK(count ==0); } } for(uint64_t i=0;icount_key(vals[i]); if(i%2==1){ CHECK(count >= 50); } else{ if(count!=0){ INFO("ERROR "<getIterator( &qfi, 0); do { uint64_t key, value, count; qfi.get(&key, &value, &count); //count=qf->count_key(key); CHECK(count >= 50); } while(!qfi.next()); delete qf; }