Skip to content
Snippets Groups Projects
Commit 421e47ea authored by jsclose's avatar jsclose
Browse files

modified local reader to take in a parsed url pointer to fix test case

parent 79e9c921
Branches
No related tags found
No related merge requests found
File added
......@@ -40,6 +40,7 @@ class ISRWord : public ISR
Location Seek ( Location target );
// ISR *GetDocumentISR( );
Location GetEndDocument ( );
......
No preview for this file type
......@@ -31,8 +31,7 @@ string LocalReader::PageToString ( )
ParsedUrl * LocalReader::getUrl ( )
{
ParsedUrl url(test_url);
return &url;
return test_url;
}
bool LocalReader::checkStatus ( )
......@@ -45,7 +44,7 @@ void LocalReader::closeReader ( )
close(fd);
}
void LocalReader::setUrl(ParsedUrl url_in)
void LocalReader::setUrl(ParsedUrl* url_in)
{
test_url = url_in;
}
\ No newline at end of file
......@@ -25,11 +25,11 @@ public:
void closeReader ( );
void setUrl(ParsedUrl url);
void setUrl(ParsedUrl * url);
private:
string fileName;
ParsedUrl test_url;
ParsedUrl * test_url;
int fd;
};
......
This diff is collapsed.
......@@ -16,7 +16,7 @@ void Indexer::run ( )
bool cond = true;
while(alive) {
while(alive && pointerToDictionaries->Size() != 0 ) {
DocIndex * dictionary = pointerToDictionaries->Pop();
cout << "INDEX GOT A NEW Dictionary" << endl;
......@@ -43,7 +43,7 @@ void Indexer::run ( )
docEnd.docNumWords = indexedCount;
docEndings.push_back(docEnd);
if(currentBlockNumberWords >= 100000 || alive == false) {
if(currentBlockNumberWords >= 100000 ) {
save();
reset();
}
......
......@@ -164,16 +164,11 @@ int main ( int argc, char *argv[] )
Indexer indexer( IndexerQueue );
indexer.StartThread( );
Crawler *crawler = new Crawler( mode, urlFrontier, IndexerQueue );
atomic_bool *alive = new atomic_bool(true); // At the beginning of the program
atomic_bool *alive = new atomic_bool(true);
crawler->SpawnSpiders( numberOfSpiders , alive);
HouseKeeper logger( crawler );
......@@ -191,6 +186,7 @@ int main ( int argc, char *argv[] )
cout << "Shutting down the indexer " << endl ;
crawler->KillAllSpiders();
crawler->WaitOnAllSpiders( );
indexer.Kill();
indexer.WaitForFinish( );
......@@ -206,16 +202,4 @@ int main ( int argc, char *argv[] )
}
//main threads is just reading command
//if it wants work, has to spawn thread to do it
//thread we spawn, periodically pulls should
}
\ No newline at end of file
......@@ -57,7 +57,7 @@ void testSimple ( )
cout << "Testing Simple: " << endl;
UrlFrontier urlFrontierTest;
Parser parser( &urlFrontierTest );
ParsedUrl fake_url = ParsedUrl( "http://www.cats.com" );
ParsedUrl * fake_url = new ParsedUrl( "http://www.cats.com" );
string filepath = util::GetCurrentWorkingDir( ) + "/tests/plaintext.txt";
LocalReader reader( filepath );
......@@ -144,7 +144,7 @@ void testURL ( )
string filepath = util::GetCurrentWorkingDir( ) + "/tests/urlTest.html";
LocalReader reader( filepath );
reader.setUrl( fake_url );
reader.setUrl( &fake_url );
auto success = reader.request( );
if ( !success )
{
......@@ -178,7 +178,7 @@ void testBody ( )
string filepath = util::GetCurrentWorkingDir( ) + "/tests/testParserBody.html";
LocalReader reader( filepath );
reader.setUrl( fake_url );
reader.setUrl( &fake_url );
auto success = reader.request( );
if ( !success )
{
......@@ -224,7 +224,7 @@ void testExtractBody ( )
cout << "Testing ExtractBody: " << endl;
UrlFrontier urlFrontierTest;
Parser parser( &urlFrontierTest );
ParsedUrl fake_url = ParsedUrl( "https://developer.mozilla.org/en-US/docs/Learn" );
ParsedUrl *fake_url = new ParsedUrl( "https://developer.mozilla.org/en-US/docs/Learn" );
string filepath = util::GetCurrentWorkingDir( ) + "/tests/testExtractBodyTest.html";
LocalReader reader( filepath );
......@@ -275,7 +275,7 @@ void testAnchorText ( )
string filepath = util::GetCurrentWorkingDir( ) + "/tests/testParserBody.html";
LocalReader reader( filepath );
reader.setUrl( fake_url );
reader.setUrl( &fake_url );
auto success = reader.request( );
if ( !success )
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment