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

broken seek for isrenddoc (my debugger is broken)

parent 2ff2b7fc
No related branches found
No related tags found
No related merge requests found
Showing
with 65 additions and 1 deletion
......@@ -141,6 +141,13 @@ add_executable(ISRWord-tests
util/stringProcessing.cpp
util/Stemmer.cpp )
add_executable(ISREndDoc-tests
util/util.cpp
util/stringProcessing.cpp
util/Stemmer.cpp
constraintSolver/ISREndDoc.cpp
constraintSolver/tests/ISREndDocTests.cpp)
add_executable(ISROR-tests
util/util.cpp
constraintSolver/ISR.cpp
......
File added
File added
URLTEST 0 → 100755
File added
......@@ -61,6 +61,60 @@ DocumentEnding ISREndDoc::next() {
return currentDoc;
}
// open up current chunk wordseek mem map
// seek all possible keys for doc ending
// check bounds
void ISREndDoc::seek(Location target) {
string key = "=docEnding";
string value = "";
int currentValueChunk = 0;
bool found = false;
pair<size_t, size_t> docEndingWordSeek; // location, offset
string input = "";
while(!found) {
string fileName = util::GetCurrentWorkingDir() +
"/constraintSolver/index-test-files/twitter/" +
to_string(currentChunk) + "-wordseek.txt";
if(0 != access(fileName.c_str(), 0)) {
return;
}
MMDiskHashTable currentWordSeek = MMDiskHashTable(fileName, 30, 168);
value = currentWordSeek.find(key + to_string(currentValueChunk));
cout << "searching through " << value << endl;
for(auto comp : value) {
switch(comp) {
case '<':
docEndingWordSeek = pair<size_t, size_t>();
break;
case '>':
docEndingWordSeek.second = stoll(input);
input = "";
break;
case ',':
if(target < stoll(input) && target > docEndingWordSeek.first) {
found = true;
break;
}
docEndingWordSeek.first = stoll(input);
input = "";
break;
default:
input += comp;
break;
}
if(found) {
string fileName = util::GetCurrentWorkingDir() + "/constraintSolver/index-test-files/twitter/" + to_string(currentChunk) + ".txt";
currentFile = open(fileName.c_str(), O_RDONLY);
memMap = (char*) mmap(nullptr, util::FileSize(currentFile), PROT_READ, MAP_PRIVATE, currentFile, 0);
memMap += docEndingWordSeek.second;
cout << "found" << endl;
return;
}
}
currentChunk++;
}
}
DocumentEnding ISREndDoc::getCurrentDoc() {
return currentDoc;
}
......@@ -24,18 +24,21 @@
class ISREndDoc
{
public:
ISREndDoc();
DocumentEnding next();
void seek(Location target);
DocumentEnding getCurrentDoc();
unsigned GetDocumentLength ( );
unsigned GetTitleLength ( );
string getURL ( );
private:
DocumentEnding currentDoc;
char* memMap;
int currentChunk;
int currentFile;
vector<size_t> getSeekContents();
};
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment