Skip to content

Commit

Permalink
Merge pull request #23 from songqing/fix_type_print
Browse files Browse the repository at this point in the history
fix build warnings of uint64_t's print
  • Loading branch information
rizkg authored Mar 13, 2023
2 parents 6bb97c4 + eacddcd commit 1803c23
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 120 deletions.
9 changes: 5 additions & 4 deletions BooPHF.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
#include <string.h>
#include <memory> // for make_shared
#include <unistd.h>
#include <inttypes.h>



namespace boomphf {


inline u_int64_t printPt( pthread_t pt) {
inline uint64_t printPt( pthread_t pt) {
unsigned char *ptc = (unsigned char*)(void*)(&pt);
u_int64_t res =0;
uint64_t res =0;
for (size_t i=0; i<sizeof(pt); i++) {
res+= (unsigned)(ptc[i]);
}
Expand All @@ -39,7 +40,7 @@ namespace boomphf {
////////////////////////////////////////////////////////////////


// iterator from disk file of u_int64_t with buffered read, todo template
// iterator from disk file of uint64_t with buffered read, todo template
template <typename basetype>
class bfile_iterator : public std::iterator<std::forward_iterator_tag, basetype>{
public:
Expand Down Expand Up @@ -1023,7 +1024,7 @@ we need this 2-functors scheme because HashFunctors won't work with unordered_ma

uint64_t totalsize = totalsizeBitset + _final_hash.size()*42*8 ; // unordered map takes approx 42B per elem [personal test] (42B with uint64_t key, would be larger for other type of elem)

printf("Bitarray %12llu bits (%.2f %%) (array + ranks )\n",
printf("Bitarray %" PRIu64 " bits (%.2f %%) (array + ranks )\n",
totalsizeBitset, 100*(float)totalsizeBitset/totalsize);
printf("Last level hash %12lu bits (%.2f %%) (nb in last level hash %lu)\n",
_final_hash.size()*42*8, 100*(float)(_final_hash.size()*42*8)/totalsize,
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ A. Limasset, G. Rizk, R. Chikhi, P. Peterlongo, _Fast and Scalable Minimal Perfe
```

# Usage
Here is a simple example showing how to build and query a mphf with input keys in a std::vector<u_int64_t> . BBHash is mainly designed for de-duplicated input. Keys can be read from a disk file, or from some user-defined iterator.
Here is a simple example showing how to build and query a mphf with input keys in a std::vector<uint64_t> . BBHash is mainly designed for de-duplicated input. Keys can be read from a disk file, or from some user-defined iterator.

#include "BooPHF.h"
//tells bbhash to use included hash function working on u_int64_t input keys :
typedef boomphf::SingleHashFunctor<u_int64_t> hasher_t;
typedef boomphf::mphf< u_int64_t, hasher_t > boophf_t;
//tells bbhash to use included hash function working on uint64_t input keys :
typedef boomphf::SingleHashFunctor<uint64_t> hasher_t;
typedef boomphf::mphf< uint64_t, hasher_t > boophf_t;
std::vector<u_int64_t> input_keys;
std::vector<uint64_t> input_keys;
//
... fill the input_keys vector
//build the mphf
boophf_t * bphf = new boomphf::mphf<u_int64_t,hasher_t>(input_keys.size(),input_keys,nthreads);
boophf_t * bphf = new boomphf::mphf<uint64_t,hasher_t>(input_keys.size(),input_keys,nthreads);
//query the mphf :
uint64_t idx = bphf->lookup(input_keys[0]);
Expand Down
Loading

0 comments on commit 1803c23

Please sign in to comment.