コード例 #1
0
ファイル: dyn_gossip.c プロジェクト: DynomiteDB/dynomite
static unsigned int
dict_node_hash(const void *key)
{
    const struct gossip_node *node = key;
    if (node == NULL)
       return 0;
    return dictGenHashFunction((unsigned char*)node->dc.data, node->dc.len) +
           dictGenHashFunction((unsigned char*)node->rack.data, node->rack.len) +
           node->token.mag[0];
}
コード例 #2
0
ファイル: maps.c プロジェクト: goodwinos/pcp
static uint64_t
intHashCallBack(const void *key)
{
    const unsigned int	*i = (const unsigned int *)key;

    return dictGenHashFunction(i, sizeof(unsigned int));
}
コード例 #3
0
ファイル: dyn_gossip.c プロジェクト: DynomiteDB/dynomite
unsigned int
dict_string_hash(const void *key)
{
    const struct string *s = key;
    //return dictGenHashFunction((unsigned char*)key, dn_strlen((char*)key));
    if (s == NULL)
        return 0;
    return dictGenHashFunction(s->data, s->len);
}
コード例 #4
0
ファイル: client.c プロジェクト: cinience/saker
/* Functions managing dictionary of callbacks for pub/sub. */
static unsigned int callbackHash(const void *key) {
    robj *o = (robj *) key;

    if (o->encoding == UG_ENCODING_RAW) {
        return dictGenHashFunction(o->ptr, (int)sdslen((sds)o->ptr));
    } else {
        if (o->encoding == UG_ENCODING_INT) {
            char buf[32];
            int len;
            len = ll2string(buf, 32, (long)o->ptr);
            return dictGenHashFunction((unsigned char *)buf, len);
        } else {
            unsigned int hash;

            o = getDecodedObject(o);
            hash = dictGenHashFunction(o->ptr, (int)sdslen((sds)o->ptr));
            decrRefCount(o);
            return hash;
        }
    }
}
コード例 #5
0
ファイル: HashTable.cpp プロジェクト: wsds/chitchat
JSObject* HashTable::get(char* key, int keyLength) {

	unsigned int hash = dictGenHashFunction(key, keyLength);
	int index = hash % max_size;
	if (elements[index] != NULL) {
		HashEntry* brother = elements[index];
		do {
			if (strcmp(brother->key, key) == 0) {
				return brother->value;
			}
			brother = brother->next;
		} while (brother != NULL);
	}

	return NULL;
}
コード例 #6
0
ファイル: HashTable.cpp プロジェクト: wsds/chitchat
JSObject* HashTable::set(char* key, int keyLength, JSObject* value) {
	HashEntry* element = new HashEntry(); //get from HashEntry pool//to do

	unsigned int hash = dictGenHashFunction(key, keyLength);
	int index = hash % max_size;

	if (elements[index] != NULL) {
		HashEntry* brother = elements[index];
		do {
			if (strcmp(brother->key, key) == 0) {
				//free the old value "brother->value"
				//todo
				JSObject* oldObject = brother->value;
				brother->value = value;
				return oldObject; //replace entry
			}
			brother = brother->next;
		} while (brother != NULL);
	}

	element->key = key;
	element->value = value;
	element->hash = hash;

	if (elements[index] == NULL) {
		elements[index] = element;
	}

	else {
		int level = 1;
		HashEntry* brother = elements[index];
		while (brother->next != NULL) {
			level++;
			brother = brother->next;
		}
		brother->next = element;
		element->level = level;
	}

	this->length++;
	if (this->length > this->threshold) {
		this->resize(); //asynchronous//todo
	}

	return NULL; //new entry
}
コード例 #7
0
ファイル: HashTable.cpp プロジェクト: wsds/chitchat
JSObject* HashTable::del(char* key, int keyLength) {
	unsigned int hash = dictGenHashFunction(key, keyLength);
	int index = hash % max_size;
	if (elements[index] != NULL) {
		HashEntry** brother = elements + index;
		do {
			if (strcmp((*brother)->key, key) == 0) {
				HashEntry* old_element = *brother;
				//free the old element, put them into a HashEntry pool to reuse them.
				//todo

				(*brother) = (*brother)->next;
				return old_element->value;
			}
			brother = &((*brother)->next);
		} while ((*brother) != NULL);
	}

	return NULL;
}
コード例 #8
0
ファイル: async.c プロジェクト: daoluan/decode-redis-2.8
/* Functions managing dictionary of callbacks for pub/sub. */
static unsigned int callbackHash(const void *key) {
    return dictGenHashFunction((unsigned char*)key,sdslen((char*)key));
}
コード例 #9
0
ファイル: cache.c プロジェクト: fengidri/BearCache
unsigned int dictHash(const void *key) {
    return dictGenHashFunction((unsigned char*)key, strlen((char*)key));
}
コード例 #10
0
ファイル: dict.c プロジェクト: AMCScarface/misc
static unsigned int _dictStringCopyHTHashFunction(const void *key)
{
    return dictGenHashFunction(key, strlen(key));
}
コード例 #11
0
ファイル: test.c プロジェクト: yuandaxing/c-cassandra
//该实现中缺少一些指针的检查,所以使用之前要确保指针的正确性
unsigned int strHash(const void *key)
{
	char *str = (char *)key;
	return  dictGenHashFunction((const unsigned char *)str, 
													strlen(str));
}
コード例 #12
0
ファイル: db.c プロジェクト: josephg/sharedb
static unsigned int dict_dstr_hash(const void *key) {
  return dictGenHashFunction((unsigned char*)key, (int)dstr_len((dstr)key));
}
コード例 #13
0
ファイル: dict.c プロジェクト: imyouxia/Firewallaudit
static unsigned int hash_func(const void * key) {
	return dictGenHashFunction(key, strlen(key));
}
コード例 #14
0
ファイル: params_map.c プロジェクト: cf981378640/cosmonaut
// dict's callbacks
static unsigned int hash_cb(const void *key) {
  return dictGenHashFunction((unsigned char *)key, strlen((char *)key));
}
コード例 #15
0
ファイル: connection.c プロジェクト: fmardini/WebMux
// table from connfd to muxConn
static unsigned int intKeyHash(const void *key) {
  int t = (int)key;
  return dictGenHashFunction(&t, sizeof(t));
}
コード例 #16
0
ファイル: maps.c プロジェクト: goodwinos/pcp
static uint64_t
sdsHashCallBack(const void *key)
{
    return dictGenHashFunction((unsigned char *)key, sdslen((char *)key));
} 
コード例 #17
0
ファイル: server.c プロジェクト: wudikua/lookup
unsigned int dictLookupHashFunction(const void *key)
{
	lookupKey *lk = (lookupKey*)key;
	unsigned int ret = dictGenHashFunction(lk->name, strlen(lk->name));
	return ret ^ (lk->type);
}
コード例 #18
0
ファイル: latency.c プロジェクト: BruceZu/disque
unsigned int dictStringHash(const void *key) {
    return dictGenHashFunction(key, strlen(key));
}
コード例 #19
0
ファイル: demo5_dict.c プロジェクト: d0evi1/redis_lib
/*
 * murmurhash2.
 */
unsigned int myHash(const void *key) {
    unsigned int ret = dictGenHashFunction(key, strlen((char*)key));
    //printf("hash key = %u\n", ret);
    return ret;
}
コード例 #20
0
ファイル: vr_server.c プロジェクト: qianyunlai/vire
unsigned int
dictObjHash(const void *key) {
    const robj *o = key;
    return dictGenHashFunction(o->ptr, sdslen((sds)o->ptr));
}