|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgate.util.AbstractFeatureBearer
gate.persist.SerialDataStore
gate.persist.LuceneDataStoreImpl
public class LuceneDataStoreImpl
| Nested Class Summary | |
|---|---|
protected class |
LuceneDataStoreImpl.IndexingTask
|
private class |
LuceneDataStoreImpl.LabelledSoftReference
Soft reference with an associated label. |
| Field Summary | |
|---|---|
protected ConcurrentMap<Object,LuceneDataStoreImpl.IndexingTask> |
currentTasks
Map keeping track of the most recent indexing task for each LR ID. |
protected boolean |
dataStoreClosing
Indicates if the datastore is being closed. |
protected ScheduledThreadPoolExecutor |
executor
Executor to run the indexing tasks |
protected long |
indexDelay
Number of milliseconds we should wait after a sync before attempting to re-index a document. |
protected Indexer |
indexer
Indexer to be used for indexing documents |
protected Map |
indexParameters
Index Parameters |
protected URL |
indexURL
URL of the index |
protected Map<Object,LuceneDataStoreImpl.LabelledSoftReference> |
lockObjects
To store canonical lock objects for each LR ID. |
protected ReferenceQueue<Object> |
refQueue
Reference queue with which the soft references in the lockObjects map will be registered. |
protected Searcher |
searcher
Searcher to be used for searching the indexed documents |
protected Map |
searchParameters
This is where we store the search parameters |
private static long |
serialVersionUID
serial version UID |
| Fields inherited from class gate.persist.SerialDataStore |
|---|
autoSaving, currentProtocolVersion, name, protocolVersionNumbers, randomiser, storageDir, versionFileName, versionNumber |
| Fields inherited from class gate.util.AbstractFeatureBearer |
|---|
features |
| Fields inherited from interface gate.DataStore |
|---|
DATASTORE_FEATURE_NAME, LR_ID_FEATURE_NAME |
| Constructor Summary | |
|---|---|
LuceneDataStoreImpl()
|
|
| Method Summary | |
|---|---|
void |
close()
Close the data store. |
void |
datastoreClosed(CreoleEvent e)
Called when a DataStore has been closed |
void |
datastoreCreated(CreoleEvent e)
Called when a DataStore has been created |
void |
datastoreOpened(CreoleEvent e)
Called when a DataStore has been opened |
void |
delete(String lrClassName,
Object lrPersistenceId)
Delete a resource from the data store. |
void |
documentAdded(CorpusEvent ce)
This method is invoked whenever a document is added to a particular corpus |
void |
documentRemoved(CorpusEvent ce)
This method is invoked whenever a document is removed from a corpus |
long |
getIndexDelay()
|
Indexer |
getIndexer()
Returns the Indexer |
LanguageResource |
getLr(String lrClassName,
Object lrPersistenceId)
Get a resource from the persistent store. |
Searcher |
getSearcher()
Returns the Searcher |
private Object |
lockObjectForID(Object id)
Obtain the lock object on which we must synchronize when loading or saving the LR with the given ID. |
Hit[] |
next(int numberOfPatterns)
Returns the next numberOfPatterns |
void |
open()
Open a connection to the data store. |
private void |
processRefQueue()
Cleans up the lockObjects map by removing any entries whose SoftReference values have been cleared by the garbage collector. |
protected void |
queueForIndexing(Object lrID)
Submits the given LR ID for indexing. |
void |
resourceLoaded(CreoleEvent e)
Called when a new Resource has been loaded into the system |
void |
resourceRenamed(Resource resource,
String oldName,
String newName)
Called when the creole register has renamed a resource.1 |
void |
resourceUnloaded(CreoleEvent e)
Called when a Resource has been removed from the system |
boolean |
search(String query,
Map searchParameters)
Search the datastore |
void |
setIndexDelay(long indexDelay)
Sets the delay in milliseconds that we should wait after a sync before attempting to re-index a document. |
void |
setIndexer(Indexer indexer,
Map indexParameters)
Sets the Indexer to be used for indexing Datastore |
void |
setSearcher(Searcher searcher)
This method is used to specify the searcher which is used for searchering the index |
void |
sync(LanguageResource lr)
Save: synchonise the in-memory image of the LR with the persistent image. |
| Methods inherited from class gate.util.AbstractFeatureBearer |
|---|
getFeatures, setFeatures |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface gate.DataStore |
|---|
addDatastoreListener, adopt, canReadLR, canWriteLR, create, delete, findLrIds, findLrIds, getComment, getIconName, getLrIds, getLrName, getLrNames, getLrTypes, getSecurityInfo, getSession, getStorageUrl, isAutoSaving, lockLr, removeDatastoreListener, setAutoSaving, setSecurityInfo, setSession, setStorageUrl, unlockLr |
| Methods inherited from interface gate.util.FeatureBearer |
|---|
getFeatures, setFeatures |
| Methods inherited from interface gate.util.NameBearer |
|---|
getName, setName |
| Field Detail |
|---|
private static final long serialVersionUID
protected Map<Object,LuceneDataStoreImpl.LabelledSoftReference> lockObjects
protected ReferenceQueue<Object> refQueue
protected boolean dataStoreClosing
protected ScheduledThreadPoolExecutor executor
protected ConcurrentMap<Object,LuceneDataStoreImpl.IndexingTask> currentTasks
protected long indexDelay
protected Indexer indexer
protected Map indexParameters
protected URL indexURL
protected Searcher searcher
protected Map searchParameters
| Constructor Detail |
|---|
public LuceneDataStoreImpl()
| Method Detail |
|---|
public void close()
throws PersistenceException
close in interface DataStoreclose in class SerialDataStorePersistenceException
public void open()
throws PersistenceException
open in interface DataStoreopen in class SerialDataStorePersistenceExceptionprivate Object lockObjectForID(Object id)
id -
private void processRefQueue()
protected void queueForIndexing(Object lrID)
public void delete(String lrClassName,
Object lrPersistenceId)
throws PersistenceException
delete in interface DataStoredelete in class SerialDataStorelrClassName - class name of the type of resourcelrPersistenceId - a data-store specific unique identifier for the resource
PersistenceException
public LanguageResource getLr(String lrClassName,
Object lrPersistenceId)
throws PersistenceException,
SecurityException
getLr in interface DataStoregetLr in class SerialDataStorePersistenceException
SecurityException
public void sync(LanguageResource lr)
throws PersistenceException
sync in interface DataStoresync in class SerialDataStorePersistenceException
public void setIndexer(Indexer indexer,
Map indexParameters)
throws IndexException
setIndexer in interface SearchableindexParameters - - parameters required by the specific
implementation of provided indexer
IndexExceptionpublic Indexer getIndexer()
Searchable
getIndexer in interface Searchable
public void setSearcher(Searcher searcher)
throws SearchException
Searchable
setSearcher in interface SearchableSearchExceptionpublic Searcher getSearcher()
Searchable
getSearcher in interface Searchablepublic void setIndexDelay(long indexDelay)
public long getIndexDelay()
public boolean search(String query,
Map searchParameters)
throws SearchException
search in interface SearchablesearchParameters - - parameters required for searching an
index (e.g. location of the index)
SearchException
public Hit[] next(int numberOfPatterns)
throws SearchException
next in interface SearchablenumberOfPatterns -
SearchExceptionpublic void documentRemoved(CorpusEvent ce)
documentRemoved in interface CorpusListenerpublic void documentAdded(CorpusEvent ce)
documentAdded in interface CorpusListenerpublic void datastoreClosed(CreoleEvent e)
CreoleListenerDataStore has been closed
datastoreClosed in interface CreoleListenerpublic void datastoreCreated(CreoleEvent e)
CreoleListenerDataStore has been created
datastoreCreated in interface CreoleListenerpublic void datastoreOpened(CreoleEvent e)
CreoleListenerDataStore has been opened
datastoreOpened in interface CreoleListenerpublic void resourceLoaded(CreoleEvent e)
CreoleListenerResource has been loaded into the system
resourceLoaded in interface CreoleListener
public void resourceRenamed(Resource resource,
String oldName,
String newName)
CreoleListener
resourceRenamed in interface CreoleListenerpublic void resourceUnloaded(CreoleEvent e)
CreoleListenerResource has been removed from the system
resourceUnloaded in interface CreoleListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||