19 #include <ndb_global.h>
34 static S_Scan g_scans[] = {
35 {
"affiliatestometa",
"ind_affiliatestometa", 0, 0, 0, 0 },
36 {
"media",
"metaid", 0, 0, 0, 0 },
37 {
"meta",
"PRIMARY", 0, 0, 0, 0 },
38 {
"artiststometamap",
"PRIMARY", 0, 0, 0, 0 },
39 {
"subgenrestometamap",
"metaid", 0, 0, 0, 0 }
43 #define require(x) require_exit_or_core_with_printer((x), 0, ndbout_printer)
44 #define require2(o, x) \
47 ndbout << o->getNdbError() << endl;\
48 require_exit_or_core_with_printer(0, 0, ndbout_printer);\
51 Uint32 g_affiliateid = 2;
52 Uint32 g_formatids[] = { 8, 31, 76 };
55 Uint32 g_artistid = 0;
56 Uint32 g_subgenreid = 0;
71 Ndb g_ndb(&con,
"test");
74 require(g_ndb.waitUntilReady() == 0);
77 g_trans = g_ndb.startTransaction();
81 const size_t cnt =
sizeof(g_scans)/
sizeof(g_scans[0]);
83 start = NdbTick_CurrentMillisecond();
85 for(i = 0; i<cnt; i++){
86 ndbout_c(
"starting scan on: %s %s",
87 g_scans[i].m_table, g_scans[i].m_index);
96 require(!g_scans[0].m_scan->setBound((Uint32)0,
99 sizeof(g_affiliateid)));
101 require(!g_scans[1].m_scan->setBound((Uint32)0,
104 sizeof(g_formatids[0])));
109 sf.eq(2, g_formatids[0]);
110 sf.eq(2, g_formatids[1]);
111 sf.eq(2, g_formatids[2]);
115 require(g_scans[0].m_scan->getValue(
"uniquekey"));
116 require(g_scans[0].m_scan->getValue(
"xml"));
119 require(g_scans[1].m_scan->getValue(
"path"));
120 require(g_scans[1].m_scan->getValue(
"mediaid"));
121 require(g_scans[1].m_scan->getValue(
"formatid"));
124 require(g_scans[2].m_scan->getValue(
"name"));
125 require(g_scans[2].m_scan->getValue(
"xml"));
128 require(g_scans[3].m_scan->getValue(
"artistid", (
char*)&g_artistid));
131 require(g_scans[4].m_scan->getValue(
"subgenreid", (
char*)&g_subgenreid));
133 for(i = 0; i<cnt; i++){
134 g_scans[
i].m_scan->
getValue(
"metaid", (
char*)&g_scans[i].metaid);
137 g_trans->
execute(NoCommit, AbortOnError, 1);
140 Uint32 match_val = 0;
142 S_Scan * F [5], * Q [5], * nextF [5];
143 Uint32 F_sz = 0, Q_sz = 0;
144 for(i = 0; i<cnt; i++){
149 Uint32 match_count = 0;
151 Uint32 prev_F_sz = F_sz;
157 for(i = 0; i<prev_F_sz; i++){
166 Uint32 metaid = F[
i]->metaid;
169 if(metaid == match_val){
171 nextF[F_sz++] = F[
i];
172 require(F_sz <= cnt);
175 for(j = 0; j<cnt; j++){
176 comb *= (&g_scans[j] == F[
i] ? 1 : g_scans[j].match_count);
182 if(metaid < max_val){
183 nextF[F_sz++] = F[
i];
184 require(F_sz <= cnt);
187 if(metaid > max_val){
188 for(j = 0; j<Q_sz; j++)
189 nextF[F_sz++] = Q[j];
190 require(F_sz <= cnt);
195 require(Q_sz <= cnt);
197 if(F_sz == 0 && Q_sz > 0){
199 for(j = 0; j<Q_sz; j++){
200 nextF[F_sz++] = Q[j];
201 Q[j]->match_count = 1;
203 require(F_sz <= cnt);
204 require(Q_sz <= cnt);
208 }
else if(!found && F_sz + Q_sz < cnt){
211 require(F_sz <= cnt);
212 for(i = 0; i<F_sz; i++)
216 start = NdbTick_CurrentMillisecond() - start;
217 ndbout_c(
"Elapsed: %lldms", start);
219 ndbout_c(
"rows: %d", match_count);
220 for(i = 0; i<cnt; i++){
221 ndbout_c(
"%s : %d", g_scans[i].m_table, g_scans[i].row_count);
232 require2(g_trans, op);
234 require2(op, op->
equal(
"artistid", g_artistid) == 0);
240 require2(g_trans, op);
242 require2(op, op->
equal(
"subgenreid", g_subgenreid) == 0);
249 require(g_trans->
execute(NoCommit) == 0);