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

no need for words in our index /w a seek dictionary

parent eeae8bec
No related branches found
No related tags found
No related merge requests found
...@@ -85,9 +85,9 @@ void Indexer::save() { ...@@ -85,9 +85,9 @@ void Indexer::save() {
} else { } else {
seeker[word.first] = seekOffset; seeker[word.first] = seekOffset;
} }
string wordBreak = word.first + "\n"; // string wordBreak = word.first + "\n";
write(file, wordBreak.c_str(), strlen(wordBreak.c_str())); // write(file, wordBreak.c_str(), strlen(wordBreak.c_str()));
seekOffset += strlen(wordBreak.c_str()); // seekOffset += strlen(wordBreak.c_str());
for(auto location : word.second) { for(auto location : word.second) {
string locationSpace = to_string(location) + " "; string locationSpace = to_string(location) + " ";
write(file, locationSpace.c_str(), strlen(locationSpace.c_str())); write(file, locationSpace.c_str(), strlen(locationSpace.c_str()));
......
...@@ -10,9 +10,9 @@ using namespace std; ...@@ -10,9 +10,9 @@ using namespace std;
int main() { int main() {
int index1 = open("index0.txt", O_CREAT|O_RDWR, S_IRWXU); int index1 = open("index0.txt", O_CREAT|O_RDWR, S_IRWXU);
lseek(index1, 129545, SEEK_SET); lseek(index1, 129522, SEEK_SET);
char buffer[10]; char buffer[10];
if(read(index1, buffer, 20) != 20) { if(read(index1, buffer, 10) != 10) {
cout << "ERROR" << endl; cout << "ERROR" << endl;
} }
cout << buffer << endl; cout << buffer << endl;
......
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