public class Index
extends java.lang.Object
Index maps document names to their referenced words in various categories.
Queries can search a single category or several at the same time.
Indexes are not synchronized structures and should only be queried/updated one at a time.| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
containerPath |
protected DiskIndex |
diskIndex |
protected MemoryIndex |
memoryIndex |
ReadWriteMonitor |
monitor |
char |
separator |
| Constructor and Description |
|---|
Index(IndexLocation location,
java.lang.String containerPath,
boolean reuseExistingFile) |
| Modifier and Type | Method and Description |
|---|---|
void |
addIndexEntry(char[] category,
char[] key,
java.lang.String containerRelativePath) |
java.lang.String |
containerRelativePath(java.lang.String documentPath) |
java.io.File |
getIndexFile() |
long |
getIndexLastModified() |
IndexLocation |
getIndexLocation() |
boolean |
hasChanged() |
boolean |
isIndexForJar() |
static boolean |
isMatch(char[] pattern,
char[] word,
int matchRule) |
EntryResult[] |
query(char[][] categories,
char[] key,
int matchRule)
Returns the entries containing the given key in a group of categories, or null if no matches are found.
|
java.lang.String[] |
queryDocumentNames(java.lang.String substring)
Returns the document names that contain the given substring, if null then returns all of them.
|
void |
remove(java.lang.String containerRelativePath) |
void |
reset()
Reset memory and disk indexes.
|
void |
save() |
void |
startQuery() |
void |
stopQuery() |
java.lang.String |
toString() |
public java.lang.String containerPath
public ReadWriteMonitor monitor
public char separator
protected DiskIndex diskIndex
protected MemoryIndex memoryIndex
public Index(IndexLocation location, java.lang.String containerPath, boolean reuseExistingFile) throws java.io.IOException
java.io.IOExceptionpublic static boolean isMatch(char[] pattern,
char[] word,
int matchRule)
public void addIndexEntry(char[] category,
char[] key,
java.lang.String containerRelativePath)
public java.lang.String containerRelativePath(java.lang.String documentPath)
public java.io.File getIndexFile()
public IndexLocation getIndexLocation()
public long getIndexLastModified()
public boolean hasChanged()
public EntryResult[] query(char[][] categories, char[] key, int matchRule) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String[] queryDocumentNames(java.lang.String substring)
throws java.io.IOException
java.io.IOExceptionpublic void remove(java.lang.String containerRelativePath)
public void reset()
throws java.io.IOException
java.io.IOExceptionpublic void save()
throws java.io.IOException
java.io.IOExceptionpublic void startQuery()
public void stopQuery()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean isIndexForJar()