摘要: hash 是用于分配值到一或多个存储里,并且为了之后快速检索.如下图,需要插入一个新的item基于hash值,必须在一定时间(当然是越快越好)告知值在哪个块中保存这个是非常慢的hash检索逻辑12345for(i = 0; i in comp.lang.c , October, 1990." in Rich * Salz's USENIX 1992 paper about INN which can be found at * . * * The magic of number 33, i.e. why it works better than many ot... 阅读全文
posted @ 2014-03-21 16:22 tree.liang 阅读(564) 评论(0) 推荐(0) 编辑
摘要: jedis 的shard使用的是MurmurHash算法(一种非加密型哈希函数),该算法已在nginx,hadoop等开源上使用.回顾String的hashcode()方法//把char型数字转换成的int型数字,因为它们的ASCII码值恰好相差48 char val[] = "111".toCharArray(); int hcode=0; for (int i = 0; i < val.length; i++) { hcode = 31 * hcode + val[i]; }例如业界最好的字符串hash是tim... 阅读全文
posted @ 2014-03-21 13:58 tree.liang 阅读(868) 评论(0) 推荐(0) 编辑