summaryrefslogtreecommitdiff
path: root/src/coucal.h
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2014-06-15 10:24:06 +0000
committerXavier Roche <xroche@users.noreply.github.com>2014-06-15 10:24:06 +0000
commit8e72bb5deb74a68e7a909d97d7d395af9c33204d (patch)
treec97a10a736718ee490b76d038e832b0b070420e2 /src/coucal.h
parent2e6a99ce09cea47a9890a30c8180b823967e9a46 (diff)
Optional 64-bit hash for really big hashtables. (disabled by default)
Diffstat (limited to 'src/coucal.h')
-rw-r--r--src/coucal.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/coucal.h b/src/coucal.h
index 56814c8..5fb03e4 100644
--- a/src/coucal.h
+++ b/src/coucal.h
@@ -52,6 +52,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* the keys (pool).
* If the string pool is being used (to store dup'ed keys), deleting is only
* O(1) average, because the pool needs to be compacted time to time.
+ * Currently the default maximum number of elements in the hashtable is
+ * 2**31 - 1 (that is, 2,147,483,648 elements), but this default can be changed
+ * by setting COUCAL_HASH_SIZE to a higher value (64 is the only higher value
+ * currently supported), and rebuilding the library.
*
* References:
*
@@ -132,9 +136,26 @@ typedef const coucal_value coucal_value_const;
typedef struct coucal_item coucal_item;
#endif
-/** Hash key (32-bit) **/
+/** Coucal primary hash size. Default is 32-bit. **/
+#ifndef COUCAL_HASH_SIZE
+#define COUCAL_HASH_SIZE 32
+#endif
+
+/** Hash integer type. **/
+#if (COUCAL_HASH_SIZE == 32)
+
+/** 32-bit hash key. **/
typedef uint32_t coucal_hashkey;
+#elif (COUCAL_HASH_SIZE == 64)
+
+/** 64-bit hash key. **/
+typedef uint64_t coucal_hashkey;
+
+#else
+#error "Unsupported COUCAL_HASH_SIZE"
+#endif
+
/** Pair of hashes **/
typedef struct coucal_hashkeys {
coucal_hashkey hash1;
@@ -262,6 +283,12 @@ COUCAL_EXTERN size_t coucal_nitems(coucal hashtable);
COUCAL_EXTERN size_t coucal_memory_size(coucal hashtable);
/**
+ * Return the library hash size compiled.
+ * The returned value MUST match COUCAL_HASH_SIZE.
+ **/
+COUCAL_EXTERN size_t coucal_hash_size(void);
+
+/**
* If 'flag' is non-zero, calls coucal_value_set_value_handler() with
* default system free() handler function, otherwise, free the value handlers.
**/