• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MurmurHash3_x86_32函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MurmurHash3_x86_32函数的典型用法代码示例。如果您正苦于以下问题:C++ MurmurHash3_x86_32函数的具体用法?C++ MurmurHash3_x86_32怎么用?C++ MurmurHash3_x86_32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MurmurHash3_x86_32函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:boydgreenfield,项目名称:Mash,代码行数:30,代码来源:hash.cpp


示例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);
    }
}
开发者ID:Jonekee,项目名称:mongo,代码行数:32,代码来源:sync_tail.cpp


示例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;
}
开发者ID:lmb,项目名称:Spielbub,代码行数:9,代码来源:set.c


示例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");
}
开发者ID:a-nakanishi,项目名称:hash,代码行数:56,代码来源:Operation.c


示例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);
    }
  }
}
开发者ID:a-nakanishi,项目名称:hash,代码行数:14,代码来源:Operation.c


示例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;
 }
开发者ID:jimzshi,项目名称:libzks,代码行数:16,代码来源:hash.cpp


示例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
}
开发者ID:cfdream,项目名称:CM_testbed_code,代码行数:15,代码来源:flow.c


示例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;
}
开发者ID:carriercomm,项目名称:OlegDB,代码行数:34,代码来源:oleg.c


示例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;
}
开发者ID:cuadros,项目名称:mosesdecoder,代码行数:7,代码来源:BlockHashIndex.cpp


示例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;
}
开发者ID:hongsan,项目名称:ukibase,代码行数:34,代码来源:Database.cpp


示例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);
}
开发者ID:uraani,项目名称:StercusEngine,代码行数:92,代码来源:SGL_data.c


示例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);
  }
开发者ID:bd,项目名称:urbit,代码行数:30,代码来源:muk.c


示例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;
}
开发者ID:ChairGraveyard,项目名称:Perception,代码行数:28,代码来源:ShaderModificationRepository.cpp


示例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;
}
开发者ID:ResearchDx,项目名称:HardSearch,代码行数:7,代码来源:HashMap.cpp


示例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;
}
开发者ID:yowcow,项目名称:p6-Digest-MurmurHash3,代码行数:7,代码来源:libmurmurhash3.c


示例16: MurmurHash3_x86_32

    //128bit;
    template<> MurmurHash<128>::result_type MurmurHash<128>::salt(bool fixed)
    {
        if (fixed) {
            result_type ret;
            uint32_t* p = (uint32_t*)&ret;
            (*p++) = 0x58132134;
            (*p++) = 0x94827513;
            (*p++) = 0x16574893;
            (*p)   = 0x17932864;
            return ret;
        }

        result_type h;
        uint32_t* p0 = (uint32_t*)&h;
        std::time_t now = std::time(nullptr);
        char* nowstr = std::ctime(&now);
        MurmurHash3_x86_32((void*)nowstr, (int)std::strlen(nowstr), 0, (void*)p0);

        std::vector<zks::u8string> mac_addrs = get_mac_address();
        for (size_t i = 0; i < mac_addrs.size(); ++i) {
#ifdef _ZKS64
            MurmurHash3_x64_128((void*)mac_addrs[i].data(), (int)mac_addrs[i].size(), *p0, (void*)&h);
#else
            MurmurHash3_x86_128((void*)mac_addrs[i].data(), (int)mac_addrs[i].size(), *p0, (void*)&h);
#endif
        }
        return h;
    }
开发者ID:jimzshi,项目名称:libzks,代码行数:29,代码来源:hash.cpp


示例17: cursor_currentSystemCursor

Cursor::Cursor(const CaptureConfig &config)
{
    id cursor = cursor_currentSystemCursor();
    BridgePoint hotSpot = cursor_hotSpot(cursor);
    BridgePoint mouseLocation = event_mouseLocation();
    id cursorImage = cursor_image(cursor);
    id tiffData = cursorImage != nil ?
        image_TIFFRepresentation(cursorImage) : nil;

    if (tiffData == nil) {
        m_imageID = Cursor::blankCursor();
        m_position.rx() = 0;
        m_position.ry() = 0;
        return;
    }

    MurmurHash3_x86_32(
                data_bytes(tiffData),
                data_length(tiffData),
                0,
                &m_imageID);

    if (m_cachedImages.find(m_imageID) == m_cachedImages.end()) {
        m_cachedImages.insert(m_imageID);
        bridgeWriteCursorFile(tiffData, m_imageID);
    }

    // The NSCursor Y coordinate's origin is at the bottom of the screen.
    // Invert it.
    mouseLocation.y =
        QApplication::desktop()->screenGeometry().height() - mouseLocation.y;

    m_position.rx() = mouseLocation.x - hotSpot.x - config.captureX;
    m_position.ry() = mouseLocation.y - hotSpot.y - config.captureY;
}
开发者ID:rprichard,项目名称:x11-canvas-screencast,代码行数:35,代码来源:CursorOSX.cpp


示例18: MurmurHash3_x86_32

std::size_t InputLayoutCache::hashInputLayout(const InputLayoutKey &inputLayout)
{
    static const unsigned int seed = 0xDEADBEEF;

    std::size_t hash = 0;
    MurmurHash3_x86_32(inputLayout.begin(), inputLayout.end() - inputLayout.begin(), seed, &hash);
    return hash;
}
开发者ID:merckhung,项目名称:libui,代码行数:8,代码来源:InputLayoutCache.cpp


示例19: MurmurHash3_x86_32

std::size_t RenderStateCache::hashBlendState(const BlendStateKey &blendState)
{
    static const unsigned int seed = 0xABCDEF98;

    std::size_t hash = 0;
    MurmurHash3_x86_32(&blendState, sizeof(gl::BlendState), seed, &hash);
    return hash;
}
开发者ID:rtwf,项目名称:skia-externals,代码行数:8,代码来源:RenderStateCache.cpp


示例20: rm_fmt_json_generate_id

static guint32 rm_fmt_json_generate_id(RmFmtHandlerJSON *self, RmFile *file,
                                       const char *file_path, char *cksum) {
    guint32 hash = 0;
    hash = file->inode ^ file->dev;
    hash ^= file->actual_file_size;

    for(int i = 0; i < 8192; ++i) {
        hash ^= MurmurHash3_x86_32(file_path, strlen(file_path), i);
        hash ^= MurmurHash3_x86_32(cksum, strlen(cksum), i);

        if(!g_hash_table_contains(self->id_set, GUINT_TO_POINTER(hash))) {
            break;
        }
    }

    g_hash_table_add(self->id_set, GUINT_TO_POINTER(hash));
    return hash;
}
开发者ID:sahib,项目名称:rmlint,代码行数:18,代码来源:json.c



注:本文中的MurmurHash3_x86_32函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Mutate函数代码示例发布时间:2022-05-30
下一篇:
C++ Multiply函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap