Example #1
0
		void add(hash_t hash, uint32_t key) {
			uint32_t index = getBucketIndex(hash);
			auto* new_bucket = newEntry();
			new_bucket->key = key;
			new_bucket->code = code_count++;
			new_bucket->next = hash_table[index];
			hash_table[index] = new_bucket;
		}
Example #2
0
 void updateSketch(const DataTypeT& data)
 {
     uint64_t v = izenelib::util::MurmurHash64A(&data,
         sizeof(DataTypeT), seed_);
     uint32_t index = getBucketIndex(v);
     uint8_t zero_rank = rankZero(v);
     assert(zero_rank <= 64 - hll_k_);
     sketch_[index] = max(sketch_[index], zero_rank);
     level2sketches_[v % level2sketches_.size()].updateBucket(LSB(v / level2sketches_.size()), data);
 }
Example #3
0
int Tid_HashTable::getOffset(unsigned key)
{
    unsigned hashed_key;
    hashed_key = hashFunction(key);
	int index = getBucketIndex(hashed_key, globalDepth); // koitaw ta globaldepth deksia bits gia na dw se poio index tha paw
    Bucket* tempBucket = bucketArray.get(index);

	if((tempBucket->empty == false) && (tempBucket->key == key))
    {
        return tempBucket->tid_offset;
    }
    else
        return -1;
}
 PageBucket * getBucket( PageIndex index )      { return &cache[getBucketIndex(index)]; }
 PageBucket * getBucket( PageBase * page )      { return &cache[getBucketIndex(page)]; }
Example #6
0
void Tid_HashTable::insert(unsigned key, int offset)
{
    unsigned hashed_key;
    hashed_key = hashFunction(key);
    int index = getBucketIndex(hashed_key, globalDepth); // koitaw ta globalDepth deksia bits gia na dw se poio index tha paw
    Bucket* tempBucket = bucketArray.get(index);

    if(tempBucket->empty == true)
    {
        tempBucket->insert(key, offset);
    }
    else
    {
        // An to key yparxei...
        if(tempBucket->key == key)
        {

        }
        else
        {
            unsigned bhashed_key = hashFunction(tempBucket->key);  // Bucket hashed key
            while(getBucketIndex(bhashed_key, globalDepth) == getBucketIndex(hashed_key, globalDepth))
            {
                doubleTableSize();
            }
            int index2 = getBucketIndex(bhashed_key, globalDepth);
            index = getBucketIndex(hashed_key, globalDepth);

            if(tempBucket->localDepth == globalDepth -1)                        // Simple split otan uparxoun 2 pointers sto bucket
            {
                bucketArray.set(index, new Bucket(key, offset, globalDepth));
                bucketArray.get(index2)->localDepth++;
                maxLocalCounter.set(maxLocalCounter.size()-1, maxLocalCounter.get(maxLocalCounter.size()-1)+2);
            }
            else           // Split otan uparxoyn perissoteroi pointers sto bucket
            {
                unsigned local = bucketArray.get(index2)->localDepth;
                while(getBucketIndex(bhashed_key, local) == getBucketIndex(hashed_key, local))  // Oso to localDepth den einai arketo gia na diaxwristoun ta 2 kleidia, auksanetai kai diaxwrizontai ta buckets
                {
                    if(getBucketIndex(bhashed_key, local+1) != getBucketIndex(hashed_key, local+1)) // An sto localDepth+1 diaxwrizetai vges apo loop
                        break;
                    local++;
                    bucketArray.get(index2)->localDepth++;
                    Bucket* newBucket = new Bucket(local);                                        // Neo empty bucket

                    unsigned oldindex = getBucketIndex(hashed_key, local);
                    unsigned newindex;                                              // Ypologismos tou bucket index poy tha diaforopoieitai sto bit pou orizei to neo local
                    unsigned i = pow(2, local-1);
                    if((oldindex & i) == 0)
                        newindex = oldindex + i;
                    else
                        newindex = oldindex - i;
                    unsigned dist = pow(2, local);

                    for(unsigned i = newindex; i < size; i+=dist)   // Metafora deiktwn tou index sto newBucket
                    {
                        bucketArray.set(i, newBucket);
                    }
                }

                local++;
                Bucket* tempBucketnew = new Bucket(key, offset, local);
                bucketArray.set(index, tempBucketnew);
                bucketArray.get(index2)->localDepth++;
                unsigned toindex = getBucketIndex(hashed_key, local);        // Ypologismos tou bucket index me to neo local depth
                unsigned dist = pow(2, local);                               // H apostash poy tha exei to bucket index me ton epomeno deikth poy tha deiksei sto new bucket
                for(unsigned i = toindex; i < size; i+=dist)                 // Metafora deiktwn tou indexTable sto tempBucketnew
                {
                    bucketArray.set(i, tempBucketnew);
                }
                if(local == globalDepth)   // An to local iso me global tote ta 2 bucket exoun localDepth = globalDepth kai to maxLocalCounter auksanetai kata 2
                    maxLocalCounter.set(maxLocalCounter.size()-1, maxLocalCounter.get(maxLocalCounter.size()-1)+2);
            }
        }
    }
}
Example #7
0
		HashEntry* find(hash_t hash, uint32_t key) {
			auto* b = hash_table[getBucketIndex(hash)];
			for (;b != nullptr && b->key != key; b = b->next);
			return b;
		}