[
https://issues.apache.org/jira/browse/FLINK-35240?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17840935#comment-17840935
]
Alexander Fedulov commented on FLINK-35240:
-------------------------------------------
[~gongzhongqiang] this is pretty strange, because I remember that I ran into
this issue during development and this is exactly why this line is there:
[https://github.com/apache/flink/blob/c0bf0ac3fb1fe4814bff09807ed2040bb13da052/flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvBulkWriter.java#L60]
Maybe Jackson version got bumped and something in the internal initialization
of the _generatorFactory and the state of the "parent" mapper has changed. The
pointer to it is derived from the parent mapper, so it should, in theory, not
make a difference whether the setting is applied before or after the
{{.writer()}} call in the CsvBulkWriter constructor:
[ObjectWriter.java#L105|https://github.com/FasterXML/jackson-databind/blob/jackson-databind-2.14.2/src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java#L105]
Try to move the {{JsonGenerator.Feature#AUTO_CLOSE_TARGET}} configuration above
the .writer() call.
It seems the better way could also be to configure it on the mapper itself, not
the generator, i.e.:
{{mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);}}
I am pretty sure
*com.fasterxml.jackson.core.JsonGenerator.Feature#AUTO_CLOSE_TARGET* is the
right property that is supposed to control this behavior:
[JsonFactory.java#L1474-L1482|https://github.com/FasterXML/jackson-core/blob/2.18/src/main/java/com/fasterxml/jackson/core/JsonFactory.java#L1474-L1482]
> Disable FLUSH_AFTER_WRITE_VALUE to avoid flush per record
> ---------------------------------------------------------
>
> Key: FLINK-35240
> URL: https://issues.apache.org/jira/browse/FLINK-35240
> Project: Flink
> Issue Type: Improvement
> Components: Connectors / FileSystem
> Reporter: Zhongqiang Gong
> Priority: Minor
> Attachments: image-2024-04-26-00-23-29-975.png
>
>
> *Reproduce:*
> * According to user email:
> https://lists.apache.org/thread/9j5z8hv4vjkd54dkzqy1ryyvm0l5rxhc
> * !image-2024-04-26-00-23-29-975.png!
> *Analysis:*
> * `org.apache.flink.formats.csv.CsvBulkWriter#addElement` will flush per
> record.
> *Solution:*
> * I think maybe we can disable `FLUSH_AFTER_WRITE_VALUE` to avoid flush when
> a record added.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)