org.teiid.internal.core.index
Class IndexSummary

java.lang.Object
  extended by org.teiid.internal.core.index.IndexSummary

public class IndexSummary
extends java.lang.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 Summary
protected  java.util.ArrayList firstFilesInBlocks
          First file for each block.
protected  boolean firstWordAdded
           
protected  int firstWordBlockNum
           
protected  java.util.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 Summary
IndexSummary()
           
 
Method Summary
 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(java.io.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(java.io.RandomAccessFile raf)
          Saves the summary on the disk.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

firstFilesInBlocks

protected java.util.ArrayList firstFilesInBlocks
First file for each block.


firstWordsInBlocks

protected java.util.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.


read

public void read(java.io.RandomAccessFile raf)
          throws java.io.IOException
Loads the summary in memory.

Throws:
java.io.IOException

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.


write

public void write(java.io.RandomAccessFile raf)
           throws java.io.IOException
Saves the summary on the disk.

Throws:
java.io.IOException


Copyright © 2011. All Rights Reserved.