Typedef nv::merlin::EraseIfPredict

Typedef Documentation

template<class K, class S>
using nv::merlin::EraseIfPredict = bool (*)(const K &key, S &score, const K &pattern, const S &threshold)

A customizable template function indicates which keys should be erased from the hash table by returning true.

Example for erase_if:

template <class K, class S>
struct EraseIfPredFunctor {
  __forceinline__ __device__ bool operator()(const K& key,
                                             S& score,
                                             const K& pattern,
                                             const S& threshold) {
    return ((key & 0xFFFF000000000000 == pattern) &&
            (score < threshold));
  }
};

Example for export_batch_if:

template <class K, class S>
struct ExportIfPredFunctor {
  __forceinline__ __device__ bool operator()(const K& key,
                                             S& score,
                                             const K& pattern,
                                             const S& threshold) {
    return score >= threshold;
  }
};

Note

The erase_if or export_batch_if API traverses all of the items by this function and the items that return true are removed or exported.