Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read-only BFs and XXHash #83

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ext_files = ["src/mmapbitarray.c",
"src/bloomfilter.c",
"src/md5.c",
"src/xxhash.c",
"src/primetester.c",
"src/MurmurHash3.c",
]
Expand Down
23 changes: 20 additions & 3 deletions src/bloomfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ BTYPE _hash_long(uint32_t hash_seed, Key * key) {

/*
CODE TO USE SHA512..

#include <openssl/evp.h>

uint32_t _hash_char(uint32_t hash_seed, Key * key) {
BTYPE _hash_char(uint32_t hash_seed, Key * key) {
EVP_MD_CTX ctx;
unsigned char result_buffer[64];

Expand All @@ -171,9 +172,9 @@ uint32_t _hash_char(uint32_t hash_seed, Key * key) {
EVP_MD_CTX_cleanup(&ctx);
return *(uint32_t *)result_buffer;
}
*/

/* Code for MurmurHash3 */
CODE TO USE MurmurHash3

#include "MurmurHash3.h"
BTYPE _hash_char(uint32_t hash_seed, Key * key) {
BTYPE hashed_pieces[2];
Expand All @@ -183,6 +184,22 @@ BTYPE _hash_char(uint32_t hash_seed, Key * key) {
}


CODE TO USE SuperFast

#include "superfast.h"
BYPTE _hash_char(uint32_t hash_seed, Key * key) {
return SuperFastHash(key->shash, key->nhash, hash_seed);
}
*/

/* CODE TO USE xxHash */

#include "xxhash.h"
BTYPE _hash_char(uint32_t hash_seed, Key * key) {
return XXH32(key->shash, key->nhash, hash_seed);
}


#if 0
int main(int argc, char **argv)
{
Expand Down
6 changes: 5 additions & 1 deletion src/mmapbitarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,13 @@ MBArray * mbarray_Create_Mmap(BTYPE num_bits, const char * file, const char * he
}

errno = 0;

int mmap_flags = PROT_READ;
mmap_flags |= (oflag & O_RDWR) ? PROT_WRITE : 0; //add PROT_WRITE if we have write permissions

array->vector = (DTYPE *)mmap(NULL,
_mmap_size(array),
PROT_READ | PROT_WRITE,
mmap_flags,
MAP_SHARED,
array->fd,
0);
Expand Down
Loading