Less branches.
This commit is contained in:
parent
b3e2ef709d
commit
4fabbd9d25
@ -182,7 +182,7 @@ void MPHIndex::Ranking() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t MPHIndex::Rank(uint32_t vertex) const {
|
uint32_t MPHIndex::Rank(uint32_t vertex) const {
|
||||||
if (!g_.size()) return 0;
|
if (!ranktable_size_) return 0;
|
||||||
uint32_t index = vertex >> b_;
|
uint32_t index = vertex >> b_;
|
||||||
uint32_t base_rank = ranktable_[index];
|
uint32_t base_rank = ranktable_[index];
|
||||||
uint32_t beg_idx_v = index << b_;
|
uint32_t beg_idx_v = index << b_;
|
||||||
|
@ -45,7 +45,7 @@ namespace cxxmph {
|
|||||||
class MPHIndex {
|
class MPHIndex {
|
||||||
public:
|
public:
|
||||||
MPHIndex(bool square = false, double c = 1.23, uint8_t b = 7) :
|
MPHIndex(bool square = false, double c = 1.23, uint8_t b = 7) :
|
||||||
c_(c), b_(b), m_(0), n_(0), k_(0), square_(square), r_(1),
|
c_(c), b_(b), m_(0), n_(0), k_(0), square_(square), r_(1), g_(8, true),
|
||||||
ranktable_(NULL), ranktable_size_(0) { }
|
ranktable_(NULL), ranktable_size_(0) { }
|
||||||
~MPHIndex();
|
~MPHIndex();
|
||||||
|
|
||||||
@ -174,7 +174,6 @@ bool MPHIndex::Mapping(
|
|||||||
|
|
||||||
template <class SeededHashFcn, class Key>
|
template <class SeededHashFcn, class Key>
|
||||||
uint32_t MPHIndex::perfect_square(const Key& key) const {
|
uint32_t MPHIndex::perfect_square(const Key& key) const {
|
||||||
if (!g_.size()) return 0;
|
|
||||||
h128 h = SeededHashFcn().hash128(key, hash_seed_[0]);
|
h128 h = SeededHashFcn().hash128(key, hash_seed_[0]);
|
||||||
h[0] = (h[0] & (r_-1)) + nest_displacement_[0];
|
h[0] = (h[0] & (r_-1)) + nest_displacement_[0];
|
||||||
h[1] = (h[1] & (r_-1)) + nest_displacement_[1];
|
h[1] = (h[1] & (r_-1)) + nest_displacement_[1];
|
||||||
|
@ -33,10 +33,11 @@ int main(int argc, char** argv) {
|
|||||||
cerr << endl;
|
cerr << endl;
|
||||||
sort(ids.begin(), ids.end());
|
sort(ids.begin(), ids.end());
|
||||||
for (vector<int>::size_type i = 0; i < ids.size(); ++i) assert(ids[i] == static_cast<vector<int>::value_type>(i));
|
for (vector<int>::size_type i = 0; i < ids.size(); ++i) assert(ids[i] == static_cast<vector<int>::value_type>(i));
|
||||||
/*
|
|
||||||
char* serialized = new char[mph_index.serialize_bytes_needed()];
|
FlexibleMPHIndex<false, true, int64_t, seeded_hash<std::hash<int64_t>>::hash_function> square_empty;
|
||||||
mph_index.serialize(serialized);
|
auto id = square_empty.index(1);
|
||||||
SimpleMPHIndex<string> other_mph_index;
|
FlexibleMPHIndex<false, false, int64_t, seeded_hash<std::hash<int64_t>>::hash_function> unordered_empty;
|
||||||
other_mph_index.deserialize(serialized);
|
id ^= unordered_empty.index(1);
|
||||||
*/
|
FlexibleMPHIndex<true, false, int64_t, seeded_hash<std::hash<int64_t>>::hash_function> minimal_empty;
|
||||||
|
id ^= minimal_empty.index(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user