XuQianJin-Stars opened a new pull request #6823: [FLINK-10134] UTF-16 support 
for TextInputFormat bug refixed
URL: https://github.com/apache/flink/pull/6823
 
 
   ## What is the purpose of the change
   
   *(This PR is designed to solve the problem of `TextInputFormat` using UTF-16 
encoding to parse files.)*
   
   ## Brief change log
   
   *(To solve this bug, I added a file BOM header encoding check to determine 
the current file encoding, so that when user-defined encoding format and file 
with a BOM header encoding format conflict processing, specific changes in the 
following::)*
   
   - *I add `getBomFileCharset` function to `DelimitedInputFormat.java` to 
detect the current file BOM header coding judgment, mainly `UTF-16BE`, 
`UTF-16LE`, `UTF-8 with BOM header`, `UTF-32BE`, `UTF-32LE` these types, 
default to `UTF-8`.*
   - *I added the `bomCharset`,`fileBomCharsetMap`,`charsetStepSize` variable 
to the `DelimitedInputFormat.java`, `getBomFileCharset(split)` to the `open` 
method, and `getBomCharsetName` to get the 
`bomCharset`,`fileBomCharsetMap`,`charsetStepSize` variable.*The file name that 
has been parsed is used as the key, and the encoded value is inserted as a 
value into the `fileBomCharsetMap`.
   - In the `DelimitedInputFormat.java` method `getCharset()`, the encoding 
logic is added to obtain the encoding of the current file. If the `bomCharset` 
has a value, the charset of the current class is overwritten by the 
`bomCharset` encoding. If the `bomCharset` has no value, the `charset` of the 
current class is taken.
   - Modify the readRecord method logic in `TextInputFormat.java`, using 
`this.getCharset()`, `this.delimiterNewLinePos`, 
`this.delimiterCarrageReturnPos` to support the processing of the end separator 
for each line of multiple encoding formats.
   
   ## Verifying this change
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe 
tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
   
   - *I added `testFileCharset`  and `testFileCharsetReadByMultiSplits` to 
`TextInputFormatTest`.*
   
   ## Does this pull request potentially affect one of the following parts:
   
   - Dependencies (does it add or upgrade a dependency): (yes)
   - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: (yes)
   - The serializers: (no)
   - The runtime per-record code paths (performance sensitive): (no )
   - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes)
   - The S3 file system connector: (no)
   
   ## Documentation
   
   - Does this pull request introduce a new feature? (yes / no)
   - If yes, how is the feature documented? (not applicable / docs / JavaDocs / 
not documented)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to