#include "pazpar2.h"
#include "reclists.h"
-#include "parameters.h"
+#include "jenkins_hash.h"
+
+struct reclist
+{
+ struct reclist_bucket **hashtable;
+ int hashtable_size;
+ int hashmask;
+
+ struct record_cluster **flatlist;
+ int flatlist_size;
+ int num_records;
+ int pointer;
+
+ NMEM nmem;
+};
static struct reclist_sortparms *qsort_sortparms = 0; /* thread pr */
l->pointer = 0;
}
-// Jenkins one-at-a-time hash (from wikipedia)
-static unsigned int hash(const unsigned char *key)
-{
- unsigned int hash = 0;
-
- while (*key)
- {
- hash += *(key++);
- hash += (hash << 10);
- hash ^= (hash >> 6);
- }
- hash += (hash << 3);
- hash ^= (hash >> 11);
- hash += (hash << 15);
- return hash;
-}
-
struct reclist *reclist_create(NMEM nmem, int numrecs)
{
int hashsize = 1;
return res;
}
+int reclist_get_num_records(struct reclist *l)
+{
+ if (l)
+ return l->num_records;
+ return 0;
+}
+
+struct record_cluster *reclist_get_cluster(struct reclist *l, int i)
+{
+ return l->flatlist[i];
+}
+
// Insert a record. Return record cluster (newly formed or pre-existing)
struct record_cluster *reclist_insert( struct reclist *l,
struct conf_service *service,
assert(merge_key);
assert(total);
- bucket = hash((unsigned char*) merge_key) & l->hashmask;
+ bucket = jenkins_hash((unsigned char*) merge_key) & l->hashmask;
for (p = &l->hashtable[bucket]; *p; p = &(*p)->next)
{