Class JDBCEmitter
- java.lang.Object
-
- org.apache.tika.pipes.emitter.AbstractEmitter
-
- org.apache.tika.pipes.emitter.jdbc.JDBCEmitter
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Initializable
,Emitter
public class JDBCEmitter extends AbstractEmitter implements Initializable, Closeable
This is only an initial, basic implementation of an emitter for JDBC.It is currently NOT thread safe because of the shared prepared statement, and depending on the jdbc implementation because of the shared connection.
As of the 2.5.0 release, this is ALPHA version. There may be breaking changes in the future.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JDBCEmitter.AttachmentStrategy
-
Constructor Summary
Constructors Constructor Description JDBCEmitter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkInitialization(InitializableProblemHandler problemHandler)
void
close()
void
emit(String emitKey, List<Metadata> metadataList)
This executes the emit with each call.void
emit(List<? extends EmitData> emitData)
The default behavior is to callEmitter.emit(String, List)
on each item.void
initialize(Map<String,Param> params)
void
setAlterTable(String alterTable)
This is called immediately after the table is created.void
setAttachmentStrategy(String attachmentStrategy)
void
setAttachmentStrategy(JDBCEmitter.AttachmentStrategy attachmentStrategy)
void
setConnection(String connectionString)
void
setCreateTable(String createTable)
void
setInsert(String insert)
void
setKeys(Map<String,String> keys)
The implementation of keys should be a LinkedHashMap because order matters!-
Methods inherited from class org.apache.tika.pipes.emitter.AbstractEmitter
getName, setName
-
-
-
-
Method Detail
-
setAlterTable
public void setAlterTable(String alterTable)
This is called immediately after the table is created. The purpose of this is to allow for adding a complex primary key or other constraint on the table after it is created.- Parameters:
alterTable
-
-
setKeys
@Field public void setKeys(Map<String,String> keys)
The implementation of keys should be a LinkedHashMap because order matters!Key is the name of the metadata field, value is the type of column: boolean, string, int, long
- Parameters:
keys
-
-
setAttachmentStrategy
public void setAttachmentStrategy(JDBCEmitter.AttachmentStrategy attachmentStrategy)
-
emit
public void emit(String emitKey, List<Metadata> metadataList) throws IOException, TikaEmitterException
This executes the emit with each call. For more efficient batch execution useemit(List)
.- Specified by:
emit
in interfaceEmitter
- Parameters:
emitKey
- emit keymetadataList
- list of metadata per file- Throws:
IOException
TikaEmitterException
-
emit
public void emit(List<? extends EmitData> emitData) throws IOException, TikaEmitterException
Description copied from class:AbstractEmitter
The default behavior is to callEmitter.emit(String, List)
on each item. Some implementations, e.g. Solr/ES/vespa, can benefit from subclassing this and emitting a bunch of docs at once.- Specified by:
emit
in interfaceEmitter
- Overrides:
emit
in classAbstractEmitter
- Throws:
IOException
TikaEmitterException
-
initialize
public void initialize(Map<String,Param> params) throws TikaConfigException
- Specified by:
initialize
in interfaceInitializable
- Parameters:
params
- params to use for initialization- Throws:
TikaConfigException
-
checkInitialization
public void checkInitialization(InitializableProblemHandler problemHandler) throws TikaConfigException
- Specified by:
checkInitialization
in interfaceInitializable
- Parameters:
problemHandler
- if there is a problem and no custom initializableProblemHandler has been configured via Initializable parameters, this is called to respond.- Throws:
TikaConfigException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-