From 1c16250a85fb56d6d8dcc581549cca084fe2ec49 Mon Sep 17 00:00:00 2001
From: jsclose <jsclose@umich.edu>
Date: Thu, 15 Mar 2018 18:46:10 -0400
Subject: [PATCH] working with nick/ben on determining implementation of isr +
 constrain solver

---
 constraintSolver/ISR.h       | 25 +++++++++++---
 constraintSolver/ISROr.h     | 16 ++++++---
 constraintSolver/ISRWord.cpp | 65 ++++++++++++++++++++++++++++++++++++
 constraintSolver/ISRWord.h   | 39 +++++++++++++++++++++-
 constraintSolver/Post.h      |  6 ++--
 5 files changed, 137 insertions(+), 14 deletions(-)

diff --git a/constraintSolver/ISR.h b/constraintSolver/ISR.h
index eb2ad27..bc40441 100644
--- a/constraintSolver/ISR.h
+++ b/constraintSolver/ISR.h
@@ -12,13 +12,28 @@ class ISR
 	public:
 		//
 		ISR* DocumentEnd;
-		virtual Post* Next( );
-		virtual Post* NextDocument( );
-		virtual Post* Seek( Location target);
-		virtual Location GetStartLocation( );
-		virtual Location GetEndLocation( );
+		// Returns
+		virtual Location First( );
+
+		//Returns next post of a word given current location
+		virtual Location Next( );
+
+
+		//Calls seek onto one past the current end doc location
+		//Return first instance of word at new document
+		virtual Location NextDocument( );
+		//Returns first instance of word after target location
+		virtual Location Seek( Location target);
 		virtual ISR *GetDocumentISR( );
 
+		//Returns the location of the end of the document
+		virtual Location GetEndDocument( );
+
+
+		Location currentLocation;
+
+
+
 
 	};
 
diff --git a/constraintSolver/ISROr.h b/constraintSolver/ISROr.h
index 5c1889b..fd4f5bf 100644
--- a/constraintSolver/ISROr.h
+++ b/constraintSolver/ISROr.h
@@ -17,13 +17,19 @@ class ISROr : publicISR
 		unsigned NumberOfTerms;
 		Location GetStartLocation( );//{return nearestStartLocation;}
 		Location GetEndLocation( );// {return nearestEndLocation;}
-		Post*Seek( Location target);
+		Post* 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.
-		 Post*Next( );//{ Do a next on the nearest term, then return// the new nearest match.}
-
-		Post*NextDocument( );
-		//{ Seek all the ISRs to the first occurrence just past the end of this document.returnSeek( DocumentEnd->GetEndLocation( ) + 1 );}
+			//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
+		Post* Next( );
+		//{ Do a next on the nearest term, then return// the new nearest match.}
+		//next on nearest term, return nearest temr
+		Post* NextDocument( );
+		//
+		// 	{ Seek all the ISRs to the first occurrence just past the end of this document.returnSeek( DocumentEnd->GetEndLocation( ) + 1 );}
 	private:
 		unsigned nearestTerm;
 		// nearStartLocation and nearestEndLocation are// the start and end of the nearestTerm.
diff --git a/constraintSolver/ISRWord.cpp b/constraintSolver/ISRWord.cpp
index 4d4e7ec..d042058 100644
--- a/constraintSolver/ISRWord.cpp
+++ b/constraintSolver/ISRWord.cpp
@@ -3,3 +3,68 @@
 //
 
 #include "ISRWord.h"
+
+
+
+void ISRWord::getChunks()
+	{
+	//Memory map  master index file
+
+	//Binary search thru memory map until you find word
+
+	//Get list of chunks that you need
+
+	//set current chunk
+
+
+
+	}
+
+
+Location ISRWord::First()
+	{
+
+
+		//Go to current chunk
+
+		//Look in seek dictionary for chunk (mem map, binary search)
+
+		//Have offset into chunk, find post seek to post, return value
+		//update ISR currentLocation
+		//set current memory map
+		//returns offset into corpus
+
+
+
+	}
+//returns next absolute location in corpus
+
+Location ISRWord::Next()
+	{
+
+	//looks at memory map
+
+	//if new line ( end of current list for that file
+
+	//move to next chunk, update chunk
+	//find new offset, return first location
+
+
+	//else
+	//find way to increment to next delta
+	//return new location
+
+
+
+	}
+
+Location ISRWord::Seek( Location target )
+	{
+	//look thru each chunk
+	//check if absolute position at offset in chunk is less then chunk,
+	//check seek lookup table to find if offset+absulte is bigger than target
+		//if so, set location to that big chunk
+	//go to next chunk
+
+	}
+
diff --git a/constraintSolver/ISRWord.h b/constraintSolver/ISRWord.h
index 4c807ce..a7724a8 100644
--- a/constraintSolver/ISRWord.h
+++ b/constraintSolver/ISRWord.h
@@ -13,8 +13,45 @@ class ISRWord : ISR
 	public:
 		unsigned GetDocumentCount( );
 		unsigned GetNumberOfOccurrences( );
-		virtual Post *GetCurrentPost( );
+		ISR* DocumentEnd;
+		// Returns
+		virtual Location First( );
 
+		//Returns next post of a word given current location
+		virtual Location Next( );
+
+		//Calls seek onto one past the current end doc location
+		//Return first instance of word at new document
+		virtual Location NextDocument( );
+		//Returns first instance of word after target location
+		virtual Location Seek( Location target);
+
+
+		virtual ISR *GetDocumentISR( );
+
+		//Returns the location of the end of the document
+		virtual Location GetEndDocument( );
+
+		//Current location of word on disk
+		Location currentLocation;
+		char* term;
+		char* masterIndex;
+		vector<size_t> listOfChunks;
+		size_t currentChunk;
+		char* currentMemMap;
+
+		//set member variables to all of the chunks that occur, update current chunk
+		virtual getChunks();
+
+
+
+	ISRWord(char * term_in ) : term( term_in )
+			{
+				getChunks();
+				currentLocation = First();
+
+
+			}
 	};
 
 
diff --git a/constraintSolver/Post.h b/constraintSolver/Post.h
index eed13b5..0cbe3c2 100644
--- a/constraintSolver/Post.h
+++ b/constraintSolver/Post.h
@@ -19,14 +19,14 @@ class Post
 	 	 //What Start / End Location
 		 virtual Location GetStartLocation( );
 		 virtual Location GetEndLocation( );
-		 virtual Attributes GetAttributes( );
+	   virtual Attributes GetAttributes( );
 		//Returns Next next delta
 
 		//TO-DO NICK/ZANE
 		 virtual Post* Next( );
-
+		Location currentLocation;
 		//*why?
-		 virtual ISR* GetIsr( );
+		 //virtual ISR* GetIsr( );
 
 	};
 
-- 
GitLab