Skip to content
Snippets Groups Projects
Commit 321f73d2 authored by yangni's avatar yangni
Browse files

implementation details including isrs

parent a0714c14
No related branches found
No related tags found
1 merge request!1Add makefile for everyone and tests for the indexer
//
// Created by nick on 2/6/18.
//
#include "IndexStreamReader.h"
IndexStreamReader::IndexStreamReader(string word) {
this->word = word;
}
int IndexStreamReader::first() {
}
int IndexStreamReader::last() {
}
int IndexStreamReader::next(int location) {
}
\ No newline at end of file
//
// Created by nick on 2/6/18.
//
#ifndef EECS398_SEARCH_INDEXSTREAMREADER_H
#define EECS398_SEARCH_INDEXSTREAMREADER_H
#include <iostream>
using namespace std;
class IndexStreamReader {
public:
int first();
int last();
int next(int location);
private:
IndexStreamReader(string word);
string word;
};
#endif //EECS398_SEARCH_INDEXSTREAMREADER_H
#include "Indexer.h" #include "Indexer.h"
Indexer::Indexer() { Indexer::Indexer() {
} }
void Index::run() { void Indexer::run() {
while(!pointersToDirectories.empty()) { while(pointerToDictionaries.Size() != 0) {
hashtable<string, vector<int>>* dicitonary = pointersToDirectories.pop(); unordered_map<string, vector<int>>* dictionary = pointerToDictionaries.Pop();
for(iterator it : dicitonary) { for(auto it : *dictionary) {
open/create it->first file; for(auto location : it.second) {
for(int num : it->second) { cout << location << endl;
it->first.append(num + currentidcount)
} }
save and close it->first
} }
} }
} }
\ No newline at end of file
#include "../ProducerConsumerQueue.h"
#include "../ProducerConsumerQueue.cpp"
#include <unordered_map>
#include <vector>
#include <iostream>
/* /*
Objective: Pulls small dictionaries from the parser and merges them into the Objective: Pulls small dictionaries from the parser and merges them into the
...@@ -5,9 +11,12 @@ master index. ...@@ -5,9 +11,12 @@ master index.
*/ */
using namespace std;
class Indexer { class Indexer {
public: public:
Indexer(); Indexer();
void run(); void run();
private: ProducerConsumerQueue<unordered_map<string, vector<int> >*> pointerToDictionaries;
private:
}; };
\ No newline at end of file
//
// Created by nick on 2/6/18.
//
#include <iostream>
#include <thread>
#include "Indexer.h"
using namespace std;
int main() {
Indexer indexer = Indexer();
unordered_map<string, vector<int>> test1;
test1["cat"] = { 12, 15, 17 };
test1["dog"] = { 1, 5, 15 };
indexer.pointerToDictionaries.Push(&test1);
indexer.run();
}
\ No newline at end of file
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