Class CsvFileCommitterConfig
Commits documents to CSV files (Comma Separated Value). There are two kinds of document representations: upserts and deletions.
If you request to split upserts and deletions into separate files,
the generated files will start with "upsert-" (for additions/modifications)
and "delete-" (for deletions).
A request "type" field is always added when both upserts and deletes are
added to the same file. Default header name for it is type,
but you can supply your own name with setTypeHeader(String).
The generated files are never updated. Sending a modified document with the same reference will create a new entry and won't modify any existing ones. You can think of the generated files as a set of commit instructions.
The generated CSV file names are made of a timestamp and a sequence number.
You have the option to give a prefix or suffix to files that will be created (default does not add any).
Content handling
The document content is represented by creating a column with a blank or
null field name. When requested, the "content" column
will always be present for both upserts and deletes, even if deletes do not
have content, for consistency.
Truncate long values
By default, values longer than 5096 are truncated.
You can specify a different maximum length globally, or for each column.
Use -1 for unlimited lenght, or 0 to use the
the global value, or 5096 if the global value
is also zero.
CSV Format
Applications consuming CSV files often have different expectations. Subtle format differences that can make opening or parsing a generated CSV file difficult. To help with this, there are preset CSV formats you can chose from:
- DEFAULT
- EXCEL
- INFORMIX_UNLOAD1.3
- INFORMIX_UNLOAD_CSV1.3
- MONGO_CSV1.7
- MONGO_TSV1.7
- MYSQL
- ORACLE1.6
- POSTGRESSQL_CSV1.5
- POSTGRESSQL_TEXT1.5
- RFC-4180
- TDF
More information on those can be obtained on Apache Commons CSV website. Other formatting options you explicitly configure will overwrite the corresponding setting for the chosen format.
}-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic final class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanDelimiter character to use.Escape character.Optional base CSV formatter to use.String used as delimiter when joining multi-value fields.getQuote()Quote character to use.intNumber of characters from which long text will be truncated.When generating CSV files containing both upserts and deletes requests, what column name to use to display the request type.inthashCode()booleanWhether to write column names on the first line.setColumns(List<CsvColumn> columns) setDelimiter(Character delimiter) Delimiter character to use.Escape character.Optional base CSV formatter to use.setMultiValueJoinDelimiter(String multiValueJoinDelimiter) String used as delimiter when joining multi-value fields.Quote character to use.setShowHeaders(boolean showHeaders) Whether to write column names on the first line.setTruncateAt(int truncateAt) Number of characters from which long text will be truncated.setTypeHeader(String typeHeader) When generating CSV files containing both upserts and deletes requests, what column name to use to display the request type.toString()Methods inherited from class com.norconex.committer.core.fs.BaseFsCommitterConfig
getDirectory, getDocsPerFile, getFileNamePrefix, getFileNameSuffix, isCompress, isSplitUpsertDelete, setCompress, setDirectory, setDocsPerFile, setFileNamePrefix, setFileNameSuffix, setSplitUpsertDeleteMethods inherited from class com.norconex.committer.core.BaseCommitterConfig
addRestriction, addRestrictions, clearFieldMappings, clearRestrictions, getFieldMappings, getRestrictions, removeFieldMapping, removeRestriction, removeRestriction, setFieldMapping, setFieldMappings
-
Field Details
-
DEFAULT_TRUNCATE_AT
public static final int DEFAULT_TRUNCATE_AT- See Also:
-
-
Constructor Details
-
CsvFileCommitterConfig
public CsvFileCommitterConfig()
-
-
Method Details
-
getColumns
-
setColumns
-
getFormat
Optional base CSV formatter to use. Settings explicitly set will overwrite these defaults ("quote", "escape", etc.). -
getDelimiter
Delimiter character to use. -
getQuote
Quote character to use. -
isShowHeaders
public boolean isShowHeaders()Whether to write column names on the first line. -
getEscape
Escape character. -
getTruncateAt
public int getTruncateAt()Number of characters from which long text will be truncated. Default is 5096 -
getMultiValueJoinDelimiter
String used as delimiter when joining multi-value fields. -
getTypeHeader
When generating CSV files containing both upserts and deletes requests, what column name to use to display the request type. -
setFormat
Optional base CSV formatter to use. Settings explicitly set will overwrite these defaults ("quote", "escape", etc.).- Returns:
this.
-
setDelimiter
Delimiter character to use.- Returns:
this.
-
setQuote
Quote character to use.- Returns:
this.
-
setShowHeaders
Whether to write column names on the first line.- Returns:
this.
-
setEscape
Escape character.- Returns:
this.
-
setTruncateAt
Number of characters from which long text will be truncated. Default is 5096- Returns:
this.
-
setMultiValueJoinDelimiter
String used as delimiter when joining multi-value fields.- Returns:
this.
-
setTypeHeader
When generating CSV files containing both upserts and deletes requests, what column name to use to display the request type.- Returns:
this.
-
equals
- Overrides:
equalsin classBaseFsCommitterConfig
-
canEqual
- Overrides:
canEqualin classBaseFsCommitterConfig
-
hashCode
public int hashCode()- Overrides:
hashCodein classBaseFsCommitterConfig
-
toString
- Overrides:
toStringin classBaseFsCommitterConfig
-