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 SummaryNested Classes Modifier and Type Class Description static classJDBCEmitter.AttachmentStrategystatic classJDBCEmitter.MultivaluedFieldStrategy
 - 
Constructor SummaryConstructors Constructor Description JDBCEmitter()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckInitialization(InitializableProblemHandler problemHandler)voidclose()voidemit(String emitKey, List<Metadata> metadataList)This executes the emit with each call.voidemit(List<? extends EmitData> emitData)The default behavior is to callEmitter.emit(String, List)on each item.voidinitialize(Map<String,Param> params)voidsetAlterTable(String alterTable)This is called immediately after the table is created.voidsetAttachmentStrategy(String attachmentStrategy)voidsetAttachmentStrategy(JDBCEmitter.AttachmentStrategy attachmentStrategy)voidsetConnection(String connection)voidsetCreateTable(String createTable)voidsetInsert(String insert)voidsetKeys(Map<String,String> keys)The implementation of keys should be a LinkedHashMap because order matters!voidsetMaxRetries(int maxRetries)voidsetMaxStringLength(int maxStringLength)Set the maximum string length in characters (not bytes).voidsetMultivaluedFieldDelimiter(String delimiter)voidsetMultivaluedFieldStrategy(String strategy)This applies to fields of type 'string' or 'varchar'.voidsetMultivaluedFieldStrategy(JDBCEmitter.MultivaluedFieldStrategy multivaluedFieldStrategy)voidsetPostConnection(String postConnection)This sql will be called immediately after the connection is made.- 
Methods inherited from class org.apache.tika.pipes.emitter.AbstractEmittergetName, setName
 
- 
 
- 
- 
- 
Method Detail- 
setAlterTablepublic 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-
 
 - 
setMaxStringLength@Field public void setMaxStringLength(int maxStringLength) Set the maximum string length in characters (not bytes). This is applies only to fields with name "string" not to "varchar".- Parameters:
- maxStringLength-
 
 - 
setMaxRetriespublic void setMaxRetries(int maxRetries) 
 - 
setPostConnection@Field public void setPostConnection(String postConnection) This sql will be called immediately after the connection is made. This was initially added for setting pragmas on sqlite3, but may be used for other connection configuration in other dbs. Note: This is called before the table is created if it needs to be created.- Parameters:
- postConnection-
 
 - 
setMultivaluedFieldStrategy@Field public void setMultivaluedFieldStrategy(String strategy) throws TikaConfigException This applies to fields of type 'string' or 'varchar'. If there's a multivalued field in a metadata object, do you want the first value only or should we concatenate these with thesetMultivaluedFieldDelimiter(String).The default values as of 2.6.1 are JDBCEmitter.MultivaluedFieldStrategy.CONCATENATEand the default delimiter is ", "- Parameters:
- strategy-
- Throws:
- TikaConfigException
 
 - 
setMultivaluedFieldStrategypublic void setMultivaluedFieldStrategy(JDBCEmitter.MultivaluedFieldStrategy multivaluedFieldStrategy) 
 - 
setMultivaluedFieldDelimiter@Field public void setMultivaluedFieldDelimiter(String delimiter) - Parameters:
- delimiter-
 
 - 
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-
 
 - 
setAttachmentStrategypublic void setAttachmentStrategy(JDBCEmitter.AttachmentStrategy attachmentStrategy) 
 - 
emitpublic 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:
- emitin interface- Emitter
- Parameters:
- emitKey- emit key
- metadataList- list of metadata per file
- Throws:
- IOException
- TikaEmitterException
 
 - 
emitpublic void emit(List<? extends EmitData> emitData) throws IOException, TikaEmitterException Description copied from class:AbstractEmitterThe 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:
- emitin interface- Emitter
- Overrides:
- emitin class- AbstractEmitter
- Throws:
- IOException
- TikaEmitterException
 
 - 
initializepublic void initialize(Map<String,Param> params) throws TikaConfigException - Specified by:
- initializein interface- Initializable
- Parameters:
- params- params to use for initialization
- Throws:
- TikaConfigException
 
 - 
checkInitializationpublic void checkInitialization(InitializableProblemHandler problemHandler) throws TikaConfigException - Specified by:
- checkInitializationin interface- Initializable
- Parameters:
- problemHandler- if there is a problem and no custom initializableProblemHandler has been configured via Initializable parameters, this is called to respond.
- Throws:
- TikaConfigException
 
 - 
closepublic void close() throws IOException- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Throws:
- IOException
 
 
- 
 
-