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, versionNumber
features
DATASTORE_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, unlockLr
getFeatures, setFeatures
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addDatastoreListener, adopt, canReadLR, canWriteLR, create, delete, findLrIds, findLrIds, getComment, getIconName, getLrIds, getLrName, getLrNames, getLrTypes, getStorageUrl, isAutoSaving, lockLr, removeDatastoreListener, setAutoSaving, setStorageUrl, unlockLr
getFeatures, setFeatures
getName, setName
protected 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 DataStore
close
in class SerialDataStore
PersistenceException
public void open() throws PersistenceException
open
in interface DataStore
open
in class SerialDataStore
PersistenceException
protected void queueForIndexing(Object lrID)
public void delete(String lrClassName, Object lrPersistenceId) throws PersistenceException
delete
in interface DataStore
delete
in class SerialDataStore
lrClassName
- class name of the type of resourcelrPersistenceId
- a data-store specific unique identifier for the resourcePersistenceException
public LanguageResource getLr(String lrClassName, Object lrPersistenceId) throws PersistenceException, SecurityException
DataStore
FeatureMap 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 DataStore
getLr
in class SerialDataStore
PersistenceException
SecurityException
public void sync(LanguageResource lr) throws PersistenceException
sync
in interface DataStore
sync
in class SerialDataStore
PersistenceException
public void setIndexer(Indexer indexer, Map<String,Object> indexParameters) throws IndexException
setIndexer
in interface Searchable
indexParameters
- - parameters required by the specific
implementation of provided indexerIndexException
public Indexer getIndexer()
Searchable
getIndexer
in interface Searchable
public void setSearcher(Searcher searcher) throws SearchException
Searchable
setSearcher
in interface Searchable
SearchException
public Searcher getSearcher()
Searchable
getSearcher
in interface Searchable
public void setIndexDelay(long indexDelay)
public long getIndexDelay()
public boolean search(String query, Map<String,Object> searchParameters) throws SearchException
search
in interface Searchable
searchParameters
- - parameters required for searching an
index (e.g. location of the index)SearchException
public Hit[] next(int numberOfPatterns) throws SearchException
next
in interface Searchable
numberOfPatterns
- SearchException
public void documentRemoved(CorpusEvent ce)
documentRemoved
in interface CorpusListener
public void documentAdded(CorpusEvent ce)
documentAdded
in interface CorpusListener
public void datastoreClosed(CreoleEvent e)
CreoleListener
DataStore
has been closeddatastoreClosed
in interface CreoleListener
public void datastoreCreated(CreoleEvent e)
CreoleListener
DataStore
has been createddatastoreCreated
in interface CreoleListener
public void datastoreOpened(CreoleEvent e)
CreoleListener
DataStore
has been openeddatastoreOpened
in interface CreoleListener
public void resourceLoaded(CreoleEvent e)
CreoleListener
Resource
has been loaded into the systemresourceLoaded
in interface CreoleListener
public void resourceRenamed(Resource resource, String oldName, String newName)
CreoleListener
resourceRenamed
in interface CreoleListener
public void resourceUnloaded(CreoleEvent e)
CreoleListener
Resource
has been removed from the systemresourceUnloaded
in interface CreoleListener
Copyright © 2024 GATE. All rights reserved.