bool NewChromSweep::chromChange(int dbIdx, RecordKeyVector &retList, bool wantScan) { const Record *dbRec = _currDbRecs[dbIdx]; if (_currQueryRec != NULL && _currQueryChromName != _prevQueryChromName) { _context->testNameConventions(_currQueryRec); testChromOrder(_currQueryRec); } if (dbRec != NULL) { _context->testNameConventions(dbRec); testChromOrder(dbRec); } // If the query rec and db rec are on the same chrom, stop. if (dbRec != NULL && _currQueryRec != NULL && _currQueryRec->sameChrom(dbRec)) return false; if (dbRec == NULL || _currQueryRec == NULL) return false; if (queryChromAfterDbRec(dbRec)) { // the query is ahead of the database. fast-forward the database to catch-up. QuickString oldDbChrom(dbRec->getChrName()); while (dbRec != NULL && queryChromAfterDbRec(dbRec)) { _dbFRMs[dbIdx]->deleteRecord(dbRec); if (!nextRecord(false, dbIdx)) break; dbRec = _currDbRecs[dbIdx]; const QuickString &newDbChrom = dbRec->getChrName(); if (newDbChrom != oldDbChrom) { testChromOrder(dbRec); oldDbChrom = newDbChrom; } } clearCache(dbIdx); return false; } else { // the database is ahead of the query. // scan the cache for remaining hits on the query's current chrom. if (wantScan) scanCache(dbIdx, retList); return true; } }
bool CloseSweep::chromChange(int dbIdx, RecordKeyVector &retList, bool wantScan) { Record *dbRec = _currDbRecs[dbIdx]; bool haveQuery = _currQueryRec != NULL; bool haveDB = dbRec != NULL; if (haveQuery && _currQueryChromName != _prevQueryChromName) { _context->testNameConventions(_currQueryRec); testChromOrder(_currQueryRec); } if (haveDB) { _context->testNameConventions(dbRec); testChromOrder(dbRec); } // the files are on the same chrom if (haveQuery && (!haveDB || _currQueryRec->sameChrom(dbRec))) { //if this is the first time the query's chrom is ahead of the chrom that was in this cache, //then we have to clear the cache. if (!_caches[dbIdx].empty() && queryChromAfterDbRec(_caches[dbIdx].begin()->value())) { clearCache(dbIdx); clearClosestEndPos(dbIdx); } return false; } if (!haveQuery || !haveDB) return false; if (!_caches[dbIdx].empty() && (_caches[dbIdx].begin()->value()->sameChrom(_currQueryRec))) { //the newest DB record's chrom is ahead of the query, but the cache still //has old records on that query's chrom scanCache(dbIdx, retList); finalizeSelections(dbIdx, retList); return true; } // the query is ahead of the database. fast-forward the database to catch-up. if (queryChromAfterDbRec(dbRec)) { string oldDbChrom(dbRec->getChrName()); while (dbRec != NULL && queryChromAfterDbRec(dbRec)) { _dbFRMs[dbIdx]->deleteRecord(dbRec); if (!nextRecord(false, dbIdx)) break; dbRec = _currDbRecs[dbIdx]; const string &newDbChrom = dbRec->getChrName(); if (newDbChrom != oldDbChrom) { testChromOrder(dbRec); oldDbChrom = newDbChrom; } } clearCache(dbIdx); clearClosestEndPos(dbIdx); return false; } // the database is ahead of the query. else { // 1. scan the cache for remaining hits on the query's current chrom. if (wantScan) scanCache(dbIdx, retList); return true; } //control can't reach here, but compiler still wants a return statement. return true; }