40 #ifndef VARIANTKEY_ESID_H 41 #define VARIANTKEY_ESID_H 46 #define ESID_MAXLEN 10 48 #define ESID_SHIFTPOS 60 49 #define ESID_CHARBIT 6 50 #define ESID_NUMPOS 27 61 return (uint64_t)(c - (
'a' -
'A' +
ESID_SHIFT));
68 return (uint8_t)(((esid >> pos) & 0x3f) +
ESID_SHIFT);
89 const char *pos = (str + size - 1);
146 uint8_t nchr = 0, npad = 0;
149 while ((c = *str++) && (size--))
163 while (((c = *str++) ==
'0') && (npad <
ESID_MAXPAD) && (size--))
168 while ((c >=
'0') && (c <=
'9') && (size--))
170 num = ((num * 10) + (c -
'0'));
173 h |= ((uint64_t)num & 0x7FFFFFF);
224 uint64_t num = (esid & 0x7FFFFFF);
227 char *ptr = (str + size);
228 size += sprintf(ptr,
"%" PRIu64, num);
255 static inline uint64_t
muxhash64(uint64_t k, uint64_t h)
257 k *= 0x87c37b91114253d5;
258 k = (k >> 33) | (k << 31);
259 k *= 0x4cf5ad432745937f;
261 h = (h >> 37) | (h << 27);
262 return ((h * 5) + 0x52dce729);
276 const uint64_t *pos = (
const uint64_t *)str;
277 const uint64_t *end = pos + (size / 8);
283 const uint8_t *tail = (
const uint8_t *)pos;
288 v ^= (uint64_t)tail[6] << (8 * 6);
291 v ^= (uint64_t)tail[5] << (8 * 5);
294 v ^= (uint64_t)tail[4] << (8 * 4);
297 v ^= (uint64_t)tail[3] << (8 * 3);
300 v ^= (uint64_t)tail[2] << (8 * 2);
303 v ^= (uint64_t)tail[1] << (8 * 1);
306 v ^= (uint64_t)tail[0];
314 h *= 0xff51afd7ed558ccd;
316 h *= 0xc4ceb9fe1a85ec53;
318 return (h | 0x8000000000000000);
321 #endif // VARIANTKEY_ESID_H #define ESID_SHIFTPOS
Encoded string ID LEN LSB position from LSB [ -—0000 00111111 22222233 33334444 44555555 66666677 77...
Definition: esid.h:48
static uint64_t encode_string_num_id(const char *str, size_t size, char sep)
Definition: esid.h:138
static size_t esid_decode_string_num_id(size_t size, uint64_t esid, char *str)
Definition: esid.h:215
static size_t decode_string_id(uint64_t esid, char *str)
Definition: esid.h:244
static uint8_t esid_decode_char(uint64_t esid, size_t pos)
Definition: esid.h:66
#define ESID_SHIFT
Number used to translate ASCII character values.
Definition: esid.h:47
static uint64_t encode_string_id(const char *str, size_t size, size_t start)
Definition: esid.h:81
static uint64_t muxhash64(uint64_t k, uint64_t h)
Definition: esid.h:255
#define ESID_MAXPAD
Max number of padding zero digits.
Definition: esid.h:51
static uint64_t hash_string_id(const char *str, size_t size)
Definition: esid.h:274
#define ESID_NUMPOS
Number of bit used to encode a number in the srting_num encoding.
Definition: esid.h:50
#define ESID_CHARBIT
Number of bit used to encode a char.
Definition: esid.h:49
#define ESID_MAXLEN
Maximum number of characters that can be encoded.
Definition: esid.h:46
static size_t esid_decode_string_id(size_t size, uint64_t esid, char *str)
Definition: esid.h:177
static uint64_t esid_encode_char(int c)
Definition: esid.h:53