本文整理汇总了C++中MurmurHash3_x86_32函数的典型用法代码示例。如果您正苦于以下问题:C++ MurmurHash3_x86_32函数的具体用法?C++ MurmurHash3_x86_32怎么用?C++ MurmurHash3_x86_32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MurmurHash3_x86_32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getHash
hash_u getHash(const char * seq, int length)
{
//for ( int i = 0; i < length; i++ ) { cout << *(seq + i); } cout << endl;
bool use64 = length > 16;
char data[use64 ? 8 : 4];
#ifdef ARCH_32
MurmurHash3_x86_32(seq, length > 16 ? 16 : length, seed, data);
if ( use64 )
{
MurmurHash3_x86_32(seq + 16, length - 16, seed, data + 4);
}
#else
MurmurHash3_x64_128(seq, length, seed, data);
#endif
hash_u hash;
if ( use64 )
{
hash.hash64 = *((hash64_t *)data);
}
else
{
hash.hash32 = *((hash32_t *)data);
}
return hash;
}
示例2: fillWriterVectors
void fillWriterVectors(const std::deque<BSONObj>& ops,
std::vector<std::vector<BSONObj>>* writerVectors) {
for (std::deque<BSONObj>::const_iterator it = ops.begin(); it != ops.end(); ++it) {
const BSONElement e = it->getField("ns");
verify(e.type() == String);
const char* ns = e.valuestr();
int len = e.valuestrsize();
uint32_t hash = 0;
MurmurHash3_x86_32(ns, len, 0, &hash);
const char* opType = it->getField("op").valuestrsafe();
if (getGlobalServiceContext()->getGlobalStorageEngine()->supportsDocLocking() &&
isCrudOpType(opType)) {
BSONElement id;
switch (opType[0]) {
case 'u':
id = it->getField("o2").Obj()["_id"];
break;
case 'd':
case 'i':
id = it->getField("o").Obj()["_id"];
break;
}
const size_t idHash = BSONElement::Hasher()(id);
MurmurHash3_x86_32(&idHash, sizeof(idHash), hash, &hash);
}
(*writerVectors)[hash % writerVectors->size()].push_back(*it);
}
}
示例3: add_to_filter
static uint32_t add_to_filter(uint32_t filter, uint16_t value)
{
uint32_t hash1, hash2;
MurmurHash3_x86_32((const void*)&value, 2, SEED1, (void*)&hash1);
MurmurHash3_x86_32((const void*)&value, 2, SEED2, (void*)&hash2);
return filter | hash1 | hash2;
}
示例4: checkInterface
void checkInterface(struct MergedBloomFilter *mbf, unsigned char *key, int *MatchVector, int *default_router, uint32_t *interface_num)
{
char tmp[NAME_PREF_BUF]="";
int key_len, slash_count = 0;
uint32_t hash1, hash2, hash3;//, Flug = 0, num = 0;
int Flug = 0, num = 0;
memset(tmp,0,NAME_PREF_BUF);
/*
printf("MatchVector : ");
for(int i=NAME_PREF_LEN-1; i>=0; i--){
printf("%d",MatchVector[i]);
if((i==24)||(i==16)||(i==8)) printf(" ");
}
printf("\n");
*/
printf("---%s---\n",key);
for(int i=NAME_PREF_LEN; i>=1; i--){
if(MatchVector[i-1]){
for(int j = 1; j <= strlen(key); j++) {
//printf("%c\n",*(key+j));
if((*(key+j)=='/')||(*(key+j)=='\0')){
slash_count++;
if(slash_count == i){
strncpy(tmp,key,j);
tmp[j] = '\0';
printf("%s : ",tmp);
key_len = strlen(tmp);
hash1 = MurmurHash3_x86_32 (tmp, key_len, 1);
hash2 = MurmurHash3_x86_32 (tmp, key_len, 2);
hash3 = MurmurHash3_x86_32 (tmp, key_len, 3);
//Flug = 0;
checkMergedBloomFilter(mbf, hash1, hash2, hash3, &Flug, &num);
//printf("tmp = %s\n",tmp);
//printf("num = %u\n",num);
//printf("Flug = %u\n",Flug);
*interface_num = num;
//if(Flug==1) break;
//if((Flug==1)||(Flug==2)) break;
if(Flug!=0) break;
}
}
}
//slash_count=0;
if(Flug==1){
*default_router = 1;
break;
}
}
}
if(Flug==2) *default_router = 2;
printf("\n");
}
示例5: makeHash
void makeHash(struct Name *list){
uint32_t len;
char *tmp;
for(int i=0; i<=NAME_PREF_LEN; i++){
struct List *node = list[i].next;
for(; node != NULL; node = node->next){
len = strlen(node->NamePrefix);
tmp = node->NamePrefix;
node->hash1 = MurmurHash3_x86_32 (tmp, len, 1);
node->hash2 = MurmurHash3_x86_32 (tmp, len, 2);
node->hash3 = MurmurHash3_x86_32 (tmp, len, 3);
}
}
}
示例6: result_type
//32bits
template<> MurmurHash<32>::result_type MurmurHash<32>::salt(bool fixed)
{
if (fixed) {
return result_type(0x58132134);
}
result_type h = 0;
std::vector<zks::u8string> mac_addrs = get_mac_address();
for (size_t i = 0; i < mac_addrs.size(); ++i) {
MurmurHash3_x86_32((void*) mac_addrs[i].data(), (int)mac_addrs[i].size(), h, (void*) &h);
}
std::time_t now = std::time(nullptr);
char* nowstr = std::ctime(&now);
MurmurHash3_x86_32((void*) nowstr, (int)std::strlen(nowstr), h, (void*) &h);
return h;
}
示例7: flow_src_hash_bin
uint32_t flow_src_hash_bin(flow_src_t* p_flow_src, uint32_t map_size) {
#ifdef FLOW_SRC
uint32_t hash;
MurmurHash3_x86_32((void*)(&(p_flow_src->srcip)), sizeof(p_flow_src->srcip), 42, &hash);
hash = hash - map_size * (hash / map_size); // A % B <=> A – B * (A / B)
//printf("srcip:%u, hash_bin:%u, map_size:%u\n", p_flow_src->srcip, hash, map_size);
return hash;
#endif
#ifdef FLOW_SRC_DST
uint32_t hash = 0;
MurmurHash3_x86_32((void*)p_flow_src, sizeof(flow_src_t), 42, &hash);
hash = hash - map_size * (hash / map_size);
#endif
}
示例8: char
ol_bucket *ol_get_bucket(const ol_database *db, const char *key, const size_t klen, char (*_key)[KEY_SIZE], size_t *_klen) {
if (db == NULL)
return NULL;
uint32_t hash;
_ol_trunc(key, klen, *_key);
*_klen = strnlen(*_key, KEY_SIZE);
if (*_klen == 0)
return NULL;
MurmurHash3_x86_32(*_key, *_klen, DEVILS_SEED, &hash);
unsigned int index = _ol_calc_idx(db->cur_ht_size, hash);
if (db->hashes[index] != NULL) {
size_t larger_key = 0;
ol_bucket *tmp_bucket;
tmp_bucket = db->hashes[index];
larger_key = tmp_bucket->klen > klen ? tmp_bucket->klen : klen;
if (strncmp(tmp_bucket->key, key, larger_key) == 0) {
return tmp_bucket;
} else if (tmp_bucket->next != NULL) {
/* Keys were not the same, traverse the linked list to see if it's
* farther down. */
do {
tmp_bucket = tmp_bucket->next;
larger_key = tmp_bucket->klen > klen ? tmp_bucket->klen : klen;
if (strncmp(tmp_bucket->key, key, larger_key) == 0)
return tmp_bucket;
} while (tmp_bucket->next != NULL);
}
}
return NULL;
}
示例9: MurmurHash3_x86_32
size_t BlockHashIndex::GetFprint(const char* key) const
{
size_t hash;
MurmurHash3_x86_32(key, std::strlen(key), 100000, &hash);
hash &= (1ul << m_fingerPrintBits) - 1;
return hash;
}
示例10: MurmurHash3_x86_32
uint64_t Database::next_type_id()
{
Engine& engine = Engine::get_instance();
uint32_t shard;
string id = SEQ_DATATYPE;
MurmurHash3_x86_32(id.c_str(), id.size(), DataType::SEQUENCE, &shard);
int size = id.size() + 32;
uint64_t msg_id = engine.next_message_id();
_enc_declare_(req, size);
_enc_put_msg_header_(req, MessageType::SEQ_TYPE, msg_id, shard);
_enc_put_string_(req, id);
_enc_update_msg_size_(req);
servernode_ptr node = ring->get_node(shard);
boost::scoped_ptr<ReplyContext> context(new ReplyContext(msg_id));
engine.save_context(context.get());
node->connection->send(_enc_data_(req), _enc_size_(req));
context->wait();
engine.release_context(context.get());
if (!context->done) return 0;
int code;
_dec_declare2_(rep, context->get_reply()->get_content_data(), context->get_reply()->get_content_size());
_dec_get_var32_(rep, code);
uint64_t val;
if (code == ErrorCode::OK)
{
_dec_get_var64_(rep, val);
}
if (!_dec_valid_(rep)) return 0;
if (code != ErrorCode::OK) return 0;
return val;
}
示例11: SDL_RWFromFile
/*U32 SGL_DataSaveShader(const char * filePath, const char* name)
{
U32 loc;
U32 hash;
SDL_RWops* rw;
U32 size;
U8* shaderData;
{
rw = SDL_RWFromFile(filePath, "rb");
if (rw == NULL)
{
SDL_Log("SGL_DataSaveShader couldn't open file in path: %s, SDL_Error:%s", filePath, SDL_GetError());
return SGL_FALSE;
}
size = SDL_RWseek(rw, 0, RW_SEEK_END);
shaderData = SDL_malloc(size);
SDL_RWseek(rw, 0, RW_SEEK_SET);
if (SDL_RWread(rw, shaderData, size, 1) != 1)
{
SDL_RWclose(rw);
SDL_Log("SGL_DataSaveShader couldn't read data from file in path: %s", filePath);
return SGL_FALSE;
}
SDL_RWclose(rw);
}
targetData.block.shaderCount++;
{
rw = SDL_RWFromFile(targetData.path, "rb+");
if (rw == NULL)
{
SDL_Log("SGL_DataSaveShader couldn't open file in path: %s, SDL_Error:%s", targetData.path, SDL_GetError());
return SGL_FALSE;
}
loc = (U32)SDL_RWseek(rw, 0, RW_SEEK_END);
if (SDL_RWwrite(rw, &size, sizeof(U32), 1) != 1)
{
SDL_RWclose(rw);
SDL_Log("SGL_DataSaveShader couldn't write to data file in path: %s", targetData.path);
return SGL_FALSE;
}
if (SDL_RWwrite(rw, shaderData, size, 1) != 1)
{
SDL_RWclose(rw);
SDL_Log("SGL_DataSaveShader couldn't write to data file in path: %s", targetData.path);
return SGL_FALSE;
}
SDL_RWseek(rw, 0, RW_SEEK_SET);
if (SDL_RWwrite(rw, &targetData.block, sizeof(SGL_DataBlock), 1) != 1)
{
SDL_RWclose(rw);
SDL_Log("SGL_DataSaveShader couldn't write to data file in path: %s, SDL_Error: %s", targetData.path, SDL_GetError());
return SGL_FALSE;
}
SDL_RWclose(rw);
}
MurmurHash3_x86_32(name, (I32)SDL_strlen(name), targetData.block.seed, &hash);
return AddNode(hash, loc);
return SGL_TRUE;
}*/
SDL_Surface * SGL_DataLoadImage(const char * imageName)
{
U32 hash;
MurmurHash3_x86_32(imageName, (I32)SDL_strlen(imageName), targetData.block.seed, &hash);
U32 loc = FindNodeLoc(hash);
if (loc == SGL_FALSE)
{
return NULL;
}
SDL_RWops* rw = SDL_RWFromFile(targetData.path, "rb");
if (rw == NULL)
{
SDL_Log("SGL_DataLoadImage couldn't open file in path: %s, SDL_Error:%s", targetData.path, SDL_GetError());
return NULL;
}
SDL_RWseek(rw, loc, RW_SEEK_SET);
SGL_FileSurface surfData;
if (SDL_RWread(rw, &surfData, sizeof(SGL_FileSurface), 1) != 1)
{
SDL_RWclose(rw);
SDL_Log("SGL_DataSaveImage couldn't read data from file in path: %s", targetData.path);
return NULL;
}
const size_t size = surfData.h * surfData.w * (surfData.depth/8);
void* pixels = SDL_malloc(size);
if (SDL_RWread(rw, pixels, size, 1) != 1)
{
SDL_RWclose(rw);
SDL_Log("SGL_DataSaveImage couldn't read data from file in path: %s", targetData.path);
return NULL;
}
return SDL_CreateRGBSurfaceFrom(pixels, surfData.w, surfData.h, surfData.depth, surfData.w*(surfData.depth / 8), surfData.Rmask, surfData.Gmask, surfData.Bmask, surfData.Amask);
}
示例12: u3qc_muk
/* functions
*/
u3_noun
u3qc_muk(u3_atom seed,
u3_atom len,
u3_atom key)
{
c3_w seed_w;
c3_w len_w;
c3_y *key_y;
c3_w out_w;
c3_assert(u3r_met(5, seed) <= 1);
c3_assert(u3r_met(0, len) <= 31);
c3_assert(u3r_met(3, key) <= len);
seed_w = u3r_word(0, seed);
len_w = u3r_word(0, len);
if (len_w > 0) { /* can't u3a_calloc 0 bytes */
key_y = u3a_calloc(sizeof(c3_y), len);
} else {
key_y = 0;
}
u3r_bytes(0, len, key_y, key);
MurmurHash3_x86_32(key_y, len, seed_w, &out_w);
u3a_free(key_y);
return u3i_words(1, &out_w);
}
示例13: MurmurHash3_x86_32
/**
* Returns true if viewport should be squished for this shader.
***/
bool ShaderModificationRepository::SquishViewportForShader(IDirect3DVertexShader9* pActualVertexShader)
{
// Hash the shader
BYTE *pData = NULL;
UINT pSizeOfData;
pActualVertexShader->GetFunction(NULL, &pSizeOfData);
pData = new BYTE[pSizeOfData];
pActualVertexShader->GetFunction(pData,&pSizeOfData);
uint32_t hash;
MurmurHash3_x86_32(pData, pSizeOfData, VIREIO_SEED, &hash);
delete[] pData;
// find hash
auto i = std::find(m_shaderViewportSquashIDs.begin(), m_shaderViewportSquashIDs.end(), hash);
// found
if (i != m_shaderViewportSquashIDs.end()) {
return true;
}
return false;
}
示例14: MurmurHash3_x86_32
int HashMap::_GetHash(std::string read_id)
{
uint32_t hash_value = 0;
MurmurHash3_x86_32(read_id.c_str(), strlen(read_id.c_str()), 0, &hash_value);
return hash_value;
}
示例15: MurmurHash3_x86_32_i
uint32_t
MurmurHash3_x86_32_i(const void * key, int len, uint32_t seed)
{
uint32_t out = 0;
MurmurHash3_x86_32(key, len, seed, &out);
return out;
}