Module datarush.library
Class AbstractTextWriter
java.lang.Object
com.pervasive.datarush.operators.AbstractLogicalOperator
com.pervasive.datarush.operators.CompositeOperator
com.pervasive.datarush.operators.io.AbstractWriter
com.pervasive.datarush.operators.io.textfile.AbstractTextWriter
- All Implemented Interfaces:
LogicalOperator,RecordSinkOperator,SinkOperator<RecordPort>
- Direct Known Subclasses:
WriteARFF,WriteDelimitedText,WriteFixedText
A generic writer of text data representing a stream of records.
The writer encompasses the
basic attributes any such reader should have beyond a
standard byte-oriented writer, namely information on
how to encode the characters into bytes.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CharsetEncodingContainer for character encoding related attributesFields inherited from class com.pervasive.datarush.operators.io.AbstractWriter
input, options -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWrites text to an empty target with default settings.protectedAbstractTextWriter(boolean provideDoneSignal) Writes text to an empty target with default settings, optionally providing a port for signaling completion of the write.protectedAbstractTextWriter(Path path, WriteMode mode) Writes text to the specified path in the given mode, using default settings.protectedAbstractTextWriter(ByteSink target, WriteMode mode) Writes text to the specified target sink in the given mode.protectedAbstractTextWriter(String path, WriteMode mode) Writes text to the specified path in the given mode, using default settings. -
Method Summary
Modifier and TypeMethodDescriptionGets the character set used by the data sink.Gets the name of the character set used by the data sink.intGets the size of the buffer, in bytes, used to encode character data.Get the character set encoding properties.Get the configured encoding error action.Get the text used by the replacement error action.voidsetCharset(Charset charset) Sets the character set used by the data sink.voidsetCharsetName(String charsetName) Sets the character set used by the data sink.voidsetEncodeBuffer(int size) Sets the size of the buffer, in bytes, used to encode character data.voidsetEncoding(CharsetEncoding settings) Set the properties that control character set encoding.voidsetErrorAction(CodingErrorAction errorAction) Set the encoding error action.voidsetReplacement(String replacement) Sets the error policy to be replacement with the specified string.Methods inherited from class com.pervasive.datarush.operators.io.AbstractWriter
compose, computeFormat, getFormatOptions, getInput, getMode, getSaveMetadata, getTarget, getWriteBuffer, getWriteOnClient, getWriteSingleSink, isIgnoreSortOrder, setFormatOptions, setIgnoreSortOrder, setMode, setSaveMetadata, setTarget, setTarget, setTarget, setWriteBuffer, setWriteOnClient, setWriteSingleSinkMethods inherited from class com.pervasive.datarush.operators.AbstractLogicalOperator
disableParallelism, getInputPorts, getOutputPorts, newInput, newInput, newOutput, newRecordInput, newRecordInput, newRecordOutput, notifyErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.pervasive.datarush.operators.LogicalOperator
disableParallelism, getInputPorts, getOutputPorts
-
Field Details
-
encodingProps
Container for character encoding related attributes
-
-
Constructor Details
-
AbstractTextWriter
protected AbstractTextWriter()Writes text to an empty target with default settings. The target must be set before execution or an error will be raised.- See Also:
-
AbstractTextWriter
protected AbstractTextWriter(boolean provideDoneSignal) Writes text to an empty target with default settings, optionally providing a port for signaling completion of the write. The target must be set before execution or an error will be raised.- Parameters:
provideDoneSignal- indicates whether a done signal port should be created- See Also:
-
AbstractTextWriter
Writes text to the specified path in the given mode, using default settings.If the writer is parallelized, this is interpreted as a directory in which each partition will write a fragment of the entire input stream. Otherwise, it is interpreted as the file to write.
- Parameters:
path- the path to which to writemode- how to handle existing files
-
AbstractTextWriter
Writes text to the specified path in the given mode, using default settings.If the writer is parallelized, this is interpreted as a directory in which each partition will write a fragment of the entire input stream. Otherwise, it is interpreted as the file to write.
- Parameters:
path- the path to which to writemode- how to handle existing files
-
AbstractTextWriter
Writes text to the specified target sink in the given mode.The writer can only be parallelized if the sink is fragmentable. In this case, each partition will be written as an independent sink. Otherwise, the writer will run non-parallel.
- Parameters:
target- the sink to which to writemode- how to handle an existing sink
-
-
Method Details
-
getEncodeBuffer
public int getEncodeBuffer()Gets the size of the buffer, in bytes, used to encode character data.- Returns:
- the decoding buffer size
-
setEncodeBuffer
public void setEncodeBuffer(int size) Sets the size of the buffer, in bytes, used to encode character data. By default, this will be automatically derived using the character set and write buffer size.- Parameters:
size- the encoding buffer size to use
-
getEncoding
Get the character set encoding properties.- Returns:
- properties used for character set encoding
-
setEncoding
Set the properties that control character set encoding.- Parameters:
settings- character set encoding properties
-
getCharset
Gets the character set used by the data sink.- Returns:
- the character set of the target
-
setCharset
Sets the character set used by the data sink. By default ISO-8859-1 is used.- Parameters:
charset- the character set to use
-
getCharsetName
Gets the name of the character set used by the data sink.- Returns:
- the name of character set of the target
-
setCharsetName
Sets the character set used by the data sink.- Parameters:
charsetName- name of the character set- Throws:
InvalidPropertyValueException- if the named character set is not supported.
-
getErrorAction
Get the configured encoding error action.- Returns:
- encoding error action
-
setErrorAction
Set the encoding error action. The error action determines how to handle errors encoding the input data into the configured character set. The default action is to replace the faulty data with a replacement character.- Parameters:
errorAction- encoding error action
-
getReplacement
Get the text used by the replacement error action. This value is only used if the error action is to replace.- Returns:
- replacement text
-
setReplacement
Sets the error policy to be replacement with the specified string. By default, "?" is used.- Parameters:
replacement- replacement value to use for encoding errors
-