1166.5.1
by Patrick Galbraith
Starting over with a fresh tree, moved in memcached functions. |
1 |
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (c) 2009, Patrick "CaptTofu" Galbraith, Padraig O'Sullivan
|
|
5 |
* All rights reserved.
|
|
6 |
*
|
|
7 |
* Redistribution and use in source and binary forms, with or without
|
|
8 |
* modification, are permitted provided that the following conditions are met:
|
|
9 |
*
|
|
10 |
* * Redistributions of source code must retain the above copyright notice,
|
|
11 |
* this list of conditions and the following disclaimer.
|
|
12 |
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
13 |
* this list of conditions and the following disclaimer in the documentation
|
|
14 |
* and/or other materials provided with the distribution.
|
|
15 |
* * Neither the name of Patrick Galbraith nor the names of its contributors
|
|
16 |
* may be used to endorse or promote products derived from this software
|
|
17 |
* without specific prior written permission.
|
|
18 |
*
|
|
19 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20 |
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
22 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
23 |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
24 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
25 |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
26 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
27 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
28 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
29 |
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
30 |
*/
|
|
31 |
||
1166.6.2
by Monty Taylor
Fixed merge-related errors, including libmemcached detection and header issues caught by cpplint. |
32 |
#ifndef PLUGIN_MEMCACHED_FUNCTIONS_MEMC_BEHAVIOR_SET_H
|
33 |
#define PLUGIN_MEMCACHED_FUNCTIONS_MEMC_BEHAVIOR_SET_H
|
|
1166.5.1
by Patrick Galbraith
Starting over with a fresh tree, moved in memcached functions. |
34 |
|
35 |
#include <drizzled/item/func.h> |
|
36 |
||
37 |
#include <libmemcached/memcached.h> |
|
38 |
||
39 |
#include <map> |
|
40 |
#include <string> |
|
41 |
||
42 |
/* implements memc_behavior_set */
|
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
43 |
class MemcachedBehaviorSet : public drizzled::Item_str_func |
1166.5.1
by Patrick Galbraith
Starting over with a fresh tree, moved in memcached functions. |
44 |
{
|
45 |
public: |
|
46 |
MemcachedBehaviorSet() |
|
47 |
:
|
|
48 |
Item_str_func(), |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
49 |
failure_buff("0", &drizzled::my_charset_bin), |
50 |
success_buff("1", &drizzled::my_charset_bin), |
|
1166.5.1
by Patrick Galbraith
Starting over with a fresh tree, moved in memcached functions. |
51 |
behavior_map(), |
52 |
dist_settings_map(), |
|
53 |
hash_settings_map(), |
|
54 |
ketama_hash_settings_map() |
|
55 |
{
|
|
56 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
57 |
("MEMCACHED_BEHAVIOR_SUPPORT_CAS", MEMCACHED_BEHAVIOR_SUPPORT_CAS)); |
|
58 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
59 |
("MEMCACHED_BEHAVIOR_NO_BLOCK", MEMCACHED_BEHAVIOR_NO_BLOCK)); |
|
60 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
61 |
("MEMCACHED_BEHAVIOR_TCP_NODELAY", MEMCACHED_BEHAVIOR_TCP_NODELAY)); |
|
62 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
63 |
("MEMCACHED_BEHAVIOR_HASH", MEMCACHED_BEHAVIOR_HASH)); |
|
64 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
65 |
("MEMCACHED_BEHAVIOR_CACHE_LOOKUPS", MEMCACHED_BEHAVIOR_CACHE_LOOKUPS)); |
|
66 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
67 |
("MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE", MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE)); |
|
68 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
69 |
("MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE", MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE)); |
|
70 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
71 |
("MEMCACHED_BEHAVIOR_BUFFER_REQUESTS", MEMCACHED_BEHAVIOR_BUFFER_REQUESTS)); |
|
72 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
73 |
("MEMCACHED_BEHAVIOR_KETAMA", MEMCACHED_BEHAVIOR_KETAMA)); |
|
74 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
75 |
("MEMCACHED_BEHAVIOR_POLL_TIMEOUT", MEMCACHED_BEHAVIOR_POLL_TIMEOUT)); |
|
76 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
77 |
("MEMCACHED_BEHAVIOR_RETRY_TIMEOUT", MEMCACHED_BEHAVIOR_RETRY_TIMEOUT)); |
|
78 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
79 |
("MEMCACHED_BEHAVIOR_DISTRIBUTION", MEMCACHED_BEHAVIOR_DISTRIBUTION)); |
|
80 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
81 |
("MEMCACHED_BEHAVIOR_USER_DATA", MEMCACHED_BEHAVIOR_USER_DATA)); |
|
82 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
83 |
("MEMCACHED_BEHAVIOR_SORT_HOSTS", MEMCACHED_BEHAVIOR_SORT_HOSTS)); |
|
84 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
85 |
("MEMCACHED_BEHAVIOR_VERIFY_KEY", MEMCACHED_BEHAVIOR_VERIFY_KEY)); |
|
86 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
87 |
("MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT", MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT)); |
|
88 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
89 |
("MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED", MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED)); |
|
90 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
91 |
("MEMCACHED_BEHAVIOR_KETAMA_HASH", MEMCACHED_BEHAVIOR_KETAMA_HASH)); |
|
92 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
93 |
("MEMCACHED_BEHAVIOR_BINARY_PROTOCOL", MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); |
|
94 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
95 |
("MEMCACHED_BEHAVIOR_SND_TIMEOUT", MEMCACHED_BEHAVIOR_SND_TIMEOUT)); |
|
96 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
97 |
("MEMCACHED_BEHAVIOR_RCV_TIMEOUT", MEMCACHED_BEHAVIOR_RCV_TIMEOUT)); |
|
98 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
99 |
("MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT", MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT)); |
|
100 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
101 |
("MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK", MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK)); |
|
102 |
behavior_map.insert(std::pair<const std::string, memcached_behavior> |
|
103 |
("MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK", MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK)); |
|
104 |
||
105 |
dist_settings_map.insert(std::pair<const std::string, uint64_t> |
|
106 |
("MEMCACHED_DISTRIBUTION_MODULA", MEMCACHED_DISTRIBUTION_MODULA)); |
|
107 |
dist_settings_map.insert(std::pair<const std::string, uint64_t> |
|
108 |
("MEMCACHED_DISTRIBUTION_CONSISTENT", MEMCACHED_DISTRIBUTION_CONSISTENT)); |
|
109 |
dist_settings_map.insert(std::pair<const std::string, uint64_t> |
|
110 |
("MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA", MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA)); |
|
111 |
||
112 |
hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
113 |
("MEMCACHED_HASH_DEFAULT", MEMCACHED_HASH_DEFAULT)); |
|
114 |
hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
115 |
("MEMCACHED_HASH_MD5", MEMCACHED_HASH_MD5)); |
|
116 |
hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
117 |
("MEMCACHED_HASH_CRC", MEMCACHED_HASH_CRC)); |
|
118 |
hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
119 |
("MEMCACHED_HASH_FNV1_64", MEMCACHED_HASH_FNV1_64)); |
|
120 |
hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
121 |
("MEMCACHED_HASH_FNV1A_64", MEMCACHED_HASH_FNV1A_64)); |
|
122 |
hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
123 |
("MEMCACHED_HASH_FNV1_32", MEMCACHED_HASH_FNV1_32)); |
|
124 |
hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
125 |
("MEMCACHED_HASH_FNV1A_32", MEMCACHED_HASH_FNV1A_32)); |
|
126 |
hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
127 |
("MEMCACHED_HASH_JENKINS", MEMCACHED_HASH_JENKINS)); |
|
128 |
hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
129 |
("MEMCACHED_HASH_HSIEH", MEMCACHED_HASH_HSIEH)); |
|
130 |
hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
131 |
("MEMCACHED_HASH_MURMUR", MEMCACHED_HASH_MURMUR)); |
|
132 |
||
133 |
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
134 |
("MEMCACHED_HASH_DEFAULT", MEMCACHED_HASH_DEFAULT)); |
|
135 |
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
136 |
("MEMCACHED_HASH_MD5", MEMCACHED_HASH_MD5)); |
|
137 |
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
138 |
("MEMCACHED_HASH_CRC", MEMCACHED_HASH_CRC)); |
|
139 |
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
140 |
("MEMCACHED_HASH_FNV1_64", MEMCACHED_HASH_FNV1_64)); |
|
141 |
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
142 |
("MEMCACHED_HASH_FNV1A_64", MEMCACHED_HASH_FNV1A_64)); |
|
143 |
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
144 |
("MEMCACHED_HASH_FNV1_32", MEMCACHED_HASH_FNV1_32)); |
|
145 |
ketama_hash_settings_map.insert(std::pair<const std::string, uint64_t> |
|
146 |
("MEMCACHED_HASH_FNV1A_32", MEMCACHED_HASH_FNV1A_32)); |
|
147 |
}
|
|
148 |
||
149 |
const char *func_name() const |
|
150 |
{
|
|
151 |
return "memc_behavior_set"; |
|
152 |
}
|
|
153 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
154 |
drizzled::String *val_str(drizzled::String *); |
1166.5.1
by Patrick Galbraith
Starting over with a fresh tree, moved in memcached functions. |
155 |
|
156 |
void fix_length_and_dec() |
|
157 |
{
|
|
158 |
max_length= 32; |
|
159 |
}
|
|
160 |
||
161 |
private: |
|
162 |
void setFailureString(const char *error); |
|
163 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
164 |
drizzled::String failure_buff; |
165 |
drizzled::String success_buff; |
|
1166.5.1
by Patrick Galbraith
Starting over with a fresh tree, moved in memcached functions. |
166 |
|
167 |
std::map<const std::string, memcached_behavior> behavior_map; |
|
168 |
std::map<const std::string, uint64_t> dist_settings_map; |
|
169 |
std::map<const std::string, uint64_t> hash_settings_map; |
|
170 |
std::map<const std::string, uint64_t> ketama_hash_settings_map; |
|
171 |
};
|
|
172 |
||
1166.6.2
by Monty Taylor
Fixed merge-related errors, including libmemcached detection and header issues caught by cpplint. |
173 |
#endif /* PLUGIN_MEMCACHED_FUNCTIONS_MEMC_BEHAVIOR_SET_H */ |