2007-11-29 14:18:54 +00:00
|
|
|
/* -*- mode: C; c-basic-offset: 4 -*- */
|
2008-01-24 15:10:32 +00:00
|
|
|
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
|
2007-11-29 14:18:54 +00:00
|
|
|
|
2013-04-16 23:57:21 -04:00
|
|
|
#include "includes.h"
|
2007-11-14 17:58:38 +00:00
|
|
|
|
|
|
|
// Calculate the fingerprint for a kvpair
|
2008-07-27 22:16:49 +00:00
|
|
|
static void toku_calc_more_murmur_kvpair (struct x1764 *mm, const void *key, int keylen, const void *val, int vallen) {
|
2007-11-14 17:58:38 +00:00
|
|
|
int i;
|
2013-04-16 23:57:46 -04:00
|
|
|
i = toku_htod32(keylen);
|
2008-07-27 22:16:49 +00:00
|
|
|
x1764_add(mm, (void*)&i, 4);
|
|
|
|
x1764_add(mm, key, keylen);
|
2013-04-16 23:57:46 -04:00
|
|
|
i = toku_htod32(vallen);
|
2008-07-27 22:16:49 +00:00
|
|
|
x1764_add(mm, (void*)&i, 4);
|
|
|
|
x1764_add(mm, val, vallen);
|
2007-11-14 17:58:38 +00:00
|
|
|
}
|
|
|
|
|
2008-04-07 01:30:25 +00:00
|
|
|
#if 0
|
|
|
|
u_int32_t toku_calccrc32_kvpair (const void *key, int keylen, const void *val, int vallen) {
|
2007-11-14 17:58:38 +00:00
|
|
|
return toku_calc_more_crc32_kvpair(toku_null_crc, key, keylen, val, vallen);
|
|
|
|
}
|
|
|
|
|
2008-04-02 23:40:36 +00:00
|
|
|
u_int32_t toku_calccrc32_kvpair_struct (const struct kv_pair *kvp) {
|
|
|
|
return toku_calccrc32_kvpair(kv_pair_key_const(kvp), kv_pair_keylen(kvp),
|
|
|
|
kv_pair_val_const(kvp), kv_pair_vallen(kvp));
|
|
|
|
}
|
2008-04-07 01:30:25 +00:00
|
|
|
#endif
|
2008-04-02 23:40:36 +00:00
|
|
|
|
2008-07-27 22:16:49 +00:00
|
|
|
u_int32_t toku_calc_fingerprint_cmd (u_int32_t type, TXNID xid, const void *key, u_int32_t keylen, const void *val, u_int32_t vallen) {
|
2013-04-16 23:57:20 -04:00
|
|
|
unsigned char type_c = (unsigned char)type;
|
2013-04-16 23:57:46 -04:00
|
|
|
unsigned int a = toku_htod32(xid>>32);
|
|
|
|
unsigned int b = toku_htod32(xid&0xffffffff);
|
2008-07-27 22:16:49 +00:00
|
|
|
struct x1764 mm;
|
|
|
|
x1764_init(&mm);
|
|
|
|
x1764_add(&mm, &type_c, 1);
|
|
|
|
x1764_add(&mm, &a, 4);
|
|
|
|
x1764_add(&mm, &b, 4);
|
|
|
|
toku_calc_more_murmur_kvpair(&mm, key, keylen, val, vallen);
|
|
|
|
return x1764_finish(&mm);
|
2007-11-14 17:58:38 +00:00
|
|
|
}
|