VIBE v5.1.6
Search Engine
Loading...
Searching...
No Matches
edu.usfca.cs272.ThreadSafeInvertedIndex Class Reference
Inheritance diagram for edu.usfca.cs272.ThreadSafeInvertedIndex:
edu.usfca.cs272.InvertedIndex

Public Member Functions

 ThreadSafeInvertedIndex ()
 
Set< String > getWords ()
 
Set< Integer > getPositions (String word, String location)
 
Set< String > getLocations (String word)
 
boolean hasCount (String location)
 
boolean hasLocation (String word, String location)
 
boolean hasPosition (String word, String location, int position)
 
Map< String, Integer > getCounts ()
 
boolean add (String stem, String path, int location)
 
boolean addAll (String path, Collection< String > stems)
 
boolean addIndex (InvertedIndex invertedIndex)
 
boolean isEmpty ()
 
int size ()
 
int sizeOfCounts ()
 
int numOfLocations (String word)
 
int numOfPositions (String word, String location)
 
boolean hasWord (String word)
 
ArrayList< ScoreexactSearch (Set< String > queries)
 
ArrayList< ScorepartialSearch (Set< String > queries)
 
void toJson (Path output) throws IOException
 
String toString ()
 
- Public Member Functions inherited from edu.usfca.cs272.InvertedIndex
 InvertedIndex ()
 
ArrayList< Scoresearch (Set< String > queries, boolean partial)
 

Detailed Description

Thread-safe version of the InvertedIndex.

Author
Ravneet Singh Bhatia
Version
Spring 2024

Constructor & Destructor Documentation

◆ ThreadSafeInvertedIndex()

edu.usfca.cs272.ThreadSafeInvertedIndex.ThreadSafeInvertedIndex ( )

Creates a new thread-safe inverted index.

Member Function Documentation

◆ add()

boolean edu.usfca.cs272.ThreadSafeInvertedIndex.add ( String stem,
String path,
int location )

adds a stem to the index. updates the count after adding the stem to the index.

Parameters
stemword stem
pathfile path
locationindex in stemList
Returns
true if added successfully.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ addAll()

boolean edu.usfca.cs272.ThreadSafeInvertedIndex.addAll ( String path,
Collection< String > stems )

Add a collection of stems to Index.

Parameters
pathPath of file.
stemsCollection of stems
Returns
true if successful.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ addIndex()

boolean edu.usfca.cs272.ThreadSafeInvertedIndex.addIndex ( InvertedIndex other)

Copies data from another inverted index into this index.

Parameters
othera different inverted index
Returns
true if the add is successful.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ exactSearch()

ArrayList< Score > edu.usfca.cs272.ThreadSafeInvertedIndex.exactSearch ( Set< String > queries)

Performs exact search on a set of queries

Parameters
queriesset of queries.
Returns
ArrayList of Scores.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ getCounts()

Map< String, Integer > edu.usfca.cs272.ThreadSafeInvertedIndex.getCounts ( )

Returns unmodifiable map of files and their stem counts.

Returns
unmodifiable map of files and their stem counts.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ getLocations()

Set< String > edu.usfca.cs272.ThreadSafeInvertedIndex.getLocations ( String word)

returns the locations in which a word occurs

Parameters
wordstem to be searched
Returns
locations.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ getPositions()

Set< Integer > edu.usfca.cs272.ThreadSafeInvertedIndex.getPositions ( String word,
String location )

Returns unmodifiable map where key is file path value is location of word.

Parameters
wordkey in the index.
locationthe file in which word is located.
Returns
unmodifiable map where key is file path value is location of word.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ getWords()

Set< String > edu.usfca.cs272.ThreadSafeInvertedIndex.getWords ( )

Returns unmodifiable set of keys in the index.

Returns
unmodifiable set of keys in the index.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ hasCount()

boolean edu.usfca.cs272.ThreadSafeInvertedIndex.hasCount ( String location)

checks if stem counts for a location is present.

Parameters
locationpath of file.
Returns
true if there is a stem count for the location.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ hasLocation()

boolean edu.usfca.cs272.ThreadSafeInvertedIndex.hasLocation ( String word,
String location )

checks if the index has a location for the word.

Parameters
wordstem in the index.
locationlocation of the stem.
Returns
true if the stem has that location. false if the word or location is not in the index.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ hasPosition()

boolean edu.usfca.cs272.ThreadSafeInvertedIndex.hasPosition ( String word,
String location,
int position )

Checks to see if a word is present in location at specified position

Parameters
wordstem to be checked
locationfile path
positionposition in file to be checked.
Returns
true if the word is found in the location at specified location.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ hasWord()

boolean edu.usfca.cs272.ThreadSafeInvertedIndex.hasWord ( String word)

checks if word is in the index or not.

Parameters
wordstem to be looked up
Returns
true if word is in the index.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ isEmpty()

boolean edu.usfca.cs272.ThreadSafeInvertedIndex.isEmpty ( )

Returns true if index is empty.

Returns
true if index is empty.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ numOfLocations()

int edu.usfca.cs272.ThreadSafeInvertedIndex.numOfLocations ( String word)

Returns the number of locations where a word occurs.

Parameters
wordstem to be searched.
Returns
the number of locations where a word occurs.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ numOfPositions()

int edu.usfca.cs272.ThreadSafeInvertedIndex.numOfPositions ( String word,
String location )

Returns the number of positions where a word occurs in a location.

Parameters
wordstem to be searched.
locationfile path.
Returns
the number of positions where the word occurs in location.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ partialSearch()

ArrayList< Score > edu.usfca.cs272.ThreadSafeInvertedIndex.partialSearch ( Set< String > queries)

Performs partial search on index

Parameters
queriesset of queries
Returns
ArrayList of Scores

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ size()

int edu.usfca.cs272.ThreadSafeInvertedIndex.size ( )

Returns the number of stems in the index.

Returns
the number of stems in the index.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ sizeOfCounts()

int edu.usfca.cs272.ThreadSafeInvertedIndex.sizeOfCounts ( )

Returns the number of locations for which there is a stem count.

Returns
the number of locations for which there is a stem count.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ toJson()

void edu.usfca.cs272.ThreadSafeInvertedIndex.toJson ( Path output) throws IOException

writes index in pretty Json to output file.

Parameters
outputPath of output file.
Exceptions
IOExceptionif path is invalid.

Reimplemented from edu.usfca.cs272.InvertedIndex.

◆ toString()

String edu.usfca.cs272.ThreadSafeInvertedIndex.toString ( )

Returns Inverted Index in pretty Json.

Returns
Inverted Index in pretty Json.

Reimplemented from edu.usfca.cs272.InvertedIndex.


The documentation for this class was generated from the following file: