#include "gqf.h" #include /* printf, scanf, puts, NULL */ #include #include #include #include "catch.hpp" using namespace std; TEST_CASE( "Add labels to items") { QF qf; for(uint64_t label_size=2;label_size<=5;label_size++){ uint64_t qbits=16; 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){ qf_insert(&qf,vals[insertedItems],50,false,false); // qf_add_label(&qf,vals[insertedItems],vals[insertedItems]%(maximum_count+1)); // count = qf_get_label(&qf,vals[insertedItems]); // CHECK(count == vals[insertedItems]%(maximum_count+1)); insertedItems++; loadFactor=(double)qf.metadata->noccupied_slots/(double)qf.metadata->nslots; } for(int i=0;inblocks;i++) { char* blockLabel=qf_getBlockLabel_pointer_byBlock(&qf,i); for(int j=0;j'z') newChar='a'; // cout<= 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); // count = qf_get_label(&qf,key); // CHECK(count == key%(maximum_count+1)); } while(!qfi_next(&qfi)); for(int i=0;inblocks;i++) { char* blockLabel=qf_getBlockLabel_pointer_byBlock(&qf,i); for(int j=0;j'z') newChar='a'; //cout<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); // qf_add_label(&qf,vals[insertedItems],vals[insertedItems]%(maximum_count+1)); // count = qf_get_label(&qf,vals[insertedItems]); // CHECK(count == vals[insertedItems]%(maximum_count+1)); insertedItems++; loadFactor=(double)qf.metadata->noccupied_slots/(double)qf.metadata->nslots; } // cout<= 50); } qf_ComputeItemsOrder(&qf); QFi qfi; uint64_t expectedOrder=0; qf_iterator(&qf, &qfi, 0); do { uint64_t key, value, count; qfi_get(&qfi, &key, &value, &count); count=qf_count_key(&qf, key); uint64_t order=itemOrder(&qf,key); CHECK(count >= 50); REQUIRE(order==expectedOrder); expectedOrder++; // count = qf_get_label(&qf,key); // CHECK(count == key%(maximum_count+1)); } while(!qfi_next(&qfi)); qf_destroy(&qf); } TEST_CASE( "Inserting items( repeated 50 times) and attach label block to items in cqf(90% load factor )") { QF qf; int label_size=8; 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; unordered_map labels_Map; uint64_t currLabel=0; while(loadFactor<0.9){ qf_insert(&qf,vals[insertedItems],50,false,false); insertedItems++; loadFactor=(double)qf.metadata->noccupied_slots/(double)qf.metadata->nslots; } // cout<= 50); char* label; bool flag=qf_getBlockLabel_pointer_byItem(&qf,key,label); REQUIRE(flag==true); uint64_t block_index = qfi.current/64; CHECK(labels_Map[block_index]==*((uint64_t*)label)); // count = qf_get_label(&qf,key); // CHECK(count == key%(maximum_count+1)); } while(!qfi_next(&qfi)); qf_destroy(&qf); } TEST_CASE( "Inserting items( repeated 50 times) and set labels in cqf(90% load factor )") { QF qf; int label_size=3; uint64_t qbits=7; 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){ qf_insert(&qf,vals[insertedItems],50,false,false); qf_add_label(&qf,vals[insertedItems],vals[insertedItems]%(maximum_count+1)); count = qf_get_label(&qf,vals[insertedItems]); CHECK(count == vals[insertedItems]%(maximum_count+1)); insertedItems++; loadFactor=(double)qf.metadata->noccupied_slots/(double)qf.metadata->nslots; for(uint64_t i=0;i= 50); count = qf_get_label(&qf,vals[i]); INFO("bug in "<= 50); count = qf_get_label(&qf,vals[i]); CHECK(count == vals[i]%(maximum_count+1)); } 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); count = qf_get_label(&qf,key); CHECK(count == key%(maximum_count+1)); } while(!qfi_next(&qfi)); qf_destroy(&qf); } TEST_CASE( "Removing labels from items(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); qf_add_label(&qf,vals[insertedItems],insertedItems%8); insertedItems++; loadFactor=(double)qf.metadata->noccupied_slots/(double)qf.metadata->nslots; } uint64_t count; for(uint64_t i=0;i= 50); } while(!qfi_next(&qfi)); qf_destroy(&qf); } TEST_CASE( "Removing items from cqf with labels(90% load factor )") { QF qf; int counter_size=2; uint64_t qbits=16; uint64_t num_hash_bits=qbits+11; 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); qf_add_label(&qf,vals[insertedItems],insertedItems%8); 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); }