flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From twalthr <...@git.apache.org>
Subject [GitHub] flink pull request #2303: [FLINK-4248] [core] [table] CsvTableSource does no...
Date Wed, 21 Sep 2016 10:37:02 GMT
Github user twalthr commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2303#discussion_r79804375
  
    --- Diff: flink-core/src/main/java/org/apache/flink/types/parser/FieldParser.java ---
    @@ -174,6 +174,62 @@ protected void setErrorState(ParseErrorState error) {
     	public ParseErrorState getErrorState() {
     		return this.errorState;
     	}
    +
    +	/**
    +	 * Returns the end position of a string with a numeric format (like XXXX-XX-XX). Sets
the error state if the
    +	 * string contains leading/trailing whitespaces or if the column is empty.
    +	 *
    +	 * @return the end position of the string or -1 if an error occurred
    +	 */
    +	public final int formattedStringEndPos(byte[] bytes, int startPos, int limit, byte[]
delimiter) {
    +		int len = startPos;
    +
    +		final int delimLimit = limit - delimiter.length + 1;
    +
    +		while (len < limit) {
    +			if (len < delimLimit && delimiterNext(bytes, len, delimiter)) {
    +				if (len == startPos) {
    +					setErrorState(ParseErrorState.EMPTY_COLUMN);
    +					return -1;
    +				}
    +				break;
    +			}
    +			len++;
    +		}
    +
    +		if (len > startPos &&
    +				(Character.isWhitespace(bytes[startPos]) || Character.isWhitespace(bytes[(len - 1)])))
{
    +			setErrorState(ParseErrorState.NUMERIC_VALUE_ILLEGAL_CHARACTER);
    +			return -1;
    +		}
    +
    +		return len;
    +	}
    +
    +	/**
    +	 * Returns a string with a numeric format (like XXXX-XX-XX). Throws an exception if
the
    --- End diff --
    
    Why not? Only parsers with a numeric format will use this method.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message