org.teiid.internal.core.index
Class IndexInput

java.lang.Object
  extended by org.teiid.internal.core.index.IndexInput
Direct Known Subclasses:
BlocksIndexInput, SimpleIndexInput

public abstract class IndexInput
extends java.lang.Object

This class provides an input on an index, after it has been generated. You can access all the files of an index via getNextFile(), getCurrentFile() and moveToNextFile() (idem for the word entries). The usage is the same for every subclass: creation (constructor), opening (the open() method), usage, and closing (the close() method), to release the data source used by this input.


Field Summary
protected  WordEntry currentWordEntry
           
protected  int filePosition
           
protected  int wordPosition
           
 
Constructor Summary
IndexInput()
           
 
Method Summary
abstract  void clearCache()
          clears the cache of this indexInput, if it keeps track of the information already read.
abstract  void close()
          Closes the IndexInput.
abstract  IndexedFile getCurrentFile()
          Returns the current file the indexInput is pointing to in the index.
 WordEntry getCurrentWordEntry()
          Returns the current file the indexInput is pointing to in the index.
 int getFilePosition()
          Returns the position of the current file the input is pointing to in the index.
abstract  IndexedFile getIndexedFile(IDocument document)
          Returns the indexedFile corresponding to the given document in the index the input reads in (e.g.
abstract  IndexedFile getIndexedFile(int fileNum)
          Returns the indexedFile corresponding to the given document number in the index the input reads in, or null if such indexedFile does not exist.
abstract  int getNumFiles()
          Returns the number of files in the index.
abstract  int getNumWords()
          Returns the number of unique words in the index.
abstract  java.lang.Object getSource()
          Returns the Object the input is reading from.
 boolean hasMoreFiles()
          Returns true if the input has not reached the end of the index for the files.
 boolean hasMoreWords()
          Returns true if the input has not reached the end of the index for the files.
 boolean isOpen()
          returns the open state of the index
abstract  void moveToNextFile()
          Moves the pointer on the current file to the next file in the index.
abstract  void moveToNextWordEntry()
          Moves the pointer on the current word to the next file in the index.
abstract  void open()
          Open the Source where the input gets the information from.
abstract  IEntryResult[] queryEntriesPrefixedBy(char[] prefix)
          Returns the list of the files containing the given word in the index.
abstract  IQueryResult[] queryFilesReferringToPrefix(char[] prefix)
           
abstract  IQueryResult[] queryInDocumentNames(java.lang.String word)
          Returns the list of the files whose name contain the given word in the index.
protected abstract  void setFirstFile()
          Set the pointer on the current file to the first file of the index.
protected abstract  void setFirstWord()
          Set the pointer on the current word to the first word of the index.
 void setOpen(boolean state)
          Set the open state of the Index
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filePosition

protected int filePosition

currentWordEntry

protected WordEntry currentWordEntry

wordPosition

protected int wordPosition
Constructor Detail

IndexInput

public IndexInput()
Method Detail

clearCache

public abstract void clearCache()
clears the cache of this indexInput, if it keeps track of the information already read.


close

public abstract void close()
                    throws java.io.IOException
Closes the IndexInput. For example, if the input is on a RandomAccessFile, it calls the close() method of RandomAccessFile.

Throws:
java.io.IOException

getCurrentFile

public abstract IndexedFile getCurrentFile()
                                    throws java.io.IOException
Returns the current file the indexInput is pointing to in the index.

Throws:
java.io.IOException

getCurrentWordEntry

public WordEntry getCurrentWordEntry()
                              throws java.io.IOException
Returns the current file the indexInput is pointing to in the index.

Throws:
java.io.IOException

getFilePosition

public int getFilePosition()
Returns the position of the current file the input is pointing to in the index.


setOpen

public void setOpen(boolean state)
Set the open state of the Index

Since:
5.0

isOpen

public boolean isOpen()
returns the open state of the index

Since:
5.0

getIndexedFile

public abstract IndexedFile getIndexedFile(int fileNum)
                                    throws java.io.IOException
Returns the indexedFile corresponding to the given document number in the index the input reads in, or null if such indexedFile does not exist.

Throws:
java.io.IOException

getIndexedFile

public abstract IndexedFile getIndexedFile(IDocument document)
                                    throws java.io.IOException
Returns the indexedFile corresponding to the given document in the index the input reads in (e.g. the indexedFile with the same path in this index), or null if such indexedFile does not exist.

Throws:
java.io.IOException

getNumFiles

public abstract int getNumFiles()
Returns the number of files in the index.


getNumWords

public abstract int getNumWords()
Returns the number of unique words in the index.


getSource

public abstract java.lang.Object getSource()
Returns the Object the input is reading from. It can be an IIndex, a File, ...


hasMoreFiles

public boolean hasMoreFiles()
Returns true if the input has not reached the end of the index for the files.


hasMoreWords

public boolean hasMoreWords()
Returns true if the input has not reached the end of the index for the files.


moveToNextFile

public abstract void moveToNextFile()
                             throws java.io.IOException
Moves the pointer on the current file to the next file in the index.

Throws:
java.io.IOException

moveToNextWordEntry

public abstract void moveToNextWordEntry()
                                  throws java.io.IOException
Moves the pointer on the current word to the next file in the index.

Throws:
java.io.IOException

open

public abstract void open()
                   throws java.io.IOException
Open the Source where the input gets the information from.

Throws:
java.io.IOException

queryEntriesPrefixedBy

public abstract IEntryResult[] queryEntriesPrefixedBy(char[] prefix)
                                               throws java.io.IOException
Returns the list of the files containing the given word in the index.

Throws:
java.io.IOException

queryFilesReferringToPrefix

public abstract IQueryResult[] queryFilesReferringToPrefix(char[] prefix)
                                                    throws java.io.IOException
Throws:
java.io.IOException

queryInDocumentNames

public abstract IQueryResult[] queryInDocumentNames(java.lang.String word)
                                             throws java.io.IOException
Returns the list of the files whose name contain the given word in the index.

Throws:
java.io.IOException

setFirstFile

protected abstract void setFirstFile()
                              throws java.io.IOException
Set the pointer on the current file to the first file of the index.

Throws:
java.io.IOException

setFirstWord

protected abstract void setFirstWord()
                              throws java.io.IOException
Set the pointer on the current word to the first word of the index.

Throws:
java.io.IOException


Copyright © 2011. All Rights Reserved.