org.teiid.internal.core.index
Class InMemoryIndex

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

public class InMemoryIndex
extends Object

This index stores the document names in an ArrayList, and the words in an HashtableOfObjects.


Field Summary
protected  IndexedFileHashedArray files
          List of IndexedFiles = file name + a unique number.
protected  long footprint
          Size of the index.
protected  List<WordEntry> words
          hashtable of WordEntrys = words+numbers of the files they appear in.
 
Constructor Summary
InMemoryIndex()
           
 
Method Summary
 IndexedFile addDocument(IDocument document)
           
protected  void addRef(char[] word, int fileNum)
          Looks if the word already exists in the index and add the fileNum to this word.
 void addRef(IndexedFile indexedFile, char[] word)
           
 long getFootprint()
          Returns the footprint of the index.
 IndexedFile getIndexedFile(String path)
          Returns the indexed file with the given path, or null if such file does not exist.
 int getNumFiles()
           
 int getNumWords()
           
protected  IndexedFile[] getSortedFiles()
          Returns the words contained in the hashtable of words, sorted by alphabetical order.
protected  WordEntry[] getSortedWordEntries()
          Returns the word entries contained in the hashtable of words, sorted by alphabetical order.
 void init()
          Initialises the fields of the index
protected  void save(IndexOutput output)
          Saves the index in the given IndexOutput.
 void save(org.jboss.virtual.VirtualFile file)
          Saves the index in the given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

words

protected List<WordEntry> words
hashtable of WordEntrys = words+numbers of the files they appear in.


files

protected IndexedFileHashedArray files
List of IndexedFiles = file name + a unique number.


footprint

protected long footprint
Size of the index.

Constructor Detail

InMemoryIndex

public InMemoryIndex()
Method Detail

addDocument

public IndexedFile addDocument(IDocument document)

addRef

protected void addRef(char[] word,
                      int fileNum)
Looks if the word already exists in the index and add the fileNum to this word. If the word does not exist, it adds it in the index.


addRef

public void addRef(IndexedFile indexedFile,
                   char[] word)

getFootprint

public long getFootprint()
Returns the footprint of the index.


getIndexedFile

public IndexedFile getIndexedFile(String path)
Returns the indexed file with the given path, or null if such file does not exist.


getNumFiles

public int getNumFiles()
See Also:
IIndex.getNumDocuments()

getNumWords

public int getNumWords()
See Also:
IIndex.getNumWords()

getSortedFiles

protected IndexedFile[] getSortedFiles()
Returns the words contained in the hashtable of words, sorted by alphabetical order.


getSortedWordEntries

protected WordEntry[] getSortedWordEntries()
Returns the word entries contained in the hashtable of words, sorted by alphabetical order.


init

public void init()
Initialises the fields of the index


save

public void save(org.jboss.virtual.VirtualFile file)
          throws IOException
Saves the index in the given file. Structure of the saved Index : - IndexedFiles in sorted order. + example: "c:/com/Test.java 1" "c:/com/UI.java 2" - References with the words in sorted order + example: "classDecl/Test 1" "classDecl/UI 2" "ref/String 1 2"

Throws:
IOException

save

protected void save(IndexOutput output)
             throws IOException
Saves the index in the given IndexOutput. Structure of the saved Index : - IndexedFiles in sorted order. + example: "c:/com/Test.java 1" "c:/com/UI.java 2" - References with the words in sorted order + example: "classDecl/Test 1" "classDecl/UI 2" "ref/String 1 2"

Throws:
IOException


Copyright © 2012. All Rights Reserved.