<commit_before>/**
 * Copyright (c) 2015, <NAME> <<EMAIL>>
 */

#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "dict.h"

/* Jenkins Hash function
 * https://en.wikipedia.org/wiki/Jenkins_hash_function */
uint32_t
jenkins_hash(char *key, size_t len)
{
    uint32_t hash, i;

    for(hash = i = 0; i < len; ++i) {
        hash += key[i];
        hash += (hash << 10);
        hash ^= (hash >> 6);
    }

    hash += (hash << 3);
    hash ^= (hash >> 11);
    hash += (hash << 15);
    return hash;
}

static uint32_t
dict_hash(char *key, size_t len)
{
    return jenkins_hash(key, len);
}

/* Get table size idx. */
size_t
dict_table_idx(size_t idx, char *key, size_t len)
{
    assert(idx <= dict_idx_max);
    return dict_hash(key, len) % dict_table_sizes[idx];
}

/* If two key equals. */
bool
dict_key_equals(char *key1, size_t len1, char *key2, size_t len2)
{
    if (len1 == len2 && (memcmp(key1, key2, len1) == 0))
        return true;
    return false;
}

/* Create dict node. */
struct dict_node *
dict_node_new(char *key, size_t len, void *val)
{<commit_msg>Remove jenkins hash, use md5 instead<commit_after>/**
 * Copyright (c) 2015, <NAME> <<EMAIL>>
 */

#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "dict.h"

static uint32_t
dict_hash(char *key, size_t len)
{
    return hash_md5(key, len);
}

/* Get table size idx. */
size_t
dict_table_idx(size_t idx, char *key, size_t len)
{
    assert(idx <= dict_idx_max);
    return dict_hash(key, len) % dict_table_sizes[idx];
}

/* If two key equals. */
bool
dict_key_equals(char *key1, size_t len1, char *key2, size_t len2)
{
    if (len1 == len2 && (memcmp(key1, key2, len1) == 0))
        return true;
    return false;
}

/* Create dict node. */
struct dict_node *
dict_node_new(char *key, size_t len, void *val)
{
{'fraction_non_alphanumeric': 0.1623555310952119, 'fraction_numerical': 0.025866813428728673, 'mean_word_length': 3.349282296650718, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 19, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6454058', 'n_tokens_mistral': 746, 'n_tokens_neox': 716, 'n_words': 192}