Java Code Examples for org.apache.flink.types.parser.StringValueParser
The following examples show how to use
org.apache.flink.types.parser.StringValueParser. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Flink-CEPplus Source File: GenericCsvInputFormat.java License: Apache License 2.0 | 5 votes |
@Override public void open(FileInputSplit split) throws IOException { super.open(split); // instantiate the parsers FieldParser<?>[] parsers = new FieldParser<?>[fieldTypes.length]; for (int i = 0; i < fieldTypes.length; i++) { if (fieldTypes[i] != null) { Class<? extends FieldParser<?>> parserType = FieldParser.getParserForType(fieldTypes[i]); if (parserType == null) { throw new RuntimeException("No parser available for type '" + fieldTypes[i].getName() + "'."); } FieldParser<?> p = InstantiationUtil.instantiate(parserType, FieldParser.class); p.setCharset(getCharset()); if (this.quotedStringParsing) { if (p instanceof StringParser) { ((StringParser)p).enableQuotedStringParsing(this.quoteCharacter); } else if (p instanceof StringValueParser) { ((StringValueParser)p).enableQuotedStringParsing(this.quoteCharacter); } } parsers[i] = p; } } this.fieldParsers = parsers; // skip the first line, if we are at the beginning of a file and have the option set if (this.skipFirstLineAsHeader && this.splitStart == 0) { readLine(); // read and ignore } }
Example 2
Source Project: flink Source File: GenericCsvInputFormat.java License: Apache License 2.0 | 5 votes |
@Override public void open(FileInputSplit split) throws IOException { super.open(split); // instantiate the parsers FieldParser<?>[] parsers = new FieldParser<?>[fieldTypes.length]; for (int i = 0; i < fieldTypes.length; i++) { if (fieldTypes[i] != null) { Class<? extends FieldParser<?>> parserType = FieldParser.getParserForType(fieldTypes[i]); if (parserType == null) { throw new RuntimeException("No parser available for type '" + fieldTypes[i].getName() + "'."); } FieldParser<?> p = InstantiationUtil.instantiate(parserType, FieldParser.class); p.setCharset(getCharset()); if (this.quotedStringParsing) { if (p instanceof StringParser) { ((StringParser)p).enableQuotedStringParsing(this.quoteCharacter); } else if (p instanceof StringValueParser) { ((StringValueParser)p).enableQuotedStringParsing(this.quoteCharacter); } } parsers[i] = p; } } this.fieldParsers = parsers; // skip the first line, if we are at the beginning of a file and have the option set if (this.skipFirstLineAsHeader && this.splitStart == 0) { readLine(); // read and ignore } }
Example 3
Source Project: flink Source File: GenericCsvInputFormat.java License: Apache License 2.0 | 5 votes |
@Override public void open(FileInputSplit split) throws IOException { super.open(split); // instantiate the parsers FieldParser<?>[] parsers = new FieldParser<?>[fieldTypes.length]; for (int i = 0; i < fieldTypes.length; i++) { if (fieldTypes[i] != null) { Class<? extends FieldParser<?>> parserType = FieldParser.getParserForType(fieldTypes[i]); if (parserType == null) { throw new RuntimeException("No parser available for type '" + fieldTypes[i].getName() + "'."); } FieldParser<?> p = InstantiationUtil.instantiate(parserType, FieldParser.class); p.setCharset(getCharset()); if (this.quotedStringParsing) { if (p instanceof StringParser) { ((StringParser)p).enableQuotedStringParsing(this.quoteCharacter); } else if (p instanceof StringValueParser) { ((StringValueParser)p).enableQuotedStringParsing(this.quoteCharacter); } } parsers[i] = p; } } this.fieldParsers = parsers; // skip the first line, if we are at the beginning of a file and have the option set if (this.skipFirstLineAsHeader && this.splitStart == 0) { readLine(); // read and ignore } }