Package org.h2.fulltext
Class FullTextSettings
- java.lang.Object
-
- org.h2.fulltext.FullTextSettings
-
final class FullTextSettings extends java.lang.ObjectThe global settings of a full text search.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.WeakHashMap<java.sql.Connection,SoftValuesHashMap<java.lang.String,java.sql.PreparedStatement>>cacheThe prepared statement cache.private java.util.HashSet<java.lang.String>ignoreListThe set of words not to index (stop words).private java.util.concurrent.ConcurrentHashMap<java.lang.Integer,IndexInfo>indexesThe set of indexes in this database.private booleaninitializedWhether this instance has been initialized.private static java.util.HashMap<java.lang.String,FullTextSettings>SETTINGSThe settings of open indexes.private java.lang.StringwhitespaceCharsThe whitespace characters.private java.util.HashMap<java.lang.String,java.lang.Integer>wordsThe set of words / terms.
-
Constructor Summary
Constructors Modifier Constructor Description privateFullTextSettings()Create a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddIgnored(java.lang.Iterable<java.lang.String> words)Amend set of ignored words(package private) voidaddIndexInfo(IndexInfo index)Add an index.voidaddWord(java.lang.String word, java.lang.Integer id)Register searchable wordvoidclearIgnored()Clear set of ignored wordsvoidclearWordList()Clear set of searchable wordsprotected static voidcloseAll()Close all fulltext settings, freeing up memory.(package private) java.lang.StringconvertWord(java.lang.String word)Convert a word to uppercase.(package private) IndexInfogetIndexInfo(int indexId)Get the index information for the given index id.private static java.lang.StringgetIndexPath(java.sql.Connection conn)Get the file system path.(package private) static FullTextSettingsgetInstance(java.sql.Connection conn)Get or create the fulltext settings for this database.protected java.lang.StringgetWhitespaceChars()java.lang.IntegergetWordId(java.lang.String word)Get id for a searchable wordprotected booleanisInitialized()Get the initialized flag.private static java.lang.StringnormalizeWord(java.lang.String word)(package private) java.sql.PreparedStatementprepare(java.sql.Connection conn, java.lang.String sql)Prepare a statement.protected voidremoveAllIndexes()Remove all indexes from the settings.protected voidremoveIndexInfo(IndexInfo index)Remove an index from the settings.protected voidsetInitialized(boolean b)Set the initialized flag.protected voidsetWhitespaceChars(java.lang.String whitespaceChars)
-
-
-
Field Detail
-
SETTINGS
private static final java.util.HashMap<java.lang.String,FullTextSettings> SETTINGS
The settings of open indexes.
-
initialized
private boolean initialized
Whether this instance has been initialized.
-
ignoreList
private final java.util.HashSet<java.lang.String> ignoreList
The set of words not to index (stop words).
-
words
private final java.util.HashMap<java.lang.String,java.lang.Integer> words
The set of words / terms.
-
indexes
private final java.util.concurrent.ConcurrentHashMap<java.lang.Integer,IndexInfo> indexes
The set of indexes in this database.
-
cache
private final java.util.WeakHashMap<java.sql.Connection,SoftValuesHashMap<java.lang.String,java.sql.PreparedStatement>> cache
The prepared statement cache.
-
whitespaceChars
private java.lang.String whitespaceChars
The whitespace characters.
-
-
Method Detail
-
clearIgnored
public void clearIgnored()
Clear set of ignored words
-
addIgnored
public void addIgnored(java.lang.Iterable<java.lang.String> words)
Amend set of ignored words- Parameters:
words- to add
-
clearWordList
public void clearWordList()
Clear set of searchable words
-
getWordId
public java.lang.Integer getWordId(java.lang.String word)
Get id for a searchable word- Parameters:
word- to find id for- Returns:
- Integer id or null if word is not found
-
addWord
public void addWord(java.lang.String word, java.lang.Integer id)Register searchable word- Parameters:
word- to registerid- to register with
-
getIndexInfo
IndexInfo getIndexInfo(int indexId)
Get the index information for the given index id.- Parameters:
indexId- the index id- Returns:
- the index info
-
addIndexInfo
void addIndexInfo(IndexInfo index)
Add an index.- Parameters:
index- the index
-
convertWord
java.lang.String convertWord(java.lang.String word)
Convert a word to uppercase. This method returns null if the word is in the ignore list.- Parameters:
word- the word to convert and check- Returns:
- the uppercase version of the word or null
-
getInstance
static FullTextSettings getInstance(java.sql.Connection conn) throws java.sql.SQLException
Get or create the fulltext settings for this database.- Parameters:
conn- the connection- Returns:
- the settings
- Throws:
java.sql.SQLException- on failure
-
getIndexPath
private static java.lang.String getIndexPath(java.sql.Connection conn) throws java.sql.SQLExceptionGet the file system path.- Parameters:
conn- the connection- Returns:
- the file system path
- Throws:
java.sql.SQLException
-
prepare
java.sql.PreparedStatement prepare(java.sql.Connection conn, java.lang.String sql) throws java.sql.SQLExceptionPrepare a statement. The statement is cached in a soft reference cache.- Parameters:
conn- the connectionsql- the statement- Returns:
- the prepared statement
- Throws:
java.sql.SQLException- on failure
-
removeAllIndexes
protected void removeAllIndexes()
Remove all indexes from the settings.
-
removeIndexInfo
protected void removeIndexInfo(IndexInfo index)
Remove an index from the settings.- Parameters:
index- the index to remove
-
setInitialized
protected void setInitialized(boolean b)
Set the initialized flag.- Parameters:
b- the new value
-
isInitialized
protected boolean isInitialized()
Get the initialized flag.- Returns:
- whether this instance is initialized
-
closeAll
protected static void closeAll()
Close all fulltext settings, freeing up memory.
-
setWhitespaceChars
protected void setWhitespaceChars(java.lang.String whitespaceChars)
-
getWhitespaceChars
protected java.lang.String getWhitespaceChars()
-
normalizeWord
private static java.lang.String normalizeWord(java.lang.String word)
-
-