Skip to content
Snippets Groups Projects
Commit 3fa996e1 authored by benbergk's avatar benbergk
Browse files

made ISRWord inherit from base ISR

parent 9203235a
No related branches found
No related tags found
No related merge requests found
......@@ -140,8 +140,6 @@ add_executable(ISRWord-tests
util/stringProcessing.cpp
util/Stemmer.cpp )
add_executable(ISROR-tests
util/util.cpp
constraintSolver/ISR.cpp
......
......@@ -19,29 +19,27 @@ class ISR
{
public:
//
ISR *DocumentEnd;
// Returns
virtual Location First ( );
virtual Location First ( ) = 0;
//Returns next post of a word given current location
virtual Location Next ( );
virtual Location Next ( ) = 0;
//Calls seek onto one past the current end doc location
//Return first instance of word at new document
virtual Location NextDocument ( );
virtual Location NextDocument ( ) = 0;
//Returns first instance of word after target location
virtual Location Seek ( Location target );
virtual Location Seek ( Location target ) = 0;
//Returns the location of the end of the document
virtual Location GetEndDocument ( );
virtual Location GetEndDocument ( ) = 0;
Location currentLocation;
ISR *DocumentEnd;
};
......
......@@ -21,23 +21,11 @@ Location ISROr::GetEndLocation ( )
}
Location ISROr::Seek ( Location target )
Location ISROr::First()
{
// Seek all the ISRs to the first occurrence beginning at// the target location. Return null if there is no match.
// The document is the document containing the nearest term.
//seek past target locations,
//seek all terms in or past starting location, take the ones that nears
//the document that the nearest term is in is the document ur in
//updates private members
return 1;
//Fixme
Location x;
return x;
}
/*
......@@ -48,21 +36,52 @@ Location ISROr::Next ( )
Location nearestEnd = this->nearestTerm->GetEndDocument( );
for(auto Term : Terms)
{
{
Location newSeekLocation = Term->Seek( nearestEnd + 1 );
if ( newSeekLocation < nearestStartLocation )
{
{
nearestStartLocation = newSeekLocation;
nearestTerm = Term;
}
}
}
return this->nearestTerm->currentLocation;
}
Location ISROr::NextDocument()
{
//Fixme
Location x;
return x;
}
Location ISROr::Seek ( Location target )
{
// Seek all the ISRs to the first occurrence beginning at// the target location. Return null if there is no match.
// The document is the document containing the nearest term.
//seek past target locations,
//seek all terms in or past starting location, take the ones that nears
//the document that the nearest term is in is the document ur in
//updates private members
return 1;
}
Location ISROr::GetEndDocument()
{
//Fixme
Location x;
return x;
}
/*
ISR *ISROr::GetCurrentEndDoc ( )
{
......
......@@ -15,28 +15,17 @@ public:
vector<ISR*>Terms;
unsigned NumberOfTerms;
Location First ( ) override;
Location Next ( ) override;
Location NextDocument ( ) override;
Location Seek ( Location target ) override;
Location GetEndDocument ( ) override;
Location GetCurrentLocation();
Location GetStartLocation ( );
Location GetEndLocation ( );
Location Seek ( Location target );
//ISR *GetCurrentEndDoc ( );
Location First ( ) ;
Location Next ( );
//{ Do a next on the nearest term, then return// the new nearest match.}
//next on nearest term, return nearest temr
Location NextDocument ( );
//
// { Seek all the ISRs to the first occurrence just past the end of this document.returnSeek( DocumentEnd->GetEndLocation( ) + 1 );}
ISROr ( vector<ISR * > InputTerms ) : Terms( InputTerms )
{
......
......@@ -8,8 +8,12 @@ size_t FileSize(int f) {
return fileInfo.st_size;
}
ISRWord::ISRWord ( char *word ) : term( word )
ISRWord::ISRWord ( char *word )
{
term = new char[strlen(word)];
strcpy(term, word);
getChunks( );
currentChunk = 0;
currentLocation = First( );
......@@ -18,8 +22,15 @@ ISRWord::ISRWord ( char *word ) : term( word )
// put into util file
vector<size_t> ISRWord::getSeekContents(string fileName) {
int file = open(fileName.c_str(), O_RDONLY);
ssize_t fileSize = FileSize(file);
vector<size_t> contents;
vector<size_t> contents;
if(file == -1)
{
cerr << "Was not able to open master index file";
exit(1);
}
ssize_t fileSize = FileSize(file);
char* memMap = (char*) mmap(nullptr, fileSize, PROT_READ, MAP_PRIVATE, file, 0);
......@@ -207,3 +218,18 @@ Location ISRWord::Seek( Location target ) {
}
}
Location ISRWord::NextDocument()
{
//FixMe
Location x;
return x;
}
Location ISRWord::GetEndDocument()
{
//Fixme
Location x;
return x;
}
#pragma once
//#include "ISR.h"
#include "ISR.h"
#include <iostream>
#include <vector>
#include <fcntl.h>
......@@ -12,7 +12,7 @@
#include <sys/types.h>
#include "WordSeek.h"
#include "../util/util.h"
#include "ISR.h"
using namespace std;
......@@ -24,26 +24,21 @@ class ISRWord : public ISR
public:
ISRWord ( char *word );
Location First ( ) override;
Location Next ( ) override;
Location NextDocument ( ) override;
Location Seek ( Location target ) override;
Location GetEndDocument ( ) override;
vector< size_t > getSeekContents ( string fileName );
unsigned GetDocumentCount ( );
unsigned GetNumberOfOccurrences ( );
// ISR* DocumentEnd;
Location First ( );
Location Next ( );
Location nextDocument ( );
Location Seek ( Location target );
// ISR *GetDocumentISR( );
Location GetEndDocument ( );
Location currentLocation;
char *term;
char *masterIndex;
vector< size_t > listOfChunks;
......
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