MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KeyPrefix.h
1 #ifndef NDBMEMCACHE_KEYPREFIX_H
2 #define NDBMEMCACHE_KEYPREFIX_H
3 
4 #include <stdio.h>
5 
6 /***** This section defines a data structures available to C. ***/
7 /* The prefix_info_t is the compacted form of the parts of the
8  KeyPrefix that must be available to C code.
9 */
10 
11 /* The value of 13 imposes a limit of 8,192 prefixes */
12 #define KEY_PREFIX_BITS 13
13 #define MAX_KEY_PREFIXES ( 1 << KEY_PREFIX_BITS )
14 
15 /* The value of 4 imposes a limit of 16 clusters */
16 #define CLUSTER_ID_BITS 4
17 #define MAX_CLUSTERS ( 1 << CLUSTER_ID_BITS )
18 
19 typedef struct ndb_prefix_bitfield {
20  unsigned usable : 1;
21  unsigned use_ndb : 1;
22  unsigned _unused1 : 1;
23  unsigned prefix_id : KEY_PREFIX_BITS;
24 
25  unsigned do_mc_read : 1;
26  unsigned do_db_read : 1;
27  unsigned do_mc_write : 1;
28  unsigned do_db_write : 1;
29  unsigned do_mc_delete : 1;
30  unsigned do_db_delete : 1;
31  unsigned do_db_flush : 1;
32  unsigned has_cas_col : 1;
33 
34  unsigned has_flags_col : 1;
35  unsigned has_expire_col : 1;
36  unsigned has_math_col : 1;
37  unsigned cluster_id : CLUSTER_ID_BITS;
39 
40 
41 /***** This section is available to C++ only. ***/
42 #ifdef __cplusplus
43 
44 #include <sys/types.h>
45 #include <string.h>
46 #include <stdlib.h>
47 
48 #include "TableSpec.h"
49 
50 class KeyPrefix {
51 public:
52  /* public methods */
53  KeyPrefix(const char *name);
54  KeyPrefix(const KeyPrefix &);
55  ~KeyPrefix();
56  int cmp(const char *key, int nkey);
57  void dump(FILE *) const;
58 
59  /* public instance variables */
61  prefix_info_t info;
62  const char *prefix;
63  const size_t prefix_len;
64 };
65 
66 
67 /**** Inline methods for KeyPrefix ****/
68 inline int KeyPrefix::cmp(const char *key, int nkey) {
69  return strncmp(prefix, key, prefix_len);
70 };
71 
72 #endif
73 
74 #endif
75