MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hash_item_util.c
1 
2 
3 #include "hash_item_util.h"
4 
5 char * hash_item_get_key(const hash_item* item) {
6  char *ret = (void*)(item + 1);
7  if (item->iflag & ITEM_WITH_CAS) {
8  ret += sizeof(uint64_t);
9  }
10 
11  return ret;
12 }
13 
14 
15 char * hash_item_get_data(const hash_item* item) {
16  return ((char*) hash_item_get_key(item)) + item->nkey;
17 }
18 
19 
20 uint16_t hash_item_get_key_len(const hash_item *item) {
21  return item->nkey;
22 }
23 
24 
25 uint32_t hash_item_get_data_len(const hash_item *item) {
26  return item->nbytes;
27 }
28 
29 
30 uint64_t hash_item_get_cas(const hash_item* item)
31 {
32  if (item->iflag & ITEM_WITH_CAS) {
33  return *(uint64_t*)(item + 1);
34  }
35  return 0;
36 }
37 
38 void hash_item_set_cas(hash_item* item, uint64_t cas)
39 {
40  if (item->iflag & ITEM_WITH_CAS) {
41  *(uint64_t*)(item + 1) = cas;
42  }
43  return;
44 }
45 
46 uint64_t hash_item_get_exp(const hash_item* item)
47 {
48  return item->exptime;
49 }
50 
51 uint32_t hash_item_get_flag(const hash_item* item)
52 {
53  return htonl(item->flags);
54 }
55 
56 void hash_item_set_flag(hash_item* item, uint32_t value)
57 {
58  item->flags = ntohl(value);
59  return;
60 }
61 
62 uint64_t * hash_item_get_cas_ptr(const hash_item* item)
63 {
64  if (item->iflag & ITEM_WITH_CAS) {
65  return (uint64_t*)(item + 1);
66  }
67  return 0;
68 }
69