public class WriteARFF extends AbstractTextWriter
setFormatMode(ARFFMode)
method. The default mode is sparse. When the input data is highly sparse, the sparse
mode can save space since it only writes non-zero values. However, if the data is
not very sparse, using sparse mode can actually cause the resultant file to be
larger; use dense mode for dense data.
Note that when writing sparse data that contains enumerated types, the zero ordinal category will always be treated as sparse and so will not appear in the output file. This is normal and expected behavior. The enumerated type is captured in the meta-data. When the file is read, the zero ordinal values will be restored as expected.
encodingProps
input, options
Constructor and Description |
---|
WriteARFF()
Writes ARFF data to an empty target with default settings.
|
WriteARFF(ByteSink target,
WriteMode mode)
Writes ARFF data to the specified target sink in the
given mode.
|
WriteARFF(Path path,
WriteMode mode)
Writes ARFF data to the specified path in the given mode,
using default settings.
|
WriteARFF(String path,
WriteMode mode)
Writes ARFF data to the specified path in the given mode,
using default settings.
|
Modifier and Type | Method and Description |
---|---|
void |
addComment(String comment)
Add a comment line that will be written to the ARFF meta-data section
of the file.
|
protected DataFormat |
computeFormat(CompositionContext ctx)
Determines the data format for the target.
|
List<String> |
getComments()
Gets the comments lines current set to be written.
|
char |
getFieldDelimiter()
Get the configured field delimiter property value.
|
ARFFMode |
getFormatMode()
Get the value of the mode property.
|
String |
getRecordSeparator()
Get the record separator.
|
String |
getRelationName()
Get the value of the relation name property.
|
TextRecord |
getSchema()
Get the configured schema for this reader instance.
|
void |
setComments(List<String> comments)
Set the comments lines to write to the ARFF meta-data section of the file.
|
void |
setFieldDelimiter(char delimiter)
Set the field delimiter to use when writing the file contents.
|
void |
setFormatMode(ARFFMode mode)
Set the mode with which to write the file.
|
void |
setRecordSeparator(String separator)
Set the record separator.
|
void |
setRelationName(String relationName)
Set the relation name attribute.
|
void |
setSchema(TextRecord schema)
Set the schema to use for the provided data.
|
getCharset, getCharsetName, getEncodeBuffer, getEncoding, getErrorAction, getReplacement, setCharset, setCharsetName, setEncodeBuffer, setEncoding, setErrorAction, setReplacement
compose, getFormatOptions, getInput, getMode, getSaveMetadata, getTarget, getWriteBuffer, getWriteOnClient, getWriteSingleSink, isIgnoreSortOrder, setFormatOptions, setIgnoreSortOrder, setMode, setSaveMetadata, setTarget, setTarget, setTarget, setWriteBuffer, setWriteOnClient, setWriteSingleSink
disableParallelism, getInputPorts, getOutputPorts, newInput, newInput, newOutput, newRecordInput, newRecordInput, newRecordOutput, notifyError
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
disableParallelism, getInputPorts, getOutputPorts
public WriteARFF()
AbstractWriter.setTarget(ByteSink)
public WriteARFF(String path, WriteMode mode)
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.
path
- the path to which to writemode
- how to handle existing filespublic WriteARFF(Path path, WriteMode mode)
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.
path
- the path to which to writemode
- how to handle existing filespublic WriteARFF(ByteSink target, WriteMode 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.
target
- the sink to which to writemode
- how to handle an existing sinkpublic String getRelationName()
public void setRelationName(String relationName)
@attribute
.relationName
- name of the relationpublic void addComment(String comment)
comment
- a line of commentary to add to the output filepublic void setComments(List<String> comments)
comments
- lines of commentary to add to the output filepublic List<String> getComments()
public void setRecordSeparator(String separator)
separator
- text separating recordspublic String getRecordSeparator()
public ARFFMode getFormatMode()
public void setFormatMode(ARFFMode mode)
SPARSE
and DENSE
.mode
- write mode; either sparse or densepublic TextRecord getSchema()
public void setFieldDelimiter(char delimiter)
delimiter
- the delimiter to used for field values
containing spacespublic char getFieldDelimiter()
public void setSchema(TextRecord schema)
schema
- definition of field ordering, names, types and formatsprotected DataFormat computeFormat(CompositionContext ctx)
AbstractWriter
WriteSink
operator. If an
implementation supports schema discovery, it must be
performed in this method.computeFormat
in class AbstractWriter
ctx
- the composition context for the current invocation
of AbstractWriter.compose(CompositionContext)
Copyright © 2016 Actian Corporation. All rights reserved.