public class IndexSummary extends Object
| Modifier and Type | Field and Description |
|---|---|
protected ArrayList |
firstFilesInBlocks
First file for each block.
|
protected boolean |
firstWordAdded |
protected int |
firstWordBlockNum |
protected ArrayList |
firstWordsInBlocks
First word for each block.
|
protected int |
numFiles
Number of files in the index.
|
protected int |
numWords
Number of words in the index.
|
| Constructor and Description |
|---|
IndexSummary() |
| Modifier and Type | Method and Description |
|---|---|
void |
addFirstFileInBlock(IndexedFile indexedFile,
int blockNum)
Adds the given file as the first file for the given Block number.
|
void |
addFirstWordInBlock(char[] word,
int blockNum)
Adds the given word as the first word for the given Block number.
|
int[] |
getAllBlockNums()
Returns the numbers of all the blocks
|
int |
getBlockNum(int blockLocation) |
int |
getBlockNumForFileNum(int fileNum)
Returns the number of the Block containing the file with the given number.
|
int |
getBlockNumForWord(char[] word)
Returns the number of the Block containing the given word.
|
int[] |
getBlockNumsForPrefix(char[] prefix) |
int |
getFirstBlockLocationForPrefix(char[] prefix) |
int |
getFirstWordBlockNum()
Returns the number of the first IndexBlock (containing words).
|
int |
getNextBlockLocationForPrefix(char[] prefix,
int blockLoc)
Blocks are contiguous, so the next one is a potential candidate if its first word starts with
the given prefix
|
int |
getNumFiles()
Returns the number of files contained in the index.
|
int |
getNumWords()
Returns the number of words contained in the index.
|
void |
read(RandomAccessFile raf)
Loads the summary in memory.
|
void |
setNumFiles(int numFiles)
Sets the number of files of the index.
|
void |
setNumWords(int numWords)
Sets the number of words of the index.
|
void |
write(RandomAccessFile raf)
Saves the summary on the disk.
|
protected ArrayList firstFilesInBlocks
protected ArrayList firstWordsInBlocks
protected int numFiles
protected int numWords
protected int firstWordBlockNum
protected boolean firstWordAdded
public void addFirstFileInBlock(IndexedFile indexedFile, int blockNum)
public void addFirstWordInBlock(char[] word,
int blockNum)
public int[] getAllBlockNums()
public int getBlockNum(int blockLocation)
public int getBlockNumForFileNum(int fileNum)
public int getBlockNumForWord(char[] word)
public int[] getBlockNumsForPrefix(char[] prefix)
public int getFirstBlockLocationForPrefix(char[] prefix)
public int getFirstWordBlockNum()
public int getNextBlockLocationForPrefix(char[] prefix,
int blockLoc)
public int getNumFiles()
public int getNumWords()
public void read(RandomAccessFile raf) throws IOException
IOExceptionpublic void setNumFiles(int numFiles)
public void setNumWords(int numWords)
public void write(RandomAccessFile raf) throws IOException
IOExceptionCopyright © 2020. All rights reserved.