Skip to content

Commit

Permalink
Fix prefilter/alignment with 0-size query input #433
Browse files Browse the repository at this point in the history
  • Loading branch information
milot-mirdita committed Apr 6, 2021
1 parent 14a3dce commit a6cab56
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
25 changes: 19 additions & 6 deletions src/commons/DBWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ void DBWriter::mergeResults(const char *outFileName, const char *outFileNameInde

// merge index
mergeIndex(indexFileNames, dataFilenames.size(), mergedSizes);
} else {
} else if (dataFilenames.size() == 1) {
std::vector<std::string>& filenames = dataFilenames[0];
if (filenames.size() == 1) {
// In single thread dbreader mode it will create a .0
Expand All @@ -590,12 +590,25 @@ void DBWriter::mergeResults(const char *outFileName, const char *outFileNameInde
} else {
DBReader<unsigned int>::moveDatafiles(filenames, outFileName);
}
}
if (indexNeedsToBeSorted) {
DBWriter::sortIndex(indexFileNames[0], outFileNameIndex, lexicographicOrder);
FileUtil::remove(indexFileNames[0]);
} else {
FileUtil::move(indexFileNames[0], outFileNameIndex);
FILE *outFh = FileUtil::openAndDelete(outFileName, "w");
if (fclose(outFh) != 0) {
Debug(Debug::ERROR) << "Cannot close data file " << outFileName << "\n";
EXIT(EXIT_FAILURE);
}
outFh = FileUtil::openAndDelete(outFileNameIndex, "w");
if (fclose(outFh) != 0) {
Debug(Debug::ERROR) << "Cannot close index file " << outFileNameIndex << "\n";
EXIT(EXIT_FAILURE);
}
}
if (dataFilenames.size() > 0) {
if (indexNeedsToBeSorted) {
DBWriter::sortIndex(indexFileNames[0], outFileNameIndex, lexicographicOrder);
FileUtil::remove(indexFileNames[0]);
} else {
FileUtil::move(indexFileNames[0], outFileNameIndex);
}
}
Debug(Debug::INFO) << "Time for merging to " << FileUtil::baseName(outFileName) << ": " << timer.lap() << "\n";
}
Expand Down
11 changes: 8 additions & 3 deletions src/prefiltering/Prefiltering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,13 @@ void Prefiltering::runMpiSplits(const std::string &resultDB, const std::string &
// merge output databases
mergePrefilterSplits(resultDB, resultDBIndex, splitFiles);
} else {
Debug(Debug::ERROR) << "Aborting. No results were computed!\n";
EXIT(EXIT_FAILURE);
DBWriter writer(resultDB.c_str(), resultDBIndex.c_str(), 1, compressed, Parameters::DBTYPE_PREFILTER_RES);
writer.open();
writer.close();
}

delete [] results;
}

}
#endif

Expand Down Expand Up @@ -696,6 +696,11 @@ int Prefiltering::runSplits(const std::string &resultDB, const std::string &resu
if (runSplit(resultDB.c_str(), resultDBIndex.c_str(), fromSplit, merge)) {
hasResult = true;
}
} else if (splitProcessCount == 0) {
DBWriter writer(resultDB.c_str(), resultDBIndex.c_str(), 1, compressed, Parameters::DBTYPE_PREFILTER_RES);
writer.open();
writer.close();
hasResult = false;
}

return hasResult;
Expand Down

0 comments on commit a6cab56

Please sign in to comment.