diff --git a/ISRWord-tests b/ISRWord-tests index d5e87b3bbe042dca63484afc6c915fdfab53128a..da8fa890473414adc4d5664e08c9c5eeae034b9d 100755 Binary files a/ISRWord-tests and b/ISRWord-tests differ diff --git a/constraintSolver/ISR.h b/constraintSolver/ISR.h index 4d6fd5d9b248e7f2e95c593031ae97613ec0af6d..27a7a557334cb4b6a514dd4db0424fd96bf91065 100644 --- a/constraintSolver/ISR.h +++ b/constraintSolver/ISR.h @@ -15,6 +15,8 @@ #include <limits> #include "ISREndDoc.h" + +#define pathToIndex "/build/" typedef size_t Location; // Location 0 is the null location. const Location MAX_Location = std::numeric_limits<unsigned>::max(); diff --git a/constraintSolver/ISRWord.cpp b/constraintSolver/ISRWord.cpp index 98bad341642dd71d21318ce8bc1e8e2dbdbca734..ba288221997998a93055acc2a24d3b6ca3da2cfb 100644 --- a/constraintSolver/ISRWord.cpp +++ b/constraintSolver/ISRWord.cpp @@ -3,7 +3,6 @@ #include "ISRWord.h" -#define pathToIndex = "build" size_t FileSize(int f) { struct stat fileInfo; fstat( f, &fileInfo); @@ -20,7 +19,7 @@ ISRWord::ISRWord ( char *word ) { } void ISRWord::getChunks() { - MMDiskHashTable diskHashTable(util::GetCurrentWorkingDir() + "/constraintSolver/index-test-files/twitter/master.txt", 30, 168); + MMDiskHashTable diskHashTable(util::GetCurrentWorkingDir() + pathToIndex + "master.txt" , 30, 168); string value = diskHashTable.find(term); string chunkInput = ""; for(char val : value) { @@ -51,12 +50,12 @@ Location ISRWord::First ( ) } string currentChunkSeekFileLocation = - util::GetCurrentWorkingDir( ) + "/constraintSolver/index-test-files/twitter/" + to_string( listOfChunks[ currentChunk ] ) + + util::GetCurrentWorkingDir( ) + pathToIndex + to_string( listOfChunks[ currentChunk ] ) + "-seek.txt"; MMDiskHashTable currentChunkSeekFileHashTable = MMDiskHashTable(currentChunkSeekFileLocation, 30, 8); string loc = currentChunkSeekFileHashTable.find(term); string currentChunkFileLocation = - util::GetCurrentWorkingDir( ) + "/constraintSolver/index-test-files/twitter/" + to_string( listOfChunks[ currentChunk ] ) + + util::GetCurrentWorkingDir( ) + pathToIndex + to_string( listOfChunks[ currentChunk ] ) + ".txt"; int currentChunkFile = open( currentChunkFileLocation.c_str( ), O_RDONLY ); ssize_t currentChunkFileSize = FileSize( currentChunkFile ); @@ -118,7 +117,7 @@ size_t ISRWord::getFrequency() { void ISRWord::getWordSeek() { string currentChunkWordSeekFileLocation = - util::GetCurrentWorkingDir( ) + "/constraintSolver/index-test-files/twitter/" + to_string( listOfChunks[ currentChunk ] ) + + util::GetCurrentWorkingDir( ) + pathToIndex + to_string( listOfChunks[ currentChunk ] ) + "-wordseek.txt"; MMDiskHashTable wordSeek = MMDiskHashTable(currentChunkWordSeekFileLocation, 30, 168); string result = wordSeek.find(term); @@ -156,7 +155,7 @@ Location ISRWord::Seek( Location target ) { if(entry.realLocation < target) { best = entry; } else { - string currentChunkFileLocation = util::GetCurrentWorkingDir() + "/constraintSolver/index-test-files/twitter/" + to_string(listOfChunks[currentChunk]) + ".txt"; + string currentChunkFileLocation = util::GetCurrentWorkingDir() + pathToIndex + to_string(listOfChunks[currentChunk]) + ".txt"; int currentChunkFile = open(currentChunkFileLocation.c_str(), O_RDONLY); ssize_t currentChunkFileSize = FileSize(currentChunkFile); currentMemMap = (char*) mmap(nullptr, currentChunkFileSize, PROT_READ, MAP_PRIVATE, currentChunkFile, 0); diff --git a/constraintSolver/tests/ISRWordTests.cpp b/constraintSolver/tests/ISRWordTests.cpp index 9955309cc45541cbae37ff4ead20e03596df5a53..be6c2f632ebdd48a245bc8db4e056a1045ae3fe9 100644 --- a/constraintSolver/tests/ISRWordTests.cpp +++ b/constraintSolver/tests/ISRWordTests.cpp @@ -13,9 +13,9 @@ using namespace std; int main ( ) { - char* query = "iphone"; + //char* query = "iphone"; clock_t start = clock(); - ISRWord queryWord("clock"); + ISRWord queryWord("world"); ISREndDoc endDocs; vector<size_t> locations; vector<DocumentEnding> docEnds;