File: KeyPrefix.h

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (72 lines) | stat: -rw-r--r-- 1,686 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef NDBMEMCACHE_KEYPREFIX_H
#define NDBMEMCACHE_KEYPREFIX_H

#include <stdio.h>

/***** This section defines a data structures available to C. ***/
/* The prefix_info_t is the compacted form of the parts of the
   KeyPrefix that must be available to C code.
*/

/* The value of 13 imposes a limit of 8,192 prefixes */
#define KEY_PREFIX_BITS 13
#define MAX_KEY_PREFIXES (1 << KEY_PREFIX_BITS)

/* The value of 4 imposes a limit of 16 clusters */
#define CLUSTER_ID_BITS 4
#define MAX_CLUSTERS (1 << CLUSTER_ID_BITS)

typedef struct ndb_prefix_bitfield {
  unsigned usable : 1;
  unsigned use_ndb : 1;
  unsigned _unused1 : 1;
  unsigned prefix_id : KEY_PREFIX_BITS;

  unsigned do_mc_read : 1;
  unsigned do_db_read : 1;
  unsigned do_mc_write : 1;
  unsigned do_db_write : 1;
  unsigned do_mc_delete : 1;
  unsigned do_db_delete : 1;
  unsigned do_db_flush : 1;
  unsigned has_cas_col : 1;

  unsigned has_flags_col : 1;
  unsigned has_expire_col : 1;
  unsigned has_math_col : 1;
  unsigned cluster_id : CLUSTER_ID_BITS;
} prefix_info_t;

/***** This section is available to C++ only. ***/
#ifdef __cplusplus

#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include "TableSpec.h"

class KeyPrefix {
 public:
  /* public methods */
  KeyPrefix(const char *name);
  KeyPrefix(const KeyPrefix &);
  ~KeyPrefix();
  int cmp(const char *key, int nkey);
  void dump(FILE *) const;

  /* public instance variables */
  TableSpec *table;
  prefix_info_t info;
  const char *prefix;
  const size_t prefix_len;
};

/**** Inline methods for KeyPrefix ****/
inline int KeyPrefix::cmp(const char *key, int nkey) {
  return strncmp(prefix, key, prefix_len);
};

#endif

#endif