Skip to content
Snippets Groups Projects
Commit e940859f authored by nkindlon's avatar nkindlon
Browse files

Shortened output buffer, corrected Chromsweep errors with some print options...

Shortened output buffer, corrected Chromsweep errors with some print options due to early termination.
parent 60223993
No related branches found
No related tags found
No related merge requests found
......@@ -28,14 +28,19 @@ RecordOutputMgr::RecordOutputMgr()
: _context(NULL),
_printable(true),
_bamWriter(NULL),
_currBlockList(NULL)
_currBlockList(NULL),
_numWrites(0)
{
}
RecordOutputMgr::~RecordOutputMgr()
{
flush();
if (_outBuf.size() > 0) {
flush();
_numWrites++;
}
cerr << "Total number of buffer writes was " << _numWrites << endl;
if (_bamWriter != NULL) {
_bamWriter->Close();
delete _bamWriter;
......@@ -105,7 +110,10 @@ RecordOutputMgr::printBamType RecordOutputMgr::printBamRecord(RecordKeyList &key
void RecordOutputMgr::printRecord(RecordKeyList &keyList, RecordKeyList *blockList)
{
if (needsFlush()) flush();
if (needsFlush()) {
flush();
_numWrites++;
}
//The first time we print a record is when we print any header, because the header
//hasn't been read from the query file until after the first record has also been read.
......
......@@ -40,6 +40,7 @@ private:
RecordKeyList *_currBlockList;
QuickString _outBuf;
int _numWrites;
//some helper functions to neaten the code.
void tab() { _outBuf.append('\t'); }
......@@ -48,7 +49,7 @@ private:
void printKey(const Record *key);
void printKey(const Record *key, const QuickString & start, const QuickString & end);
static const unsigned int MAX_OUTBUF_SIZE = 33554432; //32 Mb
static const unsigned int MAX_OUTBUF_SIZE = 16384; //16 K
bool needsFlush() const { return _outBuf.size() >= MAX_OUTBUF_SIZE *.9; }
void flush();
};
......
......@@ -24,7 +24,8 @@ NewChromSweep::NewChromSweep(Context *context,
_databaseRecordsTotalLength(0),
_wasInitialized(false),
_currQueryRec(NULL),
_currDatabaseRec(NULL)
_currDatabaseRec(NULL),
_runToQueryEnd(false)
{
}
......@@ -52,6 +53,13 @@ bool NewChromSweep::init() {
if (_currDatabaseRec == NULL) {
return false;
}
//determine whether to stop when the database end is hit, or keep going until the
//end of the query file is hit as well.
if (_context->getNoHit() || _context->getWriteCount() || _context->getWriteOverlap() || _context->getWriteAllOverlap() || _context->getLeftJoin()) {
_runToQueryEnd = true;
}
_wasInitialized = true;
return true;
}
......@@ -155,7 +163,7 @@ bool NewChromSweep::next(RecordKeyList &next) {
return false;
}
if (_currDatabaseRec == NULL && _cache.empty()) {
if (_currDatabaseRec == NULL && _cache.empty() && !_runToQueryEnd) {
return false;
}
_hits.clear();
......
......@@ -81,6 +81,7 @@ private:
Record *_currDatabaseRec;
// a cache of the current chrom from the query. used to handle chrom changes.
QuickString _currChromName;
bool _runToQueryEnd;
void nextRecord(bool query); //true fetches next query record, false fetches next db record.
void nextDatabase();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment