| org.apache.lucene.store.jdbc.JdbcDirectory
JdbcDirectory | public class JdbcDirectory extends Directory implements MultiDeleteDirectory(Code) | | A Jdbc based implementation of a Lucene Directory allowing the storage of a Lucene index
within a database. Uses a jdbc DataSource ,
Dialect specific for the database used,
and an optional
JdbcDirectorySettings and
JdbcTable for configuration.
The directory works against a single table, where the binary data is stored in Blob . Each "file"
has an entry in the database, and different
FileEntryHandler can be defines for different files (or
files groups).
Most of the files will not be deleted from the database when the directory delete method is called, but will
only be marked to be deleted (see
org.apache.lucene.store.jdbc.handler.MarkDeleteFileEntryHandler . It is
done since other readers or searchers might be working with the database, and still use the files. The ability to
purge mark deleted files based on a "delta" is acheived using
JdbcDirectory.deleteMarkDeleted() and
JdbcDirectory.deleteMarkDeleted(long) . Note, the purging process is not called by the directory code, so it will have
to be managed by the application using the jdbc directory.
For transaction management, all the operations performed against the database do not call commit or
rollback . They simply open a connection (using
org.apache.lucene.store.jdbc.datasource.DataSourceUtils.getConnection(javax.sql.DataSource) ), and close it
using
org.apache.lucene.store.jdbc.datasource.DataSourceUtils.releaseConnection(java.sql.Connection) ). This
results in the fact that transcation management is simple and wraps the directory operations, allowing it to span
as many operations as needed.
For none managed applications (i.e. applications that do not use JTA or Spring transaction manager), the jdbc directory
implementation comes with
org.apache.lucene.store.jdbc.datasource.TransactionAwareDataSourceProxy which wraps
a DataSource (should be a pooled one, like Jakartat DBCP). Using it with the
org.apache.lucene.store.jdbc.datasource.DataSourceUtils , or the provided
DirectoryTemplate should make
integrating or using jdbc directory simple.
Also, for none managed applications, there is an option working with autoCommit=true mode. The system will work much
slower, and it is only supported on a portion of the databases, but any existing code that uses Lucene with any
other Directory implemenation should work as is.
If working within managed environments, an external transaction management should be performed (using JTA for example).
Simple solutions can be using CMT or Spring Framework abstraction of transaction managers. Currently, the jdbc directory
implementation does not implement a transaction management abstraction, since there is a very good solution out there
already (Spring and JTA). Note, when using Spring and the DataSourceTransactionManager , to provide the jdbc directory
with a Spring's TransactionAwareDataSourceProxy .
author: kimchy |
JdbcDirectory | public JdbcDirectory(DataSource dataSource, Dialect dialect, String tableName)(Code) | | Creates a new jdbc directory. Creates new
JdbcDirectorySettings using it's default values.
Parameters: dataSource - The data source to use Parameters: dialect - The dialect Parameters: tableName - The table name |
JdbcDirectory | public JdbcDirectory(DataSource dataSource, Dialect dialect, JdbcDirectorySettings settings, String tableName)(Code) | | Creates a new jdbc directory.
Parameters: dataSource - The data source to use Parameters: dialect - The dialect Parameters: settings - The settings to configure the directory Parameters: tableName - The table name that will be used |
JdbcDirectory | public JdbcDirectory(DataSource dataSource, JdbcTable table)(Code) | | Creates a new jdbc directory.
Parameters: dataSource - The data source to use Parameters: table - The Jdbc table definitions |
deleteContent | public void deleteContent() throws IOException(Code) | | Deletes the contents of the database, except for the commit and write lock.
throws: IOException - |
deleteMarkDeleted | public void deleteMarkDeleted(long delta) throws IOException(Code) | | Delets all the file entries that are marked to be deleted, and they were marked
"delta" time ago (base on database time, if possible by dialect).
|
|
|