diff --git a/cxxmph/mph_bits.h b/cxxmph/mph_bits.h index 36782f2..586e42b 100644 --- a/cxxmph/mph_bits.h +++ b/cxxmph/mph_bits.h @@ -20,10 +20,6 @@ class dynamic_2bitset { dynamic_2bitset() : size_(0), fill_(false) {} dynamic_2bitset(uint32_t size, bool fill = false) : size_(size), fill_(fill), data_(ceil(size / 4.0), ones()*fill) { - if (data_.size()) fprintf(stderr, "creating %p size %d\n", &data_[0], data_.size()); - } - ~dynamic_2bitset() { - if (data_.size()) fprintf(stderr, "Deleting %p size %d\n", &data_[0], data_.size()); } const uint8_t operator[](uint32_t i) const { return get(i); } @@ -53,19 +49,13 @@ class dynamic_2bitset { uint32_t size() const { return size_; } static const uint8_t vmask[]; const std::vector& data() const { return data_; } -// private: + private: uint32_t size_; bool fill_; std::vector data_; const uint8_t ones() { return std::numeric_limits::max(); } }; -static void set_2bit_value(uint8_t *d, uint32_t i, uint8_t v) { - d[(i >> 2)] &= ((v << ((i & 3) << 1)) | dynamic_2bitset::vmask[i & 3]); -} -static uint32_t get_2bit_value(const uint8_t* d, uint32_t i) { - return (d[(i >> 2)] >> (((i & 3) << 1)) & 3); -} static uint32_t nextpoweroftwo(uint32_t k) { if (k == 0) return 1; k--; diff --git a/cxxmph/mph_index.cc b/cxxmph/mph_index.cc index e1b24a8..8b6baec 100644 --- a/cxxmph/mph_index.cc +++ b/cxxmph/mph_index.cc @@ -37,14 +37,12 @@ static uint8_t kBdzLookupIndex[] = namespace cxxmph { -const uint8_t MPHIndex::valuemask[] = { 0xfc, 0xf3, 0xcf, 0x3f}; - MPHIndex::~MPHIndex() { clear(); } void MPHIndex::clear() { - if (!deserialized_) delete [] ranktable_; + delete [] ranktable_; ranktable_ = NULL; ranktable_size_ = 0; // TODO(davi) implement me @@ -162,7 +160,7 @@ void MPHIndex::Ranking() { uint32_t size = k_ >> 2U; ranktable_size_ = static_cast( ceil(n_ / static_cast(k_))); - if (!deserialized_) delete [] ranktable_; + delete [] ranktable_; ranktable_ = NULL; uint32_t* ranktable = new uint32_t[ranktable_size_]; memset(ranktable, 0, ranktable_size_*sizeof(uint32_t)); @@ -191,11 +189,11 @@ uint32_t MPHIndex::Rank(uint32_t vertex) const { beg_idx_v = beg_idx_b << 2; // cerr << "beg_idx_v: " << beg_idx_v << endl; // cerr << "base rank: " << base_rank << endl; - cerr << "G: "; - for (unsigned int i = 0; i < n_; ++i) { - cerr << static_cast(g_[i]) << " "; - } - cerr << endl; + // cerr << "G: "; + // for (unsigned int i = 0; i < n_; ++i) { + // cerr << static_cast(g_[i]) << " "; + // } + // cerr << endl; while (beg_idx_v < vertex) { if (g_[beg_idx_v] != kUnassigned) ++base_rank; ++beg_idx_v; @@ -204,14 +202,4 @@ uint32_t MPHIndex::Rank(uint32_t vertex) const { return base_rank; } -uint32_t MPHIndex::serialize_bytes_needed() const { - return 0; -} -void MPHIndex::serialize(char* memory) const { -} - -bool MPHIndex::deserialize(const char* serialized_memory) { - return true; -} - } // namespace cxxmph diff --git a/cxxmph/mph_index.h b/cxxmph/mph_index.h index c872f6b..17ad3e5 100644 --- a/cxxmph/mph_index.h +++ b/cxxmph/mph_index.h @@ -45,8 +45,7 @@ class MPHIndex { public: MPHIndex(double c = 1.23, uint8_t b = 7) : c_(c), b_(b), m_(0), n_(0), k_(0), r_(1), - ranktable_(NULL), ranktable_size_(0), - deserialized_(false) { } + ranktable_(NULL), ranktable_size_(0) { } ~MPHIndex(); template @@ -69,13 +68,6 @@ class MPHIndex { template // must agree with Reset void hash_vector(const Key& x, uint32_t* h) const; - // Serialization for mmap usage - not tested well, ping me if you care. - // Serialized tables are not guaranteed to work across versions or different - // endianness (although they could easily be made to be). - uint32_t serialize_bytes_needed() const; - void serialize(char *memory) const; - bool deserialize(const char* serialized_memory); - private: template bool Mapping(ForwardIterator begin, ForwardIterator end, @@ -111,10 +103,6 @@ class MPHIndex { // The selected hash seed triplet for finding the edges in the minimal // perfect hash function graph. uint32_t hash_seed_[3]; - - bool deserialized_; - - static const uint8_t valuemask[]; }; // Template method needs to go in the header file. @@ -153,10 +141,8 @@ bool MPHIndex::Reset( } if (iterations == 0) return false; Assigning(edges, queue); - fprintf(stderr, "Assignment finished\n"); std::vector().swap(edges); Ranking(); - deserialized_ = false; return true; } diff --git a/cxxmph/mph_map_test.cc b/cxxmph/mph_map_test.cc index 1d489c6..dd8eb5a 100644 --- a/cxxmph/mph_map_test.cc +++ b/cxxmph/mph_map_test.cc @@ -16,7 +16,6 @@ int main(int argc, char** argv) { b.insert(make_pair(i, i)); } b.rehash(b.size()); - fprintf(stderr, "Insertion finished\n"); for (int i = 0; i < 1000000; ++i) { auto it = b.find(i % num_keys); if (it == b.end()) {