CATCH_NEXTROW() { ActivityTimer t(totalCycles, timeActivities, NULL); while (!abortSoon) { if (rowIter->isValid()) { anyThisGroup = true; OwnedConstThorRow r = rowIter->getRow(); dataLinkIncrement(); rowIter->next(); return r.getClear(); } curRow.setown(input->nextRow()); if (!curRow) { if (anyThisGroup) { anyThisGroup = false; break; } curRow.setown(input->nextRow()); if (!curRow) break; } processRecord(curRow.get()); rowIter->first(); } return NULL; }
bool EReaderStream::fillBuffer() { if (myDestination == TEXT) { return PalmDocLikeStream::fillBuffer(); } else { while (myBufferOffset == myBufferLength) { if (!processRecord()) { return false; } } return true; } }
bool PalmDocLikeStream::fillBuffer() { while (myBufferOffset == myBufferLength) { if (myRecordIndex + 1 > myMaxRecordIndex) { return false; } ++myRecordIndex; if (!processRecord()) { return false; } } //myBufferOffset = 0; return true; }
int do1Record() { char *chp; char *attr; char *data; // line shoud be like ">>12345" if (line[0] != '>') { printf("Wrong first line:%s\n", line);fflush(stdout); exit(1); } strcpy(id, line+2); while (fgets(line, sizeof(line), inf) != NULL) { *(line + strlen(line) - 1 ) = '\0'; chp = strstr(line, ":"); if (chp != NULL) { *chp = '\0'; attr = line; data = chp + 2; processRecord(attr, data); } else { if ((line[0] != '>') || (line[1] != '>')) { printf("CGAP ID line not found:\n%s\n", line); break; } else { return(0); } } } done = 1; return(0); }
//------------------------------------------------------------------------------ // Process all data records in the queue. //------------------------------------------------------------------------------ void OutputHandler::processQueue() { // Get the first record from the queue base::lock( semaphore ); const DataRecordHandle* dataRecord = static_cast<const DataRecordHandle*>(queue.get()); base::unlock( semaphore ); // While we have records ... while (dataRecord != nullptr) { // process this record, processRecord(dataRecord); dataRecord->unref(); // and get the next one from the queue base::lock( semaphore ); dataRecord = static_cast<const DataRecordHandle*>(queue.get()); base::unlock( semaphore ); } }
bool Connection::processRecords() { MLOG_MESSAGE(Debug, "processRecords()"); while(pos_ >= sizeof(FCGIRecord)) { FCGIRecord * rec = mstd::pointer_cast<FCGIRecord*>(&buffer_[0]); size_t recordLen = sizeof(*rec) + mstd::ntoh(rec->contentLength) + rec->paddingLength; if(pos_ >= recordLen) { if(!processRecord(*rec)) return false; memcpy(&buffer_[0], &buffer_[0] + recordLen, pos_ - recordLen); pos_ -= recordLen; } else MLOG_MESSAGE(Debug, "Non full record: " << recordLen); } return true; }
bool BamProcessor::process () { if (!infile_.ReadHeader (sam_header_)) ers << "Unable to read SAM header" << Throw; else info << "Header read" << std::endl; if (outfile_.IsOpen ()) { if (!outfile_.WriteHeader (sam_header_)) ers << "Unable to write header data" << Throw; else info << "Header written" << std::endl; } // set up signal handlers sighandler_t sighandler_int, sighandler_term, sighandler_hup; // set INT handler to int_handler if interrupting is not disabled allready if ((sighandler_int = signal (SIGINT, int_handler)) == SIG_IGN) signal (SIGINT, SIG_IGN), sighandler_int = NULL; // set HUP handler to nothing sighandler_hup = signal (SIGHUP, SIG_IGN); // set TERM handler to int_handler if terminating is not disabled allready if ((sighandler_term = signal (SIGTERM, int_handler)) == SIG_IGN) signal (SIGTERM, SIG_IGN), sighandler_term = NULL; begtime_ = time (NULL); while (!infile_.IsEOF () && !interrupted) { if (limit_ && proc_cnt_ >= limit_) { info << limit_ << " records processed. Limit reached." << std::endl; break; } if (read_cnt_ == skip_) timer_.mark (); infile_.ReadRecord (sam_header_, rec_); ++ read_cnt_; if (read_cnt_-1 >= skip_) { if (!processRecord ()) ++ fail_cnt_; ++ proc_cnt_; if (outfile_.IsOpen ()) outfile_.WriteRecord (sam_header_, rec_); } if (timer_ ()) { info << "\r" << read_cnt_; if (proc_cnt_ != read_cnt_) info << " rd " << proc_cnt_; info << " pr "; if (realigned_cnt_ != proc_cnt_) info << realigned_cnt_ << " al (" << (double (realigned_cnt_) * 100 / proc_cnt_) << "%) "; info << modified_cnt_ << " mod (" << (double (modified_cnt_) * 100 / proc_cnt_) << "%) "; if (pos_adjusted_cnt_) info << pos_adjusted_cnt_ << " sh (" << (double (pos_adjusted_cnt_) * 100 / modified_cnt_) << "% mod) "; info << "in " << timer_.tot_elapsed () << " sec (" << std::setprecision (3) << std::fixed << timer_.speed () << " r/s)" << std::flush; } } if (interrupted) { errlog << "\nProcessing interrupted by "; switch (signal_received) { case SIGTERM: errlog << "TERM signal"; break; case SIGINT: errlog << "user's request"; break; default: errlog << "receipt of signal " << signal_received; } errlog << std::endl; } // restore signal handlers if (sighandler_term) signal (SIGTERM, sighandler_term); if (sighandler_int) signal (SIGINT, sighandler_int); if (sighandler_hup) signal (SIGHUP, sighandler_hup); return 0; }