Merge lp:~stewart/drizzle/lsmtree into lp:drizzle

Proposed by Stewart Smith on 2013-03-14
Status: Merged
Merged at revision: 2636
Proposed branch: lp:~stewart/drizzle/lsmtree
Merge into: lp:drizzle
Diff against target: 299 lines (+131/-6)
10 files modified
drizzled/message.cc (+3/-0)
drizzled/message/statement_transform.cc (+3/-0)
drizzled/message/table.proto (+1/-0)
drizzled/sql_yacc.yy (+6/-3)
drizzled/symbol_hash.gperf (+1/-0)
plugin/tableprototester/tableprototester.cc (+85/-3)
plugin/tableprototester/tests/r/basic.result (+1/-0)
plugin/tableprototester/tests/r/lsmtree.result (+22/-0)
plugin/tableprototester/tests/t/lsmtree-master.opt (+1/-0)
plugin/tableprototester/tests/t/lsmtree.test (+8/-0)
To merge this branch: bzr merge lp:~stewart/drizzle/lsmtree
Reviewer Review Type Date Requested Status
Drizzle Trunk 2013-03-14 Pending
Review via email: mp+153282@code.launchpad.net

Description of the change

The WiredTiger engine (being worked on in another branch) can support Log Structured Merge Trees. We want to be able to create them using normal syntax.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/message.cc'
2--- drizzled/message.cc 2011-08-16 11:47:29 +0000
3+++ drizzled/message.cc 2013-03-14 03:53:22 +0000
4@@ -68,6 +68,7 @@
5 static const std::string RTREE("RTREE");
6 static const std::string HASH("HASH");
7 static const std::string FULLTEXT("FULLTEXT");
8+static const std::string LSMTREE("LSMTREE");
9
10 static const std::string MATCH_FULL("FULL");
11 static const std::string MATCH_PARTIAL("PARTIAL");
12@@ -227,6 +228,8 @@
13 return HASH;
14 case message::Table::Index::FULLTEXT:
15 return FULLTEXT;
16+ case message::Table::Index::LSMTREE:
17+ return LSMTREE;
18 }
19
20 assert(0);
21
22=== modified file 'drizzled/message/statement_transform.cc'
23--- drizzled/message/statement_transform.cc 2011-08-16 11:47:29 +0000
24+++ drizzled/message/statement_transform.cc 2013-03-14 03:53:22 +0000
25@@ -1254,6 +1254,9 @@
26 case Table::Index::FULLTEXT:
27 destination.append(" USING FULLTEXT");
28 break;
29+ case Table::Index::LSMTREE:
30+ destination.append(" USING LSMTREE");
31+ break;
32 }
33
34 if (index.has_comment())
35
36=== modified file 'drizzled/message/table.proto'
37--- drizzled/message/table.proto 2011-08-16 11:47:29 +0000
38+++ drizzled/message/table.proto 2013-03-14 03:53:22 +0000
39@@ -149,6 +149,7 @@
40 RTREE = 2;
41 HASH = 3;
42 FULLTEXT = 4;
43+ LSMTREE = 5;
44 }
45
46 message IndexPart {
47
48=== modified file 'drizzled/sql_yacc.yy'
49--- drizzled/sql_yacc.yy 2013-03-03 01:46:08 +0000
50+++ drizzled/sql_yacc.yy 2013-03-14 03:53:22 +0000
51@@ -390,6 +390,7 @@
52 %token LOGS_SYM
53 %token LONG_NUM
54 %token LONG_SYM
55+%token LSMTREE_SYM
56 %token MATCH /* SQL-2003-R */
57 %token MAX_SYM /* SQL-2003-N */
58 %token MAX_VALUE_SYM /* SQL-2003-N */
59@@ -703,7 +704,7 @@
60 key_type opt_unique constraint_key_type
61
62 %type <key_alg>
63- btree_or_rtree
64+ index_algorithm
65
66 %type <string_list>
67 using_list
68@@ -1768,7 +1769,7 @@
69 ;
70
71 key_using_alg:
72- USING btree_or_rtree { ((statement::CreateTable *)Lex.statement)->key_create_info.algorithm= $2; }
73+ USING index_algorithm { ((statement::CreateTable *)Lex.statement)->key_create_info.algorithm= $2; }
74 ;
75
76 key_opt:
77@@ -1779,9 +1780,10 @@
78 { ((statement::CreateTable *)Lex.statement)->key_create_info.comment= $2; }
79 ;
80
81-btree_or_rtree:
82+index_algorithm:
83 BTREE_SYM { $$= drizzled::message::Table::Index::BTREE; }
84 | HASH_SYM { $$= drizzled::message::Table::Index::HASH; }
85+ | LSMTREE_SYM { $$= drizzled::message::Table::Index::LSMTREE; }
86 ;
87
88 key_list:
89@@ -5315,6 +5317,7 @@
90 | LOCAL_SYM {}
91 | LOCKS_SYM {}
92 | LOGS_SYM {}
93+ | LSMTREE_SYM {}
94 | MAX_VALUE_SYM {}
95 | MEDIUM_SYM {}
96 | MERGE_SYM {}
97
98=== modified file 'drizzled/symbol_hash.gperf'
99--- drizzled/symbol_hash.gperf 2012-01-29 11:21:19 +0000
100+++ drizzled/symbol_hash.gperf 2013-03-14 03:53:22 +0000
101@@ -233,6 +233,7 @@
102 LONG, LONG_SYM
103 LONGBLOB, BLOB_SYM
104 LONGTEXT, TEXT_SYM
105+LSMTREE, LSMTREE_SYM
106 MATCH, MATCH
107 MAXVALUE, MAX_VALUE_SYM
108 MEDIUM, MEDIUM_SYM
109
110=== modified file 'plugin/tableprototester/tableprototester.cc'
111--- plugin/tableprototester/tableprototester.cc 2013-03-03 01:46:08 +0000
112+++ plugin/tableprototester/tableprototester.cc 2013-03-14 03:53:22 +0000
113@@ -113,6 +113,7 @@
114 set_of_identifiers.push_back(identifier::Table(schema_identifier, "t1"));
115 set_of_identifiers.push_back(identifier::Table(schema_identifier, "too_many_enum_values"));
116 set_of_identifiers.push_back(identifier::Table(schema_identifier, "invalid_table_collation"));
117+ set_of_identifiers.push_back(identifier::Table(schema_identifier, "lsmtree"));
118 }
119 }
120
121@@ -124,6 +125,8 @@
122 return true;
123 if (not identifier.getPath().compare("local/test/invalid_table_collation"))
124 return true;
125+ if (not identifier.getPath().compare("local/test/lsmtree"))
126+ return true;
127
128 return false;
129 }
130@@ -145,9 +148,19 @@
131
132 int TableProtoTesterEngine::doCreateTable(Session&,
133 Table&,
134- const drizzled::identifier::Table&,
135- const drizzled::message::Table&)
136+ const drizzled::identifier::Table& identifier,
137+ const drizzled::message::Table& create_proto)
138 {
139+ if (not identifier.getPath().compare("local/test/lsmtree_create"))
140+ {
141+ if (create_proto.indexes_size() < 1)
142+ return -1;
143+ if (create_proto.indexes(0).type() != message::Table::Index::LSMTREE)
144+ return -2;
145+
146+ return 0;
147+ }
148+
149 return EEXIST;
150 }
151
152@@ -235,6 +248,64 @@
153
154 }
155
156+static void fill_lsmtree(message::Table &table)
157+{
158+ message::Table::Field *field;
159+ message::Table::TableOptions *tableopts;
160+
161+ table.set_name("lsmtree");
162+ table.set_schema("test");
163+ table.set_type(message::Table::STANDARD);
164+ message::Engine *engine= table.mutable_engine();
165+ engine->set_name("TABLEPROTOTESTER");
166+ table.set_creation_timestamp(0);
167+ table.set_update_timestamp(0);
168+
169+ tableopts= table.mutable_options();
170+ tableopts->set_comment("LSM Tree test");
171+ tableopts->set_collation_id(my_charset_bin.number);
172+ tableopts->set_collation(my_charset_bin.name);
173+
174+ {
175+ field= table.add_field();
176+ field->set_name("a");
177+ field->set_type(message::Table::Field::INTEGER);
178+ }
179+ {
180+ field= table.add_field();
181+ field->set_name("b");
182+ field->set_type(message::Table::Field::INTEGER);
183+ }
184+ {
185+ field= table.add_field();
186+ field->set_name("c");
187+ field->set_type(message::Table::Field::INTEGER);
188+ }
189+
190+ {
191+ message::Table::Index *index= table.add_indexes();
192+ index->set_name("PRIMARY");
193+ index->set_is_primary(true);
194+ index->set_is_unique(true);
195+ index->set_type(message::Table::Index::BTREE);
196+ index->set_key_length(sizeof(uint32_t));
197+ message::Table::Index::IndexPart *part= index->add_index_part();
198+ part->set_fieldnr(0);
199+ part->set_compare_length(sizeof(uint32_t));
200+ }
201+
202+ {
203+ message::Table::Index *index= table.add_indexes();
204+ index->set_name("mylsm");
205+ index->set_type(message::Table::Index::LSMTREE);
206+ index->set_key_length(sizeof(uint32_t));
207+ message::Table::Index::IndexPart *part= index->add_index_part();
208+ part->set_fieldnr(1);
209+ part->set_compare_length(sizeof(uint32_t));
210+ }
211+
212+}
213+
214 int TableProtoTesterEngine::doGetTableDefinition(Session&,
215 const drizzled::identifier::Table &identifier,
216 drizzled::message::Table &table_proto)
217@@ -254,11 +325,22 @@
218 fill_table_invalid_table_collation(table_proto);
219 return EEXIST;
220 }
221+ else if (not identifier.getPath().compare("local/test/lsmtree"))
222+ {
223+ fill_lsmtree(table_proto);
224+ return EEXIST;
225+ }
226 return ENOENT;
227 }
228
229-const char *TableProtoTesterCursor::index_type(uint32_t)
230+const char *TableProtoTesterCursor::index_type(uint32_t idx)
231 {
232+ if (strcmp(getShare()->getTableName(), "lsmtree") == 0)
233+ {
234+ if (idx == 1)
235+ return "LSMTREE";
236+ }
237+
238 return("BTREE");
239 }
240
241
242=== modified file 'plugin/tableprototester/tests/r/basic.result'
243--- plugin/tableprototester/tests/r/basic.result 2010-12-03 01:17:59 +0000
244+++ plugin/tableprototester/tests/r/basic.result 2013-03-14 03:53:22 +0000
245@@ -1,5 +1,6 @@
246 SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA="test" ORDER BY TABLE_NAME;
247 TABLE_SCHEMA TABLE_NAME
248 test invalid_table_collation
249+test lsmtree
250 test t1
251 test too_many_enum_values
252
253=== added file 'plugin/tableprototester/tests/r/lsmtree.result'
254--- plugin/tableprototester/tests/r/lsmtree.result 1970-01-01 00:00:00 +0000
255+++ plugin/tableprototester/tests/r/lsmtree.result 2013-03-14 03:53:22 +0000
256@@ -0,0 +1,22 @@
257+use test;
258+show tables like 'lsm%';
259+Tables_in_test (lsm%)
260+lsmtree
261+SHOW CREATE TABLE lsmtree;
262+Table Create Table
263+lsmtree CREATE TABLE `lsmtree` (
264+ `a` INT,
265+ `b` INT,
266+ `c` INT,
267+ PRIMARY KEY (`a`) USING BTREE,
268+ KEY `mylsm` (`b`) USING LSMTREE
269+) ENGINE=TABLEPROTOTESTER COMMENT='LSM Tree test' COLLATE = binary
270+SHOW INDEX FROM lsmtree;
271+Table Unique Key_name Seq_in_index Column_name
272+lsmtree YES PRIMARY 1 a
273+lsmtree NO mylsm 1 b
274+SELECT INDEX_NAME,INDEX_TYPE,INDEX_COMMENT FROM DATA_DICTIONARY.INDEXES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='lsmtree';
275+INDEX_NAME INDEX_TYPE INDEX_COMMENT
276+PRIMARY BTREE NULL
277+mylsm LSMTREE NULL
278+CREATE TABLE lsmtree_create (a int, index(a) USING LSMTREE) ENGINE=TABLEPROTOTESTER;
279
280=== added file 'plugin/tableprototester/tests/t/lsmtree-master.opt'
281--- plugin/tableprototester/tests/t/lsmtree-master.opt 1970-01-01 00:00:00 +0000
282+++ plugin/tableprototester/tests/t/lsmtree-master.opt 2013-03-14 03:53:22 +0000
283@@ -0,0 +1,1 @@
284+--plugin-add=tableprototester
285\ No newline at end of file
286
287=== added file 'plugin/tableprototester/tests/t/lsmtree.test'
288--- plugin/tableprototester/tests/t/lsmtree.test 1970-01-01 00:00:00 +0000
289+++ plugin/tableprototester/tests/t/lsmtree.test 2013-03-14 03:53:22 +0000
290@@ -0,0 +1,8 @@
291+use test;
292+show tables like 'lsm%';
293+SHOW CREATE TABLE lsmtree;
294+SHOW INDEX FROM lsmtree;
295+SELECT INDEX_NAME,INDEX_TYPE,INDEX_COMMENT FROM DATA_DICTIONARY.INDEXES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='lsmtree';
296+# We don't really create a table, we're checking parser and proto creation
297+# so we don't need to drop it afterwards.
298+CREATE TABLE lsmtree_create (a int, index(a) USING LSMTREE) ENGINE=TABLEPROTOTESTER;
299\ No newline at end of file

Subscribers

People subscribed via source and target branches

to all changes: