#include "gqf.h" #include /* printf, scanf, puts, NULL */ #include #include #include #include "catch.hpp" using namespace std; TEST_CASE( "simple counting test" ) { //except first item is inserted 5 times to full test _insert1 QF qf; int counter_size=2; uint64_t qbits=5; uint64_t num_hash_bits=qbits+8; uint64_t maximum_count=(1ULL<maximum_count=10; qf_insert(&qf,100,100000,false,false); uint64_t count = qf_count_key(&qf, 100); CHECK(count==10); qf_insert(&qf,150,8,false,false); qf_insert(&qf,150,8,false,false); count = qf_count_key(&qf, 150); CHECK(count==10); } TEST_CASE( "Big count" ) { QF qf; int counter_size=4; srand (1); uint64_t qbits=5; 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; qf_insert(&qf,vals[0],1,false,false); qf_insert(&qf,vals[0],1,false,false); qf_insert(&qf,vals[0],1,false,false); qf_insert(&qf,vals[0],1,false,false); // for(uint64_t i=0;i<32;i++) // { // cout<noccupied_slots/(double)qf.metadata->nslots; } INFO("Inserted Items = "<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(&qf,vals[insertedItems],50,false,false); insertedItems++; loadFactor=(double)qf.metadata->noccupied_slots/(double)qf.metadata->nslots; } for(uint64_t i=0;i= 50); } QFi qfi; qf_iterator(&qf, &qfi, 0); do { uint64_t key, value, count; qfi_get(&qfi, &key, &value, &count); count=qf_count_key(&qf, key); CHECK(count >= 50); } while(!qfi_next(&qfi)); qf_destroy(&qf); } TEST_CASE( "Inserting items( repeated 1-1000 times) in cqf(90% load factor )" ) { QF qf; int counter_size=4; srand (1); 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(insertedItemsrange); for(uint64_t j=0;jnoccupied_slots/(double)qf.metadata->nslots; uint64_t insertedItems=0; while(insertedItems64){ cout<<"Block "<range); for(uint64_t j=0;jnoccupied_slots/(double)qf.metadata->nslots; uint64_t insertedItems=0; while(insertedItems64){ cout<<"Block "<range); for(uint64_t j=0;jnoccupied_slots/(double)qf.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]); } qf_destroy(&qf); } TEST_CASE( "Removing items from cqf(90% load factor )") { QF 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){ qf_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)); qf_destroy(&qf); }