Class IndexSummary


  • public class IndexSummary
    extends Object
    An indexSummary is used when saving an index into a BlocksIndexOuput or reading it from a BlocksIndexInput. It contains basic informations about an index: first files/words in each block, number of files/words.
    • Field Detail

      • firstFilesInBlocks

        protected ArrayList firstFilesInBlocks
        First file for each block.
      • firstWordsInBlocks

        protected ArrayList firstWordsInBlocks
        First word for each block.
      • numFiles

        protected int numFiles
        Number of files in the index.
      • numWords

        protected int numWords
        Number of words in the index.
      • firstWordBlockNum

        protected int firstWordBlockNum
      • firstWordAdded

        protected boolean firstWordAdded
    • Constructor Detail

      • IndexSummary

        public IndexSummary()
    • Method Detail

      • addFirstFileInBlock

        public void addFirstFileInBlock​(IndexedFile indexedFile,
                                        int blockNum)
        Adds the given file as the first file for the given Block number.
      • addFirstWordInBlock

        public void addFirstWordInBlock​(char[] word,
                                        int blockNum)
        Adds the given word as the first word for the given Block number.
      • getAllBlockNums

        public int[] getAllBlockNums()
        Returns the numbers of all the blocks
      • getBlockNum

        public int getBlockNum​(int blockLocation)
      • getBlockNumForFileNum

        public int getBlockNumForFileNum​(int fileNum)
        Returns the number of the Block containing the file with the given number.
      • getBlockNumForWord

        public int getBlockNumForWord​(char[] word)
        Returns the number of the Block containing the given word.
      • getBlockNumsForPrefix

        public int[] getBlockNumsForPrefix​(char[] prefix)
      • getFirstBlockLocationForPrefix

        public int getFirstBlockLocationForPrefix​(char[] prefix)
      • getFirstWordBlockNum

        public int getFirstWordBlockNum()
        Returns the number of the first IndexBlock (containing words).
      • getNextBlockLocationForPrefix

        public 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
      • getNumFiles

        public int getNumFiles()
        Returns the number of files contained in the index.
      • getNumWords

        public int getNumWords()
        Returns the number of words contained in the index.
      • setNumFiles

        public void setNumFiles​(int numFiles)
        Sets the number of files of the index.
      • setNumWords

        public void setNumWords​(int numWords)
        Sets the number of words of the index.