Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Parser::ProcessParsedChunk() is now a regular method instead of a slo…

…t (and is being called as such). There was absolutely no need to use the signal/slot mechanism here. Hence, also stopped emitting the parsedChunk() signal.
  • Loading branch information...
commit 689fed40b65d5db6494da13033830ab24b9605a5 1 parent d55f0bc
@wimleers authored
Showing with 30 additions and 34 deletions.
  1. +29 −32 code/EpisodesParser/Parser.cpp
  2. +1 −2  code/EpisodesParser/Parser.h
View
61 code/EpisodesParser/Parser.cpp
@@ -28,8 +28,6 @@ namespace EpisodesParser {
if (!Parser::parserHelpersInitialized)
qFatal("Call Parser::initParserHelper() before creating Parser instances.");
Parser::parserHelpersInitMutex.unlock();
-
- connect(this, SIGNAL(parsedChunk(QStringList)), SLOT(processParsedChunk(QStringList)));
}
void Parser::initParserHelpers(const QString & browsCapCSV,
@@ -106,14 +104,14 @@ namespace EpisodesParser {
chunk.append(in.readLine());
numLines++;
if (chunk.size() == CHUNK_SIZE) {
- emit parsedChunk(chunk);
+ this->processParsedChunk(chunk);
chunk.clear();
}
}
// Check if we have another chunk (with size < CHUNK_SIZE).
if (chunk.size() > 0) {
- emit parsedChunk(chunk);
+ this->processParsedChunk(chunk);
}
return numLines;
@@ -403,33 +401,6 @@ namespace EpisodesParser {
//---------------------------------------------------------------------------
// Protected slots.
- void Parser::processParsedChunk(const QStringList & chunk) {
- static unsigned int quarterID = 0;
- static QList<EpisodesLogLine> batch;
-
- qDebug() << "STARTING CHUNK, remaining lines in previous batch" << batch.size();
-
- // Perform the mapping from strings to EpisodesLogLine concurrently.
-// QList<EpisodesLogLine> mappedChunk = QtConcurrent::blockingMapped(chunk, Parser::mapLineToEpisodesLogLine);
- QString rawLine;
- EpisodesLogLine line;
- foreach (rawLine, chunk) {
- line = Parser::mapLineToEpisodesLogLine(rawLine);
-
- // Create a batch for each quarter (900 seconds) and process it.
- if (line.time / 900 > quarterID) {
- quarterID = line.time / 900;
- if (!batch.isEmpty())
- this->processBatch(batch);
- batch.clear();
- }
-
- batch.append(line);
- }
-
- qDebug() << "Processed chunk of" << CHUNK_SIZE << "lines!";
- }
-
void Parser::processBatch(const QList<EpisodesLogLine> batch) {
double transactionsPerEvent;
#ifdef DEBUG
@@ -483,7 +454,33 @@ namespace EpisodesParser {
<< QDateTime::fromTime_t(batch.first().time).toString("yyyy-MM-dd hh:mm:ss").toStdString().c_str()
<< "and"
<< QDateTime::fromTime_t(batch.last().time).toString("yyyy-MM-dd hh:mm:ss").toStdString().c_str();
+ //---------------------------------------------------------------------------
+ // Protected methods.
+
+ void Parser::processParsedChunk(const QStringList & chunk) {
+ static unsigned int quarterID = 0;
+ static QList<EpisodesLogLine> batch;
+
+ qDebug() << "STARTING CHUNK, remaining lines in previous batch" << batch.size();
- emit processedChunk(transactions, transactionsPerEvent);
+ // Perform the mapping from strings to EpisodesLogLine concurrently.
+// QList<EpisodesLogLine> mappedChunk = QtConcurrent::blockingMapped(chunk, Parser::mapLineToEpisodesLogLine);
+ QString rawLine;
+ EpisodesLogLine line;
+ foreach (rawLine, chunk) {
+ line = Parser::mapLineToEpisodesLogLine(rawLine);
+
+ // Create a batch for each quarter (900 seconds) and process it.
+ if (line.time / 900 > quarterID) {
+ quarterID = line.time / 900;
+ if (!batch.isEmpty())
+ this->processBatch(batch);
+ batch.clear();
+ }
+
+ batch.append(line);
+ }
+
+ qDebug() << "Processed chunk of" << CHUNK_SIZE << "lines!";
}
}
View
3  code/EpisodesParser/Parser.h
@@ -42,14 +42,13 @@ namespace EpisodesParser {
static QList<QStringList> mapExpandedEpisodesLogLineToTransactions(const ExpandedEpisodesLogLine & line);
signals:
- void parsedChunk(QStringList chunk);
void processedChunk(QList<QStringList> transactions, double transactionsPerEvent);
protected slots:
- void processParsedChunk(const QStringList & chunk);
void processBatch(const QList<EpisodesLogLine> batch);
protected:
+ void processParsedChunk(const QStringList & chunk);
// QHashes that are used to minimize memory usage.
static EpisodeNameIDHash episodeNameIDHash;
static EpisodeIDNameHash episodeIDNameHash;
Please sign in to comment.
Something went wrong with that request. Please try again.