public class LuceneDataStoreImpl extends SerialDataStore implements SearchableDataStore, CorpusListener, CreoleListener
| Modifier and Type | Class and Description |
|---|---|
protected class |
LuceneDataStoreImpl.IndexingTask |
| Modifier and Type | Field and Description |
|---|---|
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<String,Object> |
indexParameters
Index Parameters
|
protected URL |
indexURL
URL of the index
|
protected Map<Object,gate.persist.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<String,Object> |
searchParameters
This is where we store the search parameters
|
autoSaving, currentProtocolVersion, name, protocolVersionNumbers, storageDir, versionNumberfeaturesDATASTORE_FEATURE_NAME, LR_ID_FEATURE_NAME| Constructor and Description |
|---|
LuceneDataStoreImpl() |
| Modifier and Type | Method and Description |
|---|---|
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
|
Hit[] |
next(int numberOfPatterns)
Returns the next numberOfPatterns
|
void |
open()
Open a connection to the data store.
|
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<String,Object> 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<String,Object> 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.
|
addDatastoreListener, adopt, canReadLR, canWriteLR, constructPersistenceId, create, delete, equals, filterIgnoredFileNames, findLrIds, findLrIds, fireResourceAdopted, fireResourceDeleted, fireResourceWritten, getComment, getIconName, getLrIds, getLrName, getLrNames, getLrTypes, getName, getStorageDir, getStorageUrl, getVersionFile, hashCode, isAutoSaving, isValidProtocolVersion, lockLr, random, removeDatastoreListener, setAutoSaving, setName, setStorageDir, setStorageUrl, toString, unlockLrgetFeatures, setFeaturesclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddDatastoreListener, adopt, canReadLR, canWriteLR, create, delete, findLrIds, findLrIds, getComment, getIconName, getLrIds, getLrName, getLrNames, getLrTypes, getStorageUrl, isAutoSaving, lockLr, removeDatastoreListener, setAutoSaving, setStorageUrl, unlockLrgetFeatures, setFeaturesgetName, setNameprotected Map<Object,gate.persist.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 URL indexURL
protected Searcher searcher
public void close()
throws PersistenceException
close in interface DataStoreclose in class SerialDataStorePersistenceExceptionpublic void open()
throws PersistenceException
open in interface DataStoreopen in class SerialDataStorePersistenceExceptionprotected 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 resourcePersistenceExceptionpublic LanguageResource getLr(String lrClassName, Object lrPersistenceId) throws PersistenceException, SecurityException
DataStoreFeatureMap params = Factory.newFeatureMap(); params.put(DataStore.DATASTORE_FEATURE_NAME, datastore); params.put(DataStore.LR_ID_FEATURE_NAME, lrID); LanguageResource lr = (LanguageResource)Factory.createResource(lrClassName, params);
getLr in interface DataStoregetLr in class SerialDataStorePersistenceExceptionSecurityExceptionpublic void sync(LanguageResource lr) throws PersistenceException
sync in interface DataStoresync in class SerialDataStorePersistenceExceptionpublic void setIndexer(Indexer indexer, Map<String,Object> indexParameters) throws IndexException
setIndexer in interface SearchableindexParameters - - parameters required by the specific
implementation of provided indexerIndexExceptionpublic Indexer getIndexer()
SearchablegetIndexer in interface Searchablepublic void setSearcher(Searcher searcher) throws SearchException
SearchablesetSearcher in interface SearchableSearchExceptionpublic Searcher getSearcher()
SearchablegetSearcher in interface Searchablepublic void setIndexDelay(long indexDelay)
public long getIndexDelay()
public boolean search(String query, Map<String,Object> searchParameters) throws SearchException
search in interface SearchablesearchParameters - - parameters required for searching an
index (e.g. location of the index)SearchExceptionpublic 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 closeddatastoreClosed in interface CreoleListenerpublic void datastoreCreated(CreoleEvent e)
CreoleListenerDataStore has been createddatastoreCreated in interface CreoleListenerpublic void datastoreOpened(CreoleEvent e)
CreoleListenerDataStore has been openeddatastoreOpened in interface CreoleListenerpublic void resourceLoaded(CreoleEvent e)
CreoleListenerResource has been loaded into the systemresourceLoaded in interface CreoleListenerpublic void resourceRenamed(Resource resource, String oldName, String newName)
CreoleListenerresourceRenamed in interface CreoleListenerpublic void resourceUnloaded(CreoleEvent e)
CreoleListenerResource has been removed from the systemresourceUnloaded in interface CreoleListenerCopyright © 2024 GATE. All rights reserved.