title: cmph Minimal perfect hashing
body: <p>I've spent days trying to make the library work on my system.
  The library has several algorithms which generate MPHFs.
  My understanding of minimal hash function is, that when I hash two distinct keys using the MPHF, they'll return two different ids.
  This does not seem to be the case with the 2 million keys that I've generated (integers, read as string by the algorithm). I've tried couple of algorithms that the library implements but all of them result in duplicate 'ids' for a lot of keys.</p>
  
  <p>Here is what I've written:</p>
  
  <pre><code>#include &lt;cmph.h&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;bitset&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  #include &lt;limits.h&gt;
  
  using namespace std;
  
  int main(int argc, char** argv){
  
      FILE *fp = fopen("keys.txt", "r");
      FILE *read = fopen("keys2.txt", "r");
      ofstream ids("ids2.txt");
  
      if(!fp || !read || !ids.is_open()){
          cerr&lt;&lt;"Failed to open the file\n";
          exit(1);
      }
  
      cmph_t* hash = NULL;
      // source of keys
      cmph_io_adapter_t *source = cmph_io_nlfile_adapter(fp);
      cmph_config_t *config = cmph_config_new(source);
      cmph_config_set_algo(config, CMPH_BDZ);
      hash = cmph_new(config);
      cmph_config_destroy(config);
  
      char *k = (char *)malloc(sizeof(12));
  
      while(fgets(k, INT_MAX, read) != NULL){
          string key = k;
          unsigned int id = cmph_search(hash, k, (cmph_uint32)key.length());
          ids&lt;&lt;id&lt;&lt;"\n";
      }
  
      cmph_destroy(hash);
      cmph_io_nlfile_adapter_destroy(source);
      fclose(fp);
      fclose(read);
      ids.close();
  }
  </code></pre>
  
  <p>Shouldn't the ids be unique for every distinct key if the algorithm claims to generate a minimal perfect hash function? There are 2048383 keys. For my project I would need the ids to map from 0 to 2048382, since I plan to use a minimal perfect hash function.
  I am not sure where I am going wrong with my understanding.
  Please help.</p>