|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.teiid.internal.core.index.Index
public class Index
An Index is used to create an index on the disk, and to make queries. It uses a set of
indexers and a mergeFactory. The index fills an inMemoryIndex up
to it reaches a certain size, and then merges it with a main index on the disk.
The changes are only taken into account by the queries after a merge.
| Field Summary | |
|---|---|
protected InMemoryIndex |
addsIndex
Index in memory, who is merged with mainIndex each times it reaches a certain size. |
protected IndexInput |
addsIndexInput
|
protected static int |
CAN_MERGE
|
protected boolean |
doCache
|
static int |
MAX_FOOTPRINT
Maximum size of the index in memory. |
protected static int |
MERGED
|
protected java.util.Map |
removedInAdds
Files removed form the addsIndex. |
protected java.util.Map |
removedInOld
Files removed form the oldIndex. |
protected int |
state
State of the indexGenerator: addsIndex empty <=> MERGED, or addsIndex not empty <=> CAN_MERGE |
java.lang.String |
toString
String representation of this index. |
| Constructor Summary | |
|---|---|
Index(org.jboss.virtual.VirtualFile f,
boolean reuseExistingFile)
|
|
| Method Summary | |
|---|---|
void |
add(IDocument document,
IIndexer indexer)
Indexes the given document, using the appropriate indexer registered in the indexerRegistry. |
protected boolean |
canMerge()
Returns true if the index in memory is not empty, so merge() can be called to fill the mainIndex with the files and words contained in the addsIndex. |
void |
close()
Closes the index file if open |
void |
dispose()
closes the index file then deletes it. |
void |
empty()
Initialises the indexGenerator. |
protected BlocksIndexInput |
getBlocksIndexInput()
|
BlocksIndexInput |
getCachedInput()
|
org.jboss.virtual.VirtualFile |
getIndexFile()
Returns the index file on the disk. |
int |
getNumDocuments()
Returns the number of documents indexed. |
int |
getNumWords()
Returns the number of unique words indexed. |
java.lang.String |
getPath(int documentNumber)
Returns the path corresponding to a given document number |
java.lang.String |
getResourceFileName()
|
boolean |
hasChanged()
see IIndex.hasChanged |
void |
initialize(boolean reuseExistingFile)
Initialises the indexGenerator. |
protected void |
merge()
Merges the in memory index and the index on the disk, and saves the results on the disk. |
IQueryResult[] |
query(java.lang.String word)
Returns the paths of the documents containing the given word. |
IEntryResult[] |
queryEntries(char[] prefix)
Returns all entries for a given word. |
IEntryResult[] |
queryEntries(char[] prefix,
boolean isCaseSensitive)
Overloaded the method in Index to allow a user to specify if the query should be case sensitive. |
IEntryResult[] |
queryEntriesMatching(char[] prefix,
boolean isCaseSensitive)
Overloaded the method in Index to allow a user to specify if the query should be case sensitive. |
IQueryResult[] |
queryInDocumentNames(java.lang.String word)
Returns the paths of the documents whose names contain the given word. |
IQueryResult[] |
queryPrefix(char[] prefix)
Returns the paths of the documents containing the given word prefix. |
protected void |
remove(IndexedFile file,
int index)
Removes the given document from the given index (MergeFactory.ADDS_INDEX for the in memory index, MergeFactory.OLD_INDEX for the index on the disk). |
void |
remove(java.lang.String documentName)
Removes the corresponding document from the index. |
void |
save()
Saves the index on the disk. |
void |
setCachedInput(BlocksIndexInput theCachedInput)
|
void |
setDoCache(boolean theDoCache)
sets a boolean indicating the index file will be cached and should remain open and in-memory |
protected boolean |
timeToMerge()
Returns true if the in memory index reaches a critical size, to merge it with the index on the disk. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_FOOTPRINT
protected InMemoryIndex addsIndex
protected IndexInput addsIndexInput
protected int state
protected java.util.Map removedInAdds
protected java.util.Map removedInOld
protected static final int CAN_MERGE
protected static final int MERGED
protected boolean doCache
public java.lang.String toString
| Constructor Detail |
|---|
public Index(org.jboss.virtual.VirtualFile f,
boolean reuseExistingFile)
throws java.io.IOException
java.io.IOException| Method Detail |
|---|
public void add(IDocument document,
IIndexer indexer)
throws java.io.IOException
add in interface IIndexjava.io.IOExceptionprotected boolean canMerge()
public void empty()
throws java.io.IOException
empty in interface IIndexjava.io.IOExceptionpublic org.jboss.virtual.VirtualFile getIndexFile()
IIndex
getIndexFile in interface IIndexIIndex.getIndexFile()
public int getNumDocuments()
throws java.io.IOException
IIndex
getNumDocuments in interface IIndexjava.io.IOExceptionIIndex.getNumDocuments()
public int getNumWords()
throws java.io.IOException
IIndex
getNumWords in interface IIndexjava.io.IOExceptionIIndex.getNumWords()
public java.lang.String getPath(int documentNumber)
throws java.io.IOException
getPath in interface IIndexjava.io.IOExceptionpublic boolean hasChanged()
hasChanged in interface IIndex
public void initialize(boolean reuseExistingFile)
throws java.io.IOException
java.io.IOException
protected void merge()
throws java.io.IOException
java.io.IOException
public IQueryResult[] query(java.lang.String word)
throws java.io.IOException
IIndex
query in interface IIndexjava.io.IOExceptionIIndex.query(java.lang.String)
public IEntryResult[] queryEntries(char[] prefix)
throws java.io.IOException
IIndex
queryEntries in interface IIndexjava.io.IOException
public IQueryResult[] queryInDocumentNames(java.lang.String word)
throws java.io.IOException
IIndex
queryInDocumentNames in interface IIndexjava.io.IOExceptionIIndex.queryInDocumentNames(java.lang.String)
public IQueryResult[] queryPrefix(char[] prefix)
throws java.io.IOException
IIndex
queryPrefix in interface IIndexjava.io.IOExceptionIIndex.queryPrefix(char[])
public IEntryResult[] queryEntriesMatching(char[] prefix,
boolean isCaseSensitive)
throws java.io.IOException
java.io.IOException
public IEntryResult[] queryEntries(char[] prefix,
boolean isCaseSensitive)
throws java.io.IOException
java.io.IOException
public void remove(java.lang.String documentName)
throws java.io.IOException
IIndex
remove in interface IIndexjava.io.IOExceptionIIndex.remove(java.lang.String)
protected void remove(IndexedFile file,
int index)
throws java.io.IOException
java.io.IOException
public void save()
throws java.io.IOException
IIndex
save in interface IIndexjava.io.IOExceptionIIndex.save()protected BlocksIndexInput getBlocksIndexInput()
public void close()
IIndex
close in interface IIndexpublic void dispose()
IIndex
dispose in interface IIndexprotected boolean timeToMerge()
public java.lang.String toString()
toString in class java.lang.Objectpublic void setDoCache(boolean theDoCache)
IIndex
setDoCache in interface IIndexpublic BlocksIndexInput getCachedInput()
public void setCachedInput(BlocksIndexInput theCachedInput)
public java.lang.String getResourceFileName()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||