From 76386b8312a7a087ac5a18dd308e899aa943eb31 Mon Sep 17 00:00:00 2001 From: Nicholas Yang <parablank@gmail.com> Date: Tue, 20 Mar 2018 15:53:55 -0400 Subject: [PATCH] seek function but not tested --- constraintSolver/ISRWord.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/constraintSolver/ISRWord.cpp b/constraintSolver/ISRWord.cpp index 639b151..a4def3c 100644 --- a/constraintSolver/ISRWord.cpp +++ b/constraintSolver/ISRWord.cpp @@ -170,7 +170,24 @@ Location ISRWord::next() { Location ISRWord::seek( Location target ) { if(!wordSeekLookupTable.empty()) { - + auto best = wordSeekLookupTable.front(); + for(auto entry : wordSeekLookupTable) { + if(entry.realLocation < target) { + best = entry; + } else { + string currentChunkFileLocation = "index-test-files/twitter/index" + 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); + currentMemMap += best.seekOffset; + currentLocation = best.realLocation; + return best.realLocation; + } + } + } else { + while(next() <= target) { + } + return currentLocation; } } -- GitLab