Skip to content
Snippets Groups Projects
Commit ed96f71d authored by Nicholas Yang's avatar Nicholas Yang
Browse files

fixing up more isrword stuff to use mmdht

parent 834ba0da
Branches
No related tags found
No related merge requests found
Showing
with 37 additions and 2 deletions
No preview for this file type
......@@ -18,7 +18,7 @@ ISRWord::ISRWord ( char *word ) {
}
void ISRWord::getChunks() {
MMDiskHashTable diskHashTable(util::GetCurrentWorkingDir() + "/constraintSolver/index-test-files/twitter/index-master.txt", 30, 168);
MMDiskHashTable diskHashTable(util::GetCurrentWorkingDir() + "/constraintSolver/index-test-files/twitter/master.txt", 30, 168);
string value = diskHashTable.find(term);
string chunkInput = "";
for(char val : value) {
......@@ -40,6 +40,11 @@ void ISRWord::getChunks() {
Location ISRWord::First ( )
{
if(listOfChunks.empty()) {
currentLocation = MAX_Location;
return MAX_Location;
}
string currentChunkSeekFileLocation =
util::GetCurrentWorkingDir( ) + "/constraintSolver/index-test-files/twitter/" + to_string( listOfChunks[ currentChunk ] ) +
"-seek.txt";
......@@ -58,6 +63,7 @@ Location ISRWord::First ( )
currentMemMap++;
}
currentMemMap++;
getWordSeek();
return stoll( firstLoc );
}
......@@ -77,7 +83,7 @@ Location ISRWord::Next ( )
currentChunk++;
if(listOfChunks.size( ) <= currentChunk)
{
currentLocation = 9999999999999;
currentLocation = MAX_Location;
return currentLocation;
}
......@@ -101,6 +107,34 @@ Location ISRWord::getCurrentLocation() {
return currentLocation;
}
void ISRWord::getWordSeek() {
string currentChunkWordSeekFileLocation =
util::GetCurrentWorkingDir( ) + "/constraintSolver/index-test-files/twitter/" + to_string( listOfChunks[ currentChunk ] ) +
"-wordseek.txt";
MMDiskHashTable wordSeek = MMDiskHashTable(currentChunkWordSeekFileLocation, 30, 168);
string result = wordSeek.find(term);
WordSeek wordDictionaryEntry;
string token = "";
for(char comp : result) {
switch(comp) {
case '<':
wordDictionaryEntry = WordSeek();
break;
case '>':
wordDictionaryEntry.seekOffset = stoll(token);
wordSeekLookupTable.push_back(wordDictionaryEntry);
token = "";
break;
case ',':
wordDictionaryEntry.realLocation = stoll(token);
token = "";
break;
default:
token += comp;
}
}
}
//look thru each chunk
//check if absolute position at offset in chunk is less then chunk,
//check seek lookup table to find if offset+absulte is bigger than target
......
......@@ -50,6 +50,7 @@ class ISRWord : public ISR
Location getCurrentLocation();
private:
void getWordSeek();
};
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment