You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2019/07/26 11:17:05 UTC
[GitHub] [incubator-iotdb] LeiRui opened a new pull request #311: modify
antlr3 to support timeseries path in the number format
LeiRui opened a new pull request #311: modify antlr3 to support timeseries path in the number format
URL: https://github.com/apache/incubator-iotdb/pull/311
To support series path in number format, we have the following logic in TSParser.g already:
```
nodeName
: identifier
| STAR
;
identifier
:
Identifier | integer
;
```
Then the main challenge left here is to teach antlr3 to recognize `integer` in the series path, which is easy to be confused with and recognized as `Float`, `DATETIME` partly because of the "Longest match wins first" rule of Antlr3.
For example,
| integer | float | datetime | seriesPath in the number format |
|------------|------------------------------------------------------------|----------------------------------------------------|------------------------------|
| +12 / -12 / 12 | +12.233 / -12.233 / +12.3332e-1 / -12.3332e+2 / 12.3332 / 12.3332e-1 | 2017-11-1T00:15:00+08:00 / 2017.11.1 00:15:00+08:00 | 8955.1227.223 |
The solution is to do a more elaborate division and some are directly recognized in TSLexer and some are later combined in TSParser:
In TSLexer, we have:
- PositiveInteger, e.g., `+12`
- NegativeInteger, e.g., `-12`
- PositiveFloat, e.g., `+12.233`, `+12.3332e-1 `
- NegativeFloat, e.g., `-12.233`, `-12.3332e-1 `
NOTE that the existence of '+' and '-' help ease the match rule. For those without signs, things get tricky as follows.
- UnsignedInteger, e.g., `12`
- DATETIME, e.g., `2017.11.1 00:15:00+08:00`.
NOTE that here an critical trick is used (see code). If the first lexer rule of DATETIME is not matched, then UnsignedInteger is recognized instead.
- DoubleInScientificNotationSuffix, e.g., `.E+10`.
NOTE that here the same critical trick is used (see code). If the first rule is not matched, then DOT is recognized instead.
In TSParser, we have:
- nonNegativeInteger (which is needed by LIMIT&SLIMIT clause)
- integer
- floatValue
NOTE that "float" shoud not be used as a name as it is reserved.
NOTE that the old FLOAT in the TSLexer is removed and floatValue in TSParser is used instead. It is because we want to support series path in the number format, **which can not be separated from the float number in the lexer level**.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services