<commit_before>/* $Id$ */

#ifndef _PFL_HASH2_H_
#define _PFL_HASH2_H_

#include "psc_ds/list.h"
#include "psc_ds/lockedlist.h"
#include "psc_util/atomic.h"
#include "psc_util/lock.h"

#define PSC_HASHTBL_LOCK(t)	spinlock(&(t)->pht_lock)
#define PSC_HASHTBL_ULOCK(t)	freelock(&(t)->pht_lock)

#define PSC_HTNAME_MAX 30

struct psc_hashbkt {
	struct psclist_head	  phb_listhd;
	psc_spinlock_t		  phb_lock;
	atomic_t		  phb_nitems;
};

struct psc_hashtbl {
	char			  pht_name[PSC_HTNAME_MAX];
	struct psclist_head	  pht_lentry;
	psc_spinlock_t		  pht_lock;
	int			  pht_flags;	/* hash table flags, see below */
	int			  pht_idoff;	/* offset into item to item ID */
	int			  pht_hentoff;	/* offset into item to item ID */
	int			  pht_nbuckets;
	struct psc_hashbkt	 *pht_buckets;
	int			(*pht_cmp)(const void *, const void *);
};

struct psc_hashent {
	struct psclist_head	  phe_lentry;
};

/* Table flags. */
#define PHTF_NONE	(0 << 0)	/* no table flags specified */
#define PHTF_STR	(1 << 0)	/* IDs are strings */

/* Lookup flags. */
#define PHLF_NONE	(0 << 0)	/* no lookup flags specified */
#define PHLF_DEL	(1 << 0)	/* find and remove item from table */

#define PSC_HASHTBL_FOREACH_BUCKET(b, t)				\
	for ((b) = (t)->pht_buckets;					\<commit_msg>yet more hash2.h comment tweaks<commit_after>/* $Id$ */

#ifndef _PFL_HASH2_H_
#define _PFL_HASH2_H_

#include "psc_ds/list.h"
#include "psc_ds/lockedlist.h"
#include "psc_util/atomic.h"
#include "psc_util/lock.h"

#define PSC_HASHTBL_LOCK(t)	spinlock(&(t)->pht_lock)
#define PSC_HASHTBL_ULOCK(t)	freelock(&(t)->pht_lock)

#define PSC_HTNAME_MAX 30

struct psc_hashbkt {
	struct psclist_head	  phb_listhd;
	psc_spinlock_t		  phb_lock;
	atomic_t		  phb_nitems;
};

struct psc_hashtbl {
	char			  pht_name[PSC_HTNAME_MAX];
	struct psclist_head	  pht_lentry;
	psc_spinlock_t		  pht_lock;
	int			  pht_flags;	/* hash table flags, see below */
	int			  pht_idoff;	/* offset into item to its ID field */
	int			  pht_hentoff;	/* offset to the hash table linkage */
	int			  pht_nbuckets;
	struct psc_hashbkt	 *pht_buckets;
	int			(*pht_cmp)(const void *, const void *);
};

struct psc_hashent {
	struct psclist_head	  phe_lentry;
};

/* Table flags. */
#define PHTF_NONE	(0 << 0)	/* no table flags specified */
#define PHTF_STR	(1 << 0)	/* IDs are strings */

/* Lookup flags. */
#define PHLF_NONE	(0 << 0)	/* no lookup flags specified */
#define PHLF_DEL	(1 << 0)	/* find and remove item from table */

#define PSC_HASHTBL_FOREACH_BUCKET(b, t)				\
	for ((b) = (t)->pht_buckets;					\
{'fraction_non_alphanumeric': 0.12608695652173912, 'fraction_numerical': 0.009881422924901186, 'mean_word_length': 3.820952380952381, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '5435639', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1116, 'n_words': 249}