@PublicEvolving
public class CsvOutputFormat<T extends org.apache.flink.api.java.tuple.Tuple>
extends org.apache.flink.api.common.io.FileOutputFormat<T>
implements org.apache.flink.api.java.typeutils.InputTypeConfigurable
Tuples to text. The
output is structured by record delimiters and field delimiters as common in CSV files. Record
delimiter separate records from each other ('\n' is common). Field delimiters separate fields
within a record.| 限定符和类型 | 字段和说明 |
|---|---|
static String |
DEFAULT_FIELD_DELIMITER |
static String |
DEFAULT_LINE_DELIMITER |
| 构造器和说明 |
|---|
CsvOutputFormat(org.apache.flink.core.fs.Path outputPath)
Creates an instance of CsvOutputFormat.
|
CsvOutputFormat(org.apache.flink.core.fs.Path outputPath,
String fieldDelimiter)
Creates an instance of CsvOutputFormat.
|
CsvOutputFormat(org.apache.flink.core.fs.Path outputPath,
String recordDelimiter,
String fieldDelimiter)
Creates an instance of CsvOutputFormat.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
void |
open(int taskNumber,
int numTasks) |
void |
setAllowNullValues(boolean allowNulls)
Configures the format to either allow null values (writing an empty field), or to throw an
exception when encountering a null field.
|
void |
setCharsetName(String charsetName)
Sets the charset with which the CSV strings are written to the file.
|
void |
setInputType(org.apache.flink.api.common.typeinfo.TypeInformation<?> type,
org.apache.flink.api.common.ExecutionConfig executionConfig)
The purpose of this method is solely to check whether the data type to be processed is in
fact a tuple type.
|
void |
setQuoteStrings(boolean quoteStrings)
Configures whether the output format should quote string values.
|
String |
toString() |
void |
writeRecord(T element) |
public static final String DEFAULT_FIELD_DELIMITER
public CsvOutputFormat(org.apache.flink.core.fs.Path outputPath)
outputPath - The path where the CSV file is written.public CsvOutputFormat(org.apache.flink.core.fs.Path outputPath,
String fieldDelimiter)
outputPath - The path where the CSV file is written.fieldDelimiter - The delimiter that is used to separate fields in a tuple.public CsvOutputFormat(org.apache.flink.core.fs.Path outputPath,
String recordDelimiter,
String fieldDelimiter)
outputPath - The path where the CSV file is written.recordDelimiter - The delimiter that is used to separate the tuples.fieldDelimiter - The delimiter that is used to separate fields in a tuple.public void setAllowNullValues(boolean allowNulls)
by default, null values are disallowed.
allowNulls - Flag to indicate whether the output format should accept null values.public void setCharsetName(String charsetName)
charsetName - The name of charset to use for encoding the output.public void setQuoteStrings(boolean quoteStrings)
String and StringValue, as well as all
subclasses of the latter.
By default, strings are not quoted.
quoteStrings - Flag indicating whether string fields should be quoted.public void open(int taskNumber,
int numTasks)
throws IOException
open 在接口中 org.apache.flink.api.common.io.OutputFormat<T extends org.apache.flink.api.java.tuple.Tuple>open 在类中 org.apache.flink.api.common.io.FileOutputFormat<T extends org.apache.flink.api.java.tuple.Tuple>IOExceptionpublic void close()
throws IOException
close 在接口中 org.apache.flink.api.common.io.OutputFormat<T extends org.apache.flink.api.java.tuple.Tuple>close 在类中 org.apache.flink.api.common.io.FileOutputFormat<T extends org.apache.flink.api.java.tuple.Tuple>IOExceptionpublic void writeRecord(T element) throws IOException
writeRecord 在接口中 org.apache.flink.api.common.io.OutputFormat<T extends org.apache.flink.api.java.tuple.Tuple>IOExceptionpublic void setInputType(org.apache.flink.api.common.typeinfo.TypeInformation<?> type,
org.apache.flink.api.common.ExecutionConfig executionConfig)
setInputType 在接口中 org.apache.flink.api.java.typeutils.InputTypeConfigurableCopyright © 2014–2023 The Apache Software Foundation. All rights reserved.