sto-core/Transaction.hh
// tries to find an existing item with this key, returns NULL if not found
tries to find an existing item with this key, returns NULL if not found
tries to find an existing item with this key returns NULL if not found
TransItem* find_item(TObject* obj, void* xkey) const {
#if STO_TSC_PROFILE
        TimeKeeper<tc_find_item> tk;
#endif
#if CICADA_HASHTABLE
        return cht_.find(obj, xkey);
#else
#if TRANSACTION_HASHTABLE
        TXP_INCREMENT(txp_hash_find);
        unsigned hi = hash(obj, xkey);
        for (int steps = 0; steps < TRANSACTION_HASHTABLE; ++steps) {
            if (hashtable_[hi] <= hash_base_)
                return nullptr;
            unsigned tidx = hashtable_[hi] - hash_base_ - 1;
            const TransItem* ti;
            if (likely(tidx < tset_initial_capacity))
                ti = &tset0_[tidx];
            else
                ti = &tset_[tidx / tset_chunk][tidx % tset_chunk];
            if (ti->owner() == obj && ti->key_ == xkey)
                return const_cast<TransItem*>(ti);
            if (!steps) {
                TXP_INCREMENT(txp_hash_collision);
# if STO_DEBUG_HASH_COLLISIONS
                if (local_random() <= uint32_t(0xFFFFFFFF * STO_DEBUG_HASH_COLLISIONS_FRACTION)) {
                    std::ostringstream buf;
                    TransItem fake_item(obj, xkey);
                    buf << "$ STO hash collision: search " << fake_item << ", find " << *ti << '\n';
                    std::cerr << buf.str();
                }
# endif
            } else
                TXP_INCREMENT(txp_hash_collision2);
            hi = (hi + hash_step) % hash_size;
        }
#endif
	return find_item_scan(obj, xkey);
#endif
   }
TransItem * find_item ( TObject * obj , void * xkey ) const { #if STO_TSC_PROFILE TimeKeeper < tc_find_item > tk ; #endif #if CICADA_HASHTABLE return cht_ . find ( obj , xkey ) ; #else #if TRANSACTION_HASHTABLE TXP_INCREMENT ( txp_hash_find ) ; unsigned hi = hash ( obj , xkey ) ; for ( int steps = 0 ; steps < TRANSACTION_HASHTABLE ; ++ steps ) { if ( hashtable_ [ hi ] <= hash_base_ ) return nullptr ; unsigned tidx = hashtable_ [ hi ] - hash_base_ - 1 ; const TransItem * ti ; if ( likely ( tidx < tset_initial_capacity ) ) ti = & tset0_ [ tidx ] ; else ti = & tset_ [ tidx / tset_chunk ] [ tidx % tset_chunk ] ; if ( ti -> owner ( ) == obj && ti -> key_ == xkey ) return const_cast < TransItem * > ( ti ) ; if ( ! steps ) { TXP_INCREMENT ( txp_hash_collision ) ; # if STO_DEBUG_HASH_COLLISIONS if ( local_random ( ) <= uint32_t ( 0xFFFFFFFF * STO_DEBUG_HASH_COLLISIONS_FRACTION ) ) { std :: ostringstream buf ; TransItem fake_item ( obj , xkey ) ; buf << " " << fake_item << " " << * ti << ' \n ' ; std :: cerr << buf . str ( ) ; } # endif } else TXP_INCREMENT ( txp_hash_collision2 ) ; hi = ( hi + hash_step ) % hash_size ; } #endif return find_item_scan ( obj , xkey ) ; #endif }
tries to find an existing item with this key, returns NULL if not found
tries to find an existing item with this key returns NULL if not found
// std::cout << "Hash not found!" << std::endl;