vincentchu-handlersocket 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. data/ext/HandlerSocket-Plugin-for-MySQL/AUTHORS +22 -0
  2. data/ext/HandlerSocket-Plugin-for-MySQL/COPYING +30 -0
  3. data/ext/HandlerSocket-Plugin-for-MySQL/ChangeLog +12 -0
  4. data/ext/HandlerSocket-Plugin-for-MySQL/Makefile.am +87 -0
  5. data/ext/HandlerSocket-Plugin-for-MySQL/README +78 -0
  6. data/ext/HandlerSocket-Plugin-for-MySQL/autogen.sh +117 -0
  7. data/ext/HandlerSocket-Plugin-for-MySQL/client/Makefile.am +24 -0
  8. data/ext/HandlerSocket-Plugin-for-MySQL/client/hsclient.cpp +88 -0
  9. data/ext/HandlerSocket-Plugin-for-MySQL/client/hslongrun.cpp +1041 -0
  10. data/ext/HandlerSocket-Plugin-for-MySQL/client/hspool_test.pl +224 -0
  11. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest.cpp +1532 -0
  12. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest.pl +228 -0
  13. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_hs.sh +4 -0
  14. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_hs_more50.sh +4 -0
  15. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_md.sh +7 -0
  16. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_my.sh +3 -0
  17. data/ext/HandlerSocket-Plugin-for-MySQL/client/hstest_my_more50.sh +3 -0
  18. data/ext/HandlerSocket-Plugin-for-MySQL/configure.ac +144 -0
  19. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/about-handlersocket.en.txt +72 -0
  20. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/configuration-options.en.txt +99 -0
  21. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/installation.en.txt +92 -0
  22. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/perl-client.en.txt +135 -0
  23. data/ext/HandlerSocket-Plugin-for-MySQL/docs-en/protocol.en.txt +205 -0
  24. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/about-handlersocket.ja.txt +51 -0
  25. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/installation.ja.txt +88 -0
  26. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/perl-client.ja.txt +127 -0
  27. data/ext/HandlerSocket-Plugin-for-MySQL/docs-ja/protocol.ja.txt +180 -0
  28. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/COPYRIGHT.txt +27 -0
  29. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/Makefile.am +10 -0
  30. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/Makefile.plain.template +31 -0
  31. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/database.cpp +1190 -0
  32. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/database.hpp +142 -0
  33. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/handlersocket.cpp +222 -0
  34. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/handlersocket.spec.template +29 -0
  35. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.cpp +149 -0
  36. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr.hpp +58 -0
  37. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr_worker.cpp +951 -0
  38. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/hstcpsvr_worker.hpp +35 -0
  39. data/ext/HandlerSocket-Plugin-for-MySQL/handlersocket/mysql_incl.hpp +50 -0
  40. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/COPYRIGHT.txt +27 -0
  41. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/Makefile.am +12 -0
  42. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/Makefile.plain +27 -0
  43. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/allocator.hpp +64 -0
  44. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_addrinfo.hpp +49 -0
  45. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_file.hpp +64 -0
  46. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/auto_ptrcontainer.hpp +67 -0
  47. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/config.cpp +67 -0
  48. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/config.hpp +32 -0
  49. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/escape.cpp +127 -0
  50. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/escape.hpp +66 -0
  51. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/fatal.cpp +36 -0
  52. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/fatal.hpp +22 -0
  53. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/hstcpcli.cpp +441 -0
  54. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/hstcpcli.hpp +62 -0
  55. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/libhsclient.spec.template +39 -0
  56. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/mutex.hpp +51 -0
  57. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/socket.cpp +186 -0
  58. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/socket.hpp +51 -0
  59. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_buffer.hpp +118 -0
  60. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_ref.hpp +63 -0
  61. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_util.cpp +182 -0
  62. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/string_util.hpp +53 -0
  63. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/thread.hpp +84 -0
  64. data/ext/HandlerSocket-Plugin-for-MySQL/libhsclient/util.hpp +25 -0
  65. data/ext/HandlerSocket-Plugin-for-MySQL/misc/microbench-hs.log +130 -0
  66. data/ext/HandlerSocket-Plugin-for-MySQL/misc/microbench-my.log +125 -0
  67. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/COPYRIGHT.txt +27 -0
  68. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/Changes +6 -0
  69. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/HandlerSocket.xs +632 -0
  70. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/MANIFEST +8 -0
  71. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/Makefile.PL +18 -0
  72. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/Makefile.PL.installed +20 -0
  73. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/README +30 -0
  74. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/lib/Net/HandlerSocket.pm +68 -0
  75. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/lib/Net/HandlerSocket/Pool.pm +362 -0
  76. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/perl-Net-HandlerSocket.spec.template +127 -0
  77. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/ppport.h +6375 -0
  78. data/ext/HandlerSocket-Plugin-for-MySQL/perl-Net-HandlerSocket/t/Net-HandlerSocket.t +15 -0
  79. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/Makefile +79 -0
  80. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/common/binary_my.cnf +4 -0
  81. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/common/compat.sh +29 -0
  82. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/common/hstest.pm +66 -0
  83. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/Makefile +4 -0
  84. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/run.sh +27 -0
  85. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test01.expected +100 -0
  86. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test01.pl +38 -0
  87. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test02.expected +100 -0
  88. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test02.pl +49 -0
  89. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test03.expected +771 -0
  90. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test03.pl +61 -0
  91. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test04.expected +0 -0
  92. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test04.pl +63 -0
  93. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test05.expected +771 -0
  94. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test05.pl +59 -0
  95. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test06.expected +644 -0
  96. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test06.pl +90 -0
  97. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test07.expected +304 -0
  98. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test07.pl +98 -0
  99. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test08.expected +2 -0
  100. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test08.pl +48 -0
  101. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test09.expected +12 -0
  102. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test09.pl +67 -0
  103. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test10.expected +771 -0
  104. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test10.pl +93 -0
  105. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test11.expected +37 -0
  106. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test11.pl +112 -0
  107. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test12.expected +273 -0
  108. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test12.pl +134 -0
  109. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test13.expected +92 -0
  110. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test13.pl +92 -0
  111. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test14.expected +144 -0
  112. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test14.pl +80 -0
  113. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test15.expected +764 -0
  114. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test15.pl +114 -0
  115. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test16.expected +66 -0
  116. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test16.pl +88 -0
  117. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test17.expected +0 -0
  118. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test17.pl +125 -0
  119. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test18.expected +22 -0
  120. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test18.pl +63 -0
  121. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test19.expected +14894 -0
  122. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test19.pl +190 -0
  123. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test20.expected +2 -0
  124. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test20.pl +33 -0
  125. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test21.expected +11 -0
  126. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test21.pl +58 -0
  127. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test22.expected +9 -0
  128. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test22.pl +61 -0
  129. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test23.expected +101 -0
  130. data/ext/HandlerSocket-Plugin-for-MySQL/regtest/test_01_lib/test23.pl +53 -0
  131. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/README +33 -0
  132. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/extconf.rb +27 -0
  133. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/handlersocket.cpp +437 -0
  134. data/ext/winebarrel-ruby-handlersocket-c19841e47ea2/handlersocket.h +32 -0
  135. metadata +200 -0
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/perl
2
+
3
+ # vim:sw=8:ai:ts=8
4
+
5
+ use strict;
6
+ use warnings;
7
+
8
+ use DBI;
9
+ use Net::HandlerSocket;
10
+
11
+ my %conf = ();
12
+ for my $i (@ARGV) {
13
+ my ($k, $v) = split(/=/, $i);
14
+ $conf{$k} = $v;
15
+ }
16
+
17
+ my $verbose = get_conf("verbose", 0);
18
+ my $actions_str = get_conf("actions", "hsread");
19
+ my $tablesize = get_conf("tablesize", 10000);
20
+ my $db = get_conf("db", "hstest");
21
+ my $table = get_conf("table", "hstest_table1");
22
+ my $engine = get_conf("engine", "innodb");
23
+ my $host = get_conf("host", "localhost");
24
+ my $mysqlport = get_conf("mysqlport", 3306);
25
+ my $mysqluser = get_conf("mysqluser", "root");
26
+ my $mysqlpass = get_conf("mysqlpass", "");
27
+ my $hsport = get_conf("hsport", 9999);
28
+ my $loop = get_conf("loop", 10000);
29
+ my $op = get_conf("op", "=");
30
+ my $ssps = get_conf("ssps", 0);
31
+ my $num_moreflds = get_conf("moreflds", 0);
32
+ my $moreflds_prefix = get_conf("moreflds_prefix", "column0123456789_");
33
+ my $keytype = get_conf("keytype", "varchar(32)");
34
+ my $file = get_conf("file", undef);
35
+
36
+ my $dsn = "DBI:mysql:database=;host=$host;port=$mysqlport"
37
+ . ";mysql_server_prepare=$ssps";
38
+ my $dbh = DBI->connect($dsn, $mysqluser, $mysqlpass, { RaiseError => 1 });
39
+ my $hsargs = { 'host' => $host, 'port' => $hsport };
40
+ my $cli = new Net::HandlerSocket($hsargs);
41
+
42
+ my @actions = split(/,/, $actions_str);
43
+ for my $action (@actions) {
44
+ if ($action eq "table") {
45
+ print("TABLE $db.$table\n");
46
+ $dbh->do("drop database if exists $db");
47
+ $dbh->do("create database $db");
48
+ $dbh->do("use $db");
49
+ my $moreflds = get_createtbl_moreflds_str();
50
+ $dbh->do(
51
+ "create table $table (" .
52
+ "k $keytype primary key" .
53
+ ",v varchar(32) not null" .
54
+ $moreflds .
55
+ ") character set utf8 collate utf8_bin " .
56
+ "engine = $engine");
57
+ } elsif ($action eq "insert") {
58
+ print("INSERT $db.$table tablesize=$tablesize\n");
59
+ $dbh->do("use $db");
60
+ my $moreflds = get_insert_moreflds_str();
61
+ for (my $i = 0; $i < $tablesize; $i += 100) {
62
+ my $qstr = "insert into $db.$table values";
63
+ for (my $j = 0; $j < 100; ++$j) {
64
+ if ($j != 0) {
65
+ $qstr .= ",";
66
+ }
67
+ my $k = "" . ($i + $j);
68
+ my $v = "v" . int(rand(1000)) . ($i + $j);
69
+ $qstr .= "('$k', '$v'";
70
+ for (my $j = 0; $j < $num_moreflds; ++$j) {
71
+ $qstr .= ",'$j'";
72
+ }
73
+ $qstr .= ")";
74
+ }
75
+ $dbh->do($qstr);
76
+ print "$i/$tablesize\n" if $i % 1000 == 0;
77
+ }
78
+ } elsif ($action eq "read") {
79
+ print("READ $db.$table op=$op loop=$loop\n");
80
+ $dbh->do("use $db");
81
+ my $moreflds = get_select_moreflds_str();
82
+ my $sth = $dbh->prepare(
83
+ "select k,v$moreflds from $db.$table where k = ?");
84
+ for (my $i = 0; $i < $loop; ++$i) {
85
+ my $k = "" . int(rand($tablesize));
86
+ # print "k=$k\n";
87
+ $sth->execute($k);
88
+ if ($verbose >= 10) {
89
+ print "RET:";
90
+ while (my $ref = $sth->fetchrow_arrayref()) {
91
+ my $rk = $ref->[0];
92
+ my $rv = $ref->[1];
93
+ print " $rk $rv";
94
+ }
95
+ print "\n";
96
+ }
97
+ print "$i/$loop\n" if $i % 1000 == 0;
98
+ }
99
+ } elsif ($action eq "hsinsert") {
100
+ print("HSINSERT $db.$table tablesize=$tablesize\n");
101
+ $cli->open_index(1, $db, $table, '', 'k,v');
102
+ for (my $i = 0; $i < $tablesize; ++$i) {
103
+ my $k = "" . $i;
104
+ my $v = "v" . int(rand(1000)) . $i;
105
+ my $r = $cli->execute_insert(1, [ $k, $v ]);
106
+ if ($r->[0] != 0) {
107
+ die;
108
+ }
109
+ print "$i/$tablesize\n" if $i % 1000 == 0;
110
+ }
111
+ } elsif ($action eq "hsread") {
112
+ print("HSREAD $db.$table op=$op loop=$loop\n");
113
+ my $moreflds = get_select_moreflds_str();
114
+ $cli->open_index(1, $db, $table, '', "k,v$moreflds");
115
+ for (my $i = 0; $i < $loop; ++$i) {
116
+ my $k = "" . int(rand($tablesize));
117
+ # print "k=$k\n";
118
+ my $r = $cli->execute_find(1, $op, [ $k ], 1, 0);
119
+ if ($verbose >= 10) {
120
+ my $len = scalar(@{$r});
121
+ print "LEN=$len";
122
+ for my $e (@{$r}) {
123
+ print " [$e]";
124
+ }
125
+ print "\n";
126
+ }
127
+ print "$i/$loop\n" if $i % 1000 == 0;
128
+ }
129
+ } elsif ($action eq "hsupdate") {
130
+ my $vbase = "v" . int(rand(1000));
131
+ print("HSUPDATE $db.$table op=$op loop=$loop vbase=$vbase\n");
132
+ $cli->open_index(1, $db, $table, '', 'v');
133
+ for (my $i = 0; $i < $loop; ++$i) {
134
+ my $k = "" . int(rand($tablesize));
135
+ my $v = $vbase . $i;
136
+ print "k=$k v=$v\n";
137
+ my $r = $cli->execute_update(1, $op, [ $k ], 1, 0,
138
+ [ $v ]);
139
+ if ($verbose >= 10) {
140
+ print "UP k=$k v=$v\n";
141
+ }
142
+ print "$i/$loop\n" if $i % 1000 == 0;
143
+ }
144
+ } elsif ($action eq "hsdelete") {
145
+ print("HSDELETE $db.$table op=$op loop=$loop\n");
146
+ $cli->open_index(1, $db, $table, '', '');
147
+ for (my $i = 0; $i < $loop; ++$i) {
148
+ my $k = "" . int(rand($tablesize));
149
+ print "k=$k\n";
150
+ my $r = $cli->execute_delete(1, $op, [ $k ], 1, 0);
151
+ if ($verbose >= 10) {
152
+ print "DEL k=$k\n";
153
+ }
154
+ print "$i/$loop\n" if $i % 1000 == 0;
155
+ }
156
+ } elsif ($action eq "verify") {
157
+ verify_do();
158
+ }
159
+ }
160
+
161
+ sub verify_do {
162
+ my ($fail_cnt, $ok_cnt) = (0, 0);
163
+ my $sth = $dbh->prepare("select v from $db.$table where k = ?");
164
+ use FileHandle;
165
+ my $fh = new FileHandle($file, "r");
166
+ while (my $line = <$fh>) {
167
+ chomp($line);
168
+ my @vec = split(/\t/, $line);
169
+ my $k = $vec[3];
170
+ my $v = $vec[7];
171
+ next if (!defined($k) || !defined($v));
172
+ # print "$k $v\n";
173
+ $sth->execute($k);
174
+ my $aref = $sth->fetchrow_arrayref();
175
+ if (!defined($aref)) {
176
+ print "FAILED: $k notfound\n";
177
+ ++$fail_cnt;
178
+ } else {
179
+ my $gv = $aref->[0];
180
+ if ($gv ne $v) {
181
+ print "FAILED: $k got=$gv expected=$v\n";
182
+ ++$fail_cnt;
183
+ } else {
184
+ print "OK: $k $v $gv\n" if $verbose >= 10;
185
+ ++$ok_cnt;
186
+ }
187
+ }
188
+ }
189
+ print "OK=$ok_cnt FAIL=$fail_cnt\n";
190
+ }
191
+
192
+ sub get_conf {
193
+ my ($key, $def) = @_;
194
+ my $val = $conf{$key};
195
+ if ($val) {
196
+ print "$key=$val\n";
197
+ } else {
198
+ $val = $def;
199
+ $def ||= '';
200
+ print "$key=$def(default)\n";
201
+ }
202
+ return $val;
203
+ }
204
+
205
+ sub get_createtbl_moreflds_str {
206
+ my $s = "";
207
+ for (my $j = 0; $j < $num_moreflds; ++$j) {
208
+ $s .= ",$moreflds_prefix$j varchar(30)";
209
+ }
210
+ return $s;
211
+ }
212
+
213
+ sub get_select_moreflds_str {
214
+ my $s = "";
215
+ for (my $i = 0; $i < $num_moreflds; ++$i) {
216
+ $s .= ",$moreflds_prefix$i";
217
+ }
218
+ return $s;
219
+ }
220
+
221
+ sub get_insert_moreflds_str {
222
+ my $s = "";
223
+ for (my $i = 0; $i < $num_moreflds; ++$i) {
224
+ $s .= ",?";
225
+ }
226
+ return $s;
227
+ }
228
+
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ exec ./hstest test=10 tablesize=10000 host=localhost hsport=9998 num=10000000 \
4
+ num_threads=100 timelimit=10 $@
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ exec ./hstest test=10 key_mask=9999 host=localhost port=9998 num=10000000 \
4
+ num_threads=100 timelimit=10 moreflds=50 $@
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+
3
+ ./hstest test=7 key_mask=9999 host=localhost port=11211 num=10000 \
4
+ num_threads=10 timelimit=10 op=R $@
5
+ ./hstest test=7 key_mask=9999 host=localhost port=11211 num=1000000 \
6
+ num_threads=100 timelimit=10 op=G $@
7
+
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ exec ./hstest test=9 tablesize=9999 host=localhost mysqlport=3306 num=1000000 \
3
+ num_threads=100 verbose=1 timelimit=10 $@
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ exec ./hstest test=9 key_mask=9999 host=localhost port=3306 num=1000000 \
3
+ num_threads=100 verbose=1 timelimit=10 moreflds=50 $@
@@ -0,0 +1,144 @@
1
+ # -*- Autoconf -*-
2
+ # Process this file with autoconf to produce a configure script.
3
+
4
+ #AC_PREREQ([2.63b])
5
+ AC_INIT([handlersocket-plugin], [1.0.6], [https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/issues])
6
+ AC_CONFIG_HEADERS([config.h])
7
+ AM_INIT_AUTOMAKE([-Wall -Werror foreign])
8
+ AC_CONFIG_SRCDIR([libhsclient/fatal.cpp])
9
+ AC_CONFIG_MACRO_DIR([m4])
10
+
11
+ AC_PROG_CC
12
+ AC_PROG_CXX
13
+ AC_PROG_CPP
14
+ AC_PROG_LIBTOOL
15
+
16
+ ac_mysql_debug=
17
+ AC_ARG_ENABLE(mysql-debug,
18
+ [AS_HELP_STRING([--enable-mysql-debug], [specify whether MySQL is build with DBUG_ON])],[ac_mysql_debug="$enableval"],[ac_mysql_debug=no])
19
+ AC_MSG_CHECKING([if --enable-mysql-debug is specified])
20
+ AC_MSG_RESULT($ac_mysql_debug)
21
+
22
+ AC_DEFUN([CONFIG_OPTION_MYSQL],[
23
+ AC_MSG_CHECKING([mysql source])
24
+
25
+ MYSQL_SOURCE_VERSION=
26
+ MYSQL_INC=
27
+ ac_mysql_source_dir=
28
+ AC_ARG_WITH([mysql-source],
29
+ [AS_HELP_STRING([--with-mysql-source=PATH], [MySQL source directory PATH])],
30
+ [
31
+ ac_mysql_source_dir=`cd $withval && pwd`
32
+ if test -f "$ac_mysql_source_dir/sql/handler.h" ; then
33
+ MYSQL_INC="-I$ac_mysql_source_dir/sql"
34
+ MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir/include"
35
+ MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir/regex"
36
+ MYSQL_INC="$MYSQL_INC -I$ac_mysql_source_dir"
37
+ AC_SUBST(MYSQL_INC)
38
+ if test -f "$ac_mysql_source_dir/VERSION"; then
39
+ source "$ac_mysql_source_dir/VERSION"
40
+ MYSQL_SOURCE_VERSION="$MYSQL_VERSION_MAJOR.$MYSQL_VERSION_MINOR.$MYSQL_VERSION_PATCH"
41
+ else
42
+ if test -f "$ac_mysql_source_dir/configure.in"; then
43
+ MYSQL_SOURCE_VERSION=`cat $ac_mysql_source_dir/configure.in | grep "\[[MySQL Server\]]" | sed -e "s|.*\([[0-9]]\+\.[[0-9]]\+\.[[0-9]]\+[[0-9a-zA-Z\_\-]]*\).*|\1|"`
44
+ else
45
+ AC_MSG_ERROR([invalid MySQL source directory: $ac_mysql_source_dir])
46
+ fi
47
+ fi
48
+ AC_MSG_RESULT([yes: Using $ac_mysql_source_dir, version $MYSQL_SOURCE_VERSION])
49
+ else
50
+ AC_MSG_ERROR([invalid MySQL source directory: $ac_mysql_source_dir])
51
+ fi
52
+ ],
53
+ [AC_MSG_ERROR([--with-mysql-source=PATH is required for standalone build])]
54
+ )
55
+
56
+ MYSQL_BIN_VERSION=
57
+ ac_mysql_config=
58
+ AC_ARG_WITH([mysql-bindir],
59
+ [AS_HELP_STRING([--with-mysql-bindir=PATH], [MySQL binary directory PATH. This should be the directory where mysql_config is located.])],
60
+ [
61
+ mysql_bin_dir=`cd $withval 2> /dev/null && pwd || echo ""`
62
+ ac_mysql_config="$mysql_bin_dir/mysql_config"
63
+ ],
64
+ [
65
+ AC_PATH_PROG([ac_mysql_config], [mysql_config])
66
+ ]
67
+ )
68
+
69
+ AC_MSG_CHECKING([mysql binary])
70
+ if test ! -x "$ac_mysql_config" ; then
71
+ AC_MSG_ERROR([mysql_config not found! You have to specify the directory where mysql_config resides to --with-mysql-bindir=PATH.])
72
+ fi
73
+
74
+ MYSQL_CFLAGS_ADD=`"$ac_mysql_config" --cflags`
75
+ MYSQL_CFLAGS="$MYSQL_CFLAGS $MYSQL_CFLAGS_ADD"
76
+ if test "$ac_mysql_debug" = "yes"; then
77
+ MYSQL_CFLAGS="$MYSQL_CFLAGS -DDBUG_ON -DENABLED_DEBUG_SYNC"
78
+ else
79
+ MYSQL_CFLAGS="$MYSQL_CFLAGS -DDBUG_OFF"
80
+ fi
81
+ AC_SUBST(MYSQL_CFLAGS)
82
+
83
+ MYSQL_BIN_VERSION=`"$ac_mysql_config" --version`
84
+ AC_MSG_RESULT([yes: Using $ac_mysql_config, version $MYSQL_BIN_VERSION])
85
+
86
+ MYSQL_LIB=`"$ac_mysql_config" --libs_r`
87
+ LIB_DIR=`echo $MYSQL_LIB | sed -e "s|.*-L/|/|" | sed -e "s| .*||"`
88
+ # FIXME
89
+ if test a`basename "$LIB_DIR"` = amysql ; then
90
+ MYSQL_LIB="-L`dirname $LIB_DIR` $MYSQL_LIB"
91
+ # FIXME
92
+ fi
93
+ AC_SUBST(MYSQL_LIB)
94
+
95
+ if test a$MYSQL_SOURCE_VERSION != a$MYSQL_BIN_VERSION ; then
96
+ AC_MSG_ERROR([MySQL source version does not match MySQL binary version])
97
+ fi
98
+
99
+ AC_MSG_CHECKING([mysql plugin dir])
100
+ ac_mysql_plugin_dir=
101
+ AC_ARG_WITH([mysql-plugindir],
102
+ [AS_HELP_STRING([--with-mysql-plugindir=PATH], [MySQL plugin directory where handlersocket.so to be copied])],
103
+ [
104
+ ac_mysql_plugin_dir=`cd $withval && pwd`
105
+ if test -d "$ac_mysql_plugin_dir/" ; then
106
+ PLUGIN_DIR="$ac_mysql_plugin_dir"
107
+ AC_SUBST(PLUGIN_DIR)
108
+ AC_MSG_RESULT([yes: Using $ac_mysql_plugin_dir])
109
+ else
110
+ AC_MSG_ERROR([invalid MySQL plugin directory : $ac_mysql_plugin_dir])
111
+ fi
112
+ ],
113
+ [
114
+ LIB_DIR_TMP=`"$ac_mysql_config" --plugindir`
115
+ if test ! -d "$LIB_DIR_TMP"; then
116
+ LIB_DIR_TMP=`"$ac_mysql_config" --libs_r | sed -e "s|.*-L/|/|" | sed -e "s| .*||"`/plugin
117
+ # FIXME
118
+ fi
119
+ ac_mysql_plugin_dir=$LIB_DIR_TMP
120
+ PLUGIN_DIR="$ac_mysql_plugin_dir"
121
+ AC_SUBST(PLUGIN_DIR)
122
+ AC_MSG_RESULT([--with-mysql-plugindir was not set. Using $ac_mysql_plugin_dir])
123
+ ]
124
+ )
125
+ ])
126
+
127
+ HANDLERSOCKET_SUBDIRS="libhsclient"
128
+ AC_ARG_ENABLE(handlersocket_server,
129
+ [ --enable-handlersocket-server build HandlerSocket plugin (defalut=yes)])
130
+ if test "$enable_handlersocket_server" != "no"; then
131
+ CONFIG_OPTION_MYSQL
132
+ HANDLERSOCKET_SUBDIRS="libhsclient handlersocket client"
133
+ fi
134
+ AC_SUBST(HANDLERSOCKET_SUBDIRS)
135
+
136
+ CFLAGS="$CFLAGS -Werror"
137
+ CXXFLAGS="$CXXFLAGS -Wall -g -fno-rtti -fno-exceptions -fPIC -DPIC"
138
+
139
+ AC_CONFIG_FILES([Makefile
140
+ handlersocket/Makefile
141
+ libhsclient/Makefile
142
+ client/Makefile])
143
+
144
+ AC_OUTPUT
@@ -0,0 +1,72 @@
1
+
2
+ -----------------------------------------------------------------------------
3
+ HandlerSocket plugin for MySQL
4
+
5
+ Copyright (c) 2010 DeNA Co.,Ltd.
6
+ All rights reserved.
7
+
8
+ Redistribution and use in source and binary forms, with or without
9
+ modification, are permitted provided that the following conditions are met:
10
+
11
+ * Redistributions of source code must retain the above copyright
12
+ notice, this list of conditions and the following disclaimer.
13
+ * Redistributions in binary form must reproduce the above copyright
14
+ notice, this list of conditions and the following disclaimer in the
15
+ documentation and/or other materials provided with the distribution.
16
+ * Neither the name of DeNA Co.,Ltd. nor the names of its contributors
17
+ may be used to endorse or promote products derived from this software
18
+ without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY DeNA Co.,Ltd. "AS IS" AND ANY EXPRESS OR
21
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
23
+ EVENT SHALL DeNA Co.,Ltd. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26
+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+
32
+ -----------------------------------------------------------------------------
33
+ About HandlerSocket
34
+
35
+ HandlerSocket is a NoSQL plugin for MySQL. It works as a daemon inside the
36
+ mysqld process, accept tcp connections, and execute requests from clients.
37
+ HandlerSocket does not support SQL queries. Instead, it supports simple CRUD
38
+ operations on tables.
39
+
40
+ Because of the following reasons, HandlerSocket is much faster than the
41
+ mysqld/libmysql pair in some circumstances:
42
+
43
+ - HandlerSocket manipulates data without parsing SQL, which causes less
44
+ CPU usage.
45
+ - HandlerSocket reads many requests from clients and executes their
46
+ requests in bulk, which causes less CPU and disk usage.
47
+ - HandlerSocket client/server protocol is more compact than the
48
+ mysql/libmysql pair, which causes less network usage.
49
+
50
+ The current version of HandlerSocket only works with GNU/Linux. The source
51
+ archive of HandlerSocket includes a C++ and a Perl client libraries.
52
+ Here is a list of other language bindings:
53
+
54
+ - PHP
55
+ http://openpear.org/package/Net_HandlerSocket
56
+ http://github.com/tz-lom/HSPHP
57
+ http://code.google.com/p/php-handlersocket/
58
+ - Java
59
+ http://code.google.com/p/handlersocketforjava/
60
+ - Python
61
+ https://code.launchpad.net/~songofacandy/+junk/pyhandlersocket
62
+ - Ruby
63
+ https://github.com/winebarrel/ruby-handlersocket
64
+ https://github.com/miyucy/handlersocket
65
+ - JavaScript(Node.js)
66
+ https://github.com/koichik/node-handlersocket
67
+
68
+ The home of HandlerSocket is here:
69
+ https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL
70
+
71
+ More documents are available in docs-en/ and docs-ja/ directories.
72
+