27
27
28
28
namespace souffle ::interpreter::test {
29
29
30
- using ::souffle::ram::analysis::MinIndexSelection;
30
+ using ::souffle::ram::analysis::AttributeConstraint;
31
+ using ::souffle::ram::analysis::FinalIndexSelection;
32
+ using ::souffle::ram::analysis::LexOrder;
33
+ using ::souffle::ram::analysis::OrderCollection;
34
+ using ::souffle::ram::analysis::SearchSet;
35
+ using ::souffle::ram::analysis::SearchSignature;
36
+ using ::souffle::ram::analysis::SignatureOrderMap;
31
37
32
38
TEST (Relation0, Construction) {
33
39
// create a nullary relation
34
40
SymbolTable symbolTable;
35
- MinIndexSelection order{};
36
- order.insertDefaultTotalIndex (0 );
37
- Relation<0 , interpreter::Btree> rel (0 , " test" , order);
41
+
42
+ // create an index selection from no searches to a default index for arity 0
43
+ SignatureOrderMap mapping;
44
+ SearchSet searches;
45
+ LexOrder emptyOrder;
46
+ OrderCollection orders = {emptyOrder};
47
+ FinalIndexSelection indexSelection (mapping, searches, orders);
48
+
49
+ Relation<0 , interpreter::Btree> rel (0 , " test" , indexSelection);
38
50
39
51
souffle::Tuple<RamDomain, 0 > tuple;
40
52
// add some values
@@ -48,9 +60,15 @@ TEST(Relation0, Construction) {
48
60
TEST (Relation0, Iteration) {
49
61
// create a nullary relation
50
62
SymbolTable symbolTable;
51
- MinIndexSelection order{};
52
- order.insertDefaultTotalIndex (0 );
53
- Relation<0 , interpreter::Btree> rel (0 , " test" , order);
63
+
64
+ // create an index selection from no searches to a default index for arity 0
65
+ SignatureOrderMap mapping;
66
+ SearchSet searches;
67
+ LexOrder emptyOrder;
68
+ OrderCollection orders = {emptyOrder};
69
+ FinalIndexSelection indexSelection (mapping, searches, orders);
70
+
71
+ Relation<0 , interpreter::Btree> rel (0 , " test" , indexSelection);
54
72
RelationWrapper* wrapper = &rel;
55
73
56
74
souffle::Tuple<RamDomain, 0 > tuple;
@@ -67,9 +85,17 @@ TEST(Relation0, Iteration) {
67
85
TEST (Relation1, Construction) {
68
86
// create a single attribute relation
69
87
SymbolTable symbolTable;
70
- MinIndexSelection order{};
71
- order.insertDefaultTotalIndex (1 );
72
- Relation<1 , interpreter::Btree> rel (0 , " test" , order);
88
+
89
+ // create an index selection for a relation with arity 1 with only an existence check
90
+ SignatureOrderMap mapping;
91
+ SearchSignature existenceCheck = SearchSignature::getFullSearchSignature (1 );
92
+ SearchSet searches = {existenceCheck};
93
+ LexOrder fullOrder = {0 };
94
+ OrderCollection orders = {fullOrder};
95
+ mapping.insert ({existenceCheck, fullOrder});
96
+ FinalIndexSelection indexSelection (mapping, searches, orders);
97
+
98
+ Relation<1 , interpreter::Btree> rel (0 , " test" , indexSelection);
73
99
RelInterface relInt (rel, symbolTable, " test" , {" i" }, {" i" }, 0 );
74
100
75
101
tuple d1 (&relInt, {1 });
@@ -88,9 +114,17 @@ TEST(Relation1, Construction) {
88
114
TEST (Basic, Iteration) {
89
115
// create a relation
90
116
SymbolTable symbolTable;
91
- MinIndexSelection order{};
92
- order.insertDefaultTotalIndex (1 );
93
- Relation<1 , interpreter::Btree> rel (0 , " test" , order);
117
+
118
+ // create an index selection for a relation with arity 1 with only an existence check
119
+ SignatureOrderMap mapping;
120
+ SearchSignature existenceCheck = SearchSignature::getFullSearchSignature (1 );
121
+ SearchSet searches = {existenceCheck};
122
+ LexOrder fullOrder = {0 };
123
+ OrderCollection orders = {fullOrder};
124
+ mapping.insert ({existenceCheck, fullOrder});
125
+ FinalIndexSelection indexSelection (mapping, searches, orders);
126
+
127
+ Relation<1 , interpreter::Btree> rel (0 , " test" , indexSelection);
94
128
RelInterface relInt (rel, symbolTable, " test" , {" i" }, {" i" }, 0 );
95
129
96
130
// add some values
@@ -115,9 +149,17 @@ TEST(Basic, Iteration) {
115
149
TEST (Independence, Iteration) {
116
150
// create a table
117
151
SymbolTable symbolTable;
118
- MinIndexSelection order{};
119
- order.insertDefaultTotalIndex (1 );
120
- Relation<1 , interpreter::Btree> rel (0 , " test" , order);
152
+
153
+ // create an index selection for a relation with arity 1 with only an existence check
154
+ SignatureOrderMap mapping;
155
+ SearchSignature existenceCheck = SearchSignature::getFullSearchSignature (1 );
156
+ SearchSet searches = {existenceCheck};
157
+ LexOrder fullOrder = {0 };
158
+ OrderCollection orders = {fullOrder};
159
+ mapping.insert ({existenceCheck, fullOrder});
160
+ FinalIndexSelection indexSelection (mapping, searches, orders);
161
+
162
+ Relation<1 , interpreter::Btree> rel (0 , " test" , indexSelection);
121
163
RelInterface relInt (rel, symbolTable, " test" , {" i" }, {" i" }, 0 );
122
164
123
165
// add a value
@@ -143,9 +185,17 @@ TEST(Independence, Iteration) {
143
185
TEST (IndependentMoving, Iteration) {
144
186
// create a table
145
187
SymbolTable symbolTable;
146
- MinIndexSelection order{};
147
- order.insertDefaultTotalIndex (1 );
148
- Relation<1 , interpreter::Btree> rel (0 , " test" , order);
188
+
189
+ // create an index selection for a relation with arity 1 with only an existence check
190
+ SignatureOrderMap mapping;
191
+ SearchSignature existenceCheck = SearchSignature::getFullSearchSignature (1 );
192
+ SearchSet searches = {existenceCheck};
193
+ LexOrder fullOrder = {0 };
194
+ OrderCollection orders = {fullOrder};
195
+ mapping.insert ({existenceCheck, fullOrder});
196
+ FinalIndexSelection indexSelection (mapping, searches, orders);
197
+
198
+ Relation<1 , interpreter::Btree> rel (0 , " test" , indexSelection);
149
199
RelInterface relInt (rel, symbolTable, " test" , {" i" }, {" i" }, 0 );
150
200
151
201
// add a value
@@ -166,9 +216,17 @@ TEST(IndependentMoving, Iteration) {
166
216
TEST (IndependentCopying, Iteration) {
167
217
// create a table
168
218
SymbolTable symbolTable;
169
- MinIndexSelection order{};
170
- order.insertDefaultTotalIndex (1 );
171
- Relation<1 , interpreter::Btree> rel (0 , " test" , order);
219
+
220
+ // create an index selection for a relation with arity 1 with only an existence check
221
+ SignatureOrderMap mapping;
222
+ SearchSignature existenceCheck = SearchSignature::getFullSearchSignature (1 );
223
+ SearchSet searches = {existenceCheck};
224
+ LexOrder fullOrder = {0 };
225
+ OrderCollection orders = {fullOrder};
226
+ mapping.insert ({existenceCheck, fullOrder});
227
+ FinalIndexSelection indexSelection (mapping, searches, orders);
228
+
229
+ Relation<1 , interpreter::Btree> rel (0 , " test" , indexSelection);
172
230
RelInterface relInt (rel, symbolTable, " test" , {" i" }, {" i" }, 0 );
173
231
174
232
// add a value
@@ -190,16 +248,17 @@ TEST(Reordering, Iteration) {
190
248
// create a relation, with a non-default ordering.
191
249
SymbolTable symbolTable;
192
250
251
+ // create an index selection for a relation with arity 1 with only an existence check
252
+ SignatureOrderMap mapping;
253
+ SearchSignature existenceCheck = SearchSignature::getFullSearchSignature (3 );
254
+ SearchSet searches = {existenceCheck};
193
255
// create an index of order {0, 2, 1}
194
- MinIndexSelection order{};
195
- ram::analysis::SearchSignature cols (3 );
196
- cols[0 ] = ram::analysis::AttributeConstraint::Equal;
197
- cols[1 ] = ram::analysis::AttributeConstraint::None;
198
- cols[2 ] = ram::analysis::AttributeConstraint::Equal;
199
- order.addSearch (cols);
200
- order.solve ();
201
-
202
- Relation<3 , interpreter::Btree> rel (0 , " test" , order);
256
+ LexOrder fullOrder = {0 , 2 , 1 };
257
+ OrderCollection orders = {fullOrder};
258
+ mapping.insert ({existenceCheck, fullOrder});
259
+ FinalIndexSelection indexSelection (mapping, searches, orders);
260
+
261
+ Relation<3 , interpreter::Btree> rel (0 , " test" , indexSelection);
203
262
souffle::Tuple<RamDomain, 3 > tuple{0 , 1 , 2 };
204
263
rel.insert (tuple);
205
264
0 commit comments