<commit_before>/*
 * Copyright (c) 2013 <NAME> <<EMAIL>>
 *
 * This is available for use under the terms of the MIT license, see the
 * LICENSE file.
 *
 * This is derived from the MIT-licensed Go-language implementation,
 * 'consistent,' available here:
 *         https://github.com/stathat/consistent
 */

#include <errno.h>
#include <inttypes.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

#include "hashring.h"

#include "t_bias.h"

#define hash_ring_init(r, h, n) hash_ring_init(r, h, NULL, n)
#define hash_ring_add(r, m) hash_ring_add(r, m, malloc(8192), 8192)
#define hash_ring_remove(r, m) hash_ring_remove(r, m, malloc(8192), 8192)

static void
_hash_ring_dump(struct hash_ring *h)
{

	printf("%p -> {\n", h);
	printf("\thash_fn: %p\n", h->hr_hash_fn);
	printf("\tcount: %"PRIu32"\n", h->hr_count);
	printf("\treplicas: %"PRIu32"\n", h->hr_nreplicas);
	printf("\tring:\n");
	for (size_t i = 0; i < h->hr_ring_used; i++)
		printf("\t\t{ hash: %#"PRIx32", bin: %#"PRIx32" }\n",
		    h->hr_ring[i].kv_hash, h->hr_ring[i].kv_value);
	printf("\tring capacity: %zu\n", h->hr_ring_capacity);
}
<commit_msg>Fix tests - Allocate more memory for re-hash<commit_after>/*
 * Copyright (c) 2013 <NAME> <<EMAIL>.com>
 *
 * This is available for use under the terms of the MIT license, see the
 * LICENSE file.
 *
 * This is derived from the MIT-licensed Go-language implementation,
 * 'consistent,' available here:
 *         https://github.com/stathat/consistent
 */

#include <errno.h>
#include <inttypes.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

#include "hashring.h"

#include "t_bias.h"

#define hash_ring_init(r, h, n) hash_ring_init(r, h, NULL, n)

#define NBYTES (16*1024)

#define hash_ring_add(r, m) \
fail_if(hash_ring_add(r, m, malloc(NBYTES), NBYTES))

#define hash_ring_remove(r, m) \
fail_if(hash_ring_remove(r, m, malloc(NBYTES), NBYTES))

static void
_hash_ring_dump(struct hash_ring *h)
{

	printf("%p -> {\n", h);
	printf("\thash_fn: %p\n", h->hr_hash_fn);
	printf("\tcount: %"PRIu32"\n", h->hr_count);
	printf("\treplicas: %"PRIu32"\n", h->hr_nreplicas);
	printf("\tring:\n");
	for (size_t i = 0; i < h->hr_ring_used; i++)
		printf("\t\t{ hash: %#"PRIx32", bin: %#"PRIx32" }\n",
		    h->hr_ring[i].kv_hash, h->hr_ring[i].kv_value);
	printf("\tring capacity: %zu\n", h->hr_ring_capacity);
}

{'fraction_non_alphanumeric': 0.19109617807643847, 'fraction_numerical': 0.02015959680806384, 'mean_word_length': 4.578454332552694, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 37, 'https://': 2, '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': '4356555', 'n_tokens_mistral': 1021, 'n_tokens_neox': 980, 'n_words': 227}