Changeset View
Changeset View
Standalone View
Standalone View
src/engine/transaction.cpp
Show First 20 Lines • Show All 308 Lines • ▼ Show 20 Line(s) | 295 | { | |||
---|---|---|---|---|---|
309 | if (query.subQueries().isEmpty()) { | 309 | if (query.subQueries().isEmpty()) { | ||
310 | return nullptr; | 310 | return nullptr; | ||
311 | } | 311 | } | ||
312 | 312 | | |||
313 | QVector<PostingIterator*> vec; | 313 | QVector<PostingIterator*> vec; | ||
314 | vec.reserve(query.subQueries().size()); | 314 | vec.reserve(query.subQueries().size()); | ||
315 | 315 | | |||
316 | if (query.op() == EngineQuery::Phrase) { | 316 | if (query.op() == EngineQuery::Phrase) { | ||
317 | for (const EngineQuery& q : query.subQueries()) { | 317 | const auto subQueries = query.subQueries(); | ||
318 | for (const EngineQuery& q : subQueries) { | ||||
318 | Q_ASSERT_X(q.leaf(), "Transaction::toPostingIterator", "Phrase queries must contain leaf queries"); | 319 | Q_ASSERT_X(q.leaf(), "Transaction::toPostingIterator", "Phrase queries must contain leaf queries"); | ||
319 | vec << positionDb.iter(q.term()); | 320 | vec << positionDb.iter(q.term()); | ||
320 | } | 321 | } | ||
321 | 322 | | |||
322 | return new PhraseAndIterator(vec); | 323 | return new PhraseAndIterator(vec); | ||
323 | } | 324 | } | ||
324 | 325 | | |||
325 | for (const EngineQuery& q : query.subQueries()) { | 326 | const auto subQueries = query.subQueries(); | ||
327 | for (const EngineQuery& q : subQueries) { | ||||
bruns: Move this one up, before the `query.op() == EngineQuery::Phrase)` | |||||
326 | vec << postingIterator(q); | 328 | vec << postingIterator(q); | ||
327 | } | 329 | } | ||
328 | 330 | | |||
329 | if (query.op() == EngineQuery::And) { | 331 | if (query.op() == EngineQuery::And) { | ||
330 | return new AndPostingIterator(vec); | 332 | return new AndPostingIterator(vec); | ||
331 | } else if (query.op() == EngineQuery::Or) { | 333 | } else if (query.op() == EngineQuery::Or) { | ||
332 | return new OrPostingIterator(vec); | 334 | return new OrPostingIterator(vec); | ||
333 | } | 335 | } | ||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Line(s) | 468 | for (quint64 id : list) { | |||
467 | allIds << id; | 469 | allIds << id; | ||
468 | } | 470 | } | ||
469 | } | 471 | } | ||
470 | 472 | | |||
471 | QTextStream out(stdout); | 473 | QTextStream out(stdout); | ||
472 | out << "Total Document IDs: " << allIds.size() << endl; | 474 | out << "Total Document IDs: " << allIds.size() << endl; | ||
473 | 475 | | |||
474 | int count = 0; | 476 | int count = 0; | ||
475 | for (quint64 id: allIds) { | 477 | for (quint64 id: qAsConst(allIds)) { | ||
476 | QByteArray url = docUrlDb.get(id); | 478 | QByteArray url = docUrlDb.get(id); | ||
477 | if (url.isEmpty()) { | 479 | if (url.isEmpty()) { | ||
478 | auto terms = documentTermsDB.get(id); | 480 | auto terms = documentTermsDB.get(id); | ||
479 | auto fileNameTerms = documentFileNameTermsDB.get(id); | 481 | auto fileNameTerms = documentFileNameTermsDB.get(id); | ||
480 | auto xAttrTerms = documentXattrTermsDB.get(id); | 482 | auto xAttrTerms = documentXattrTermsDB.get(id); | ||
481 | 483 | | |||
482 | // Lets reverse enginer the terms | 484 | // Lets reverse enginer the terms | ||
483 | QList<QByteArray> newTerms; | 485 | QList<QByteArray> newTerms; | ||
484 | QMapIterator<QByteArray, PostingList> it(map); | 486 | QMapIterator<QByteArray, PostingList> it(map); | ||
485 | while (it.hasNext()) { | 487 | while (it.hasNext()) { | ||
486 | it.next(); | 488 | it.next(); | ||
487 | if (it.value().contains(id)) { | 489 | if (it.value().contains(id)) { | ||
488 | newTerms << it.key(); | 490 | newTerms << it.key(); | ||
489 | } | 491 | } | ||
490 | } | 492 | } | ||
491 | 493 | | |||
492 | out << "Missing filePath for " << id << endl; | 494 | out << "Missing filePath for " << id << endl; | ||
493 | out << "\tPostingDB Terms: "; | 495 | out << "\tPostingDB Terms: "; | ||
494 | for (const QByteArray& term : newTerms) { | 496 | for (const QByteArray& term : qAsConst(newTerms)) { | ||
495 | out << term << " "; | 497 | out << term << " "; | ||
496 | } | 498 | } | ||
497 | out << endl; | 499 | out << endl; | ||
498 | 500 | | |||
499 | out << "\tDocumentTermsDB: "; | 501 | out << "\tDocumentTermsDB: "; | ||
500 | for (const QByteArray& term : terms) { | 502 | for (const QByteArray& term : terms) { | ||
501 | out << term << " "; | 503 | out << term << " "; | ||
502 | } | 504 | } | ||
503 | out << endl; | 505 | out << endl; | ||
504 | 506 | | |||
505 | out << "\tFileNameTermsDB: "; | 507 | out << "\tFileNameTermsDB: "; | ||
506 | for (const QByteArray& term : terms) { | 508 | for (const QByteArray& term : terms) { | ||
This is a functional change and should not be hidden between "cosmetical" changes bruns: This is a functional change and should not be hidden between "cosmetical" changes | |||||
507 | out << term << " "; | 509 | out << term << " "; | ||
508 | } | 510 | } | ||
509 | out << endl; | 511 | out << endl; | ||
510 | 512 | | |||
511 | out << "\tXAttrTermsDB: "; | 513 | out << "\tXAttrTermsDB: "; | ||
512 | for (const QByteArray& term : terms) { | 514 | for (const QByteArray& term : terms) { | ||
513 | out << term << " "; | 515 | out << term << " "; | ||
514 | } | 516 | } | ||
Show All 25 Lines | 530 | { | |||
540 | Q_FOREACH (const auto& list, map) { | 542 | Q_FOREACH (const auto& list, map) { | ||
541 | for (quint64 id : list) { | 543 | for (quint64 id : list) { | ||
542 | allIds << id; | 544 | allIds << id; | ||
543 | } | 545 | } | ||
544 | } | 546 | } | ||
545 | 547 | | |||
546 | QTextStream out(stdout); | 548 | QTextStream out(stdout); | ||
547 | out << "PostingDB check .." << endl; | 549 | out << "PostingDB check .." << endl; | ||
548 | for (quint64 id : allIds) { | 550 | for (quint64 id : qAsConst(allIds)) { | ||
549 | QVector<QByteArray> terms = documentTermsDB.get(id); | 551 | QVector<QByteArray> terms = documentTermsDB.get(id); | ||
550 | terms += documentXattrTermsDB.get(id); | 552 | terms += documentXattrTermsDB.get(id); | ||
551 | terms += documentFileNameTermsDB.get(id); | 553 | terms += documentFileNameTermsDB.get(id); | ||
552 | 554 | | |||
553 | for (const QByteArray& term : terms) { | 555 | for (const QByteArray& term : qAsConst(terms)) { | ||
554 | PostingList plist = postingDb.get(term); | 556 | PostingList plist = postingDb.get(term); | ||
555 | if (!plist.contains(id)) { | 557 | if (!plist.contains(id)) { | ||
556 | out << id << " is missing term " << term << endl; | 558 | out << id << " is missing term " << term << endl; | ||
557 | } | 559 | } | ||
558 | } | 560 | } | ||
559 | } | 561 | } | ||
560 | } | 562 | } | ||
561 | 563 | | |||
Show All 32 Lines |
Move this one up, before the query.op() == EngineQuery::Phrase)