stym06 commented on code in PR #8779:
URL: https://github.com/apache/pinot/pull/8779#discussion_r883304177


##########
pinot-spi/src/main/java/org/apache/pinot/spi/data/DateTimeFormatSpec.java:
##########
@@ -47,28 +50,75 @@ public class DateTimeFormatSpec {
   public static final int MIN_FORMAT_TOKENS = 3;
   public static final int MAX_FORMAT_TOKENS = 4;
 
+  public static final int FORMAT_TIMEFORMAT_POSITION_PIPE = 0;
+  public static final int FORMAT_PATTERN_POSITION_PIPE = 1;
+  public static final int FORMAT_UNIT_POSITION_PIPE = 1;
+  public static final int FORMAT_SIZE_POSITION_PIPE = 2;
+  public static final int FORMAT_TIMEZONE_POSITION_PIPE = 2;
+  public static final int MIN_FORMAT_TOKENS_PIPE = 1;
+  public static final int MAX_FORMAT_TOKENS_PIPE = 3;
+
   private final String _format;
   private final int _size;
   private final DateTimeFormatUnitSpec _unitSpec;
   private final DateTimeFormatPatternSpec _patternSpec;
 
   public DateTimeFormatSpec(String format) {
     _format = format;
-    validateFormat(format);
-    String[] formatTokens = StringUtils.split(format, COLON_SEPARATOR, 
MAX_FORMAT_TOKENS);
-    if (formatTokens.length == MAX_FORMAT_TOKENS) {
-      _patternSpec = new 
DateTimeFormatPatternSpec(formatTokens[FORMAT_TIMEFORMAT_POSITION],
-          formatTokens[FORMAT_PATTERN_POSITION]);
-    } else {
-      _patternSpec = new 
DateTimeFormatPatternSpec(formatTokens[FORMAT_TIMEFORMAT_POSITION]);
-    }
-    if (_patternSpec.getTimeFormat() == TimeFormat.TIMESTAMP) {
-      // TIMESTAMP type stores millis since epoch
-      _size = 1;
-      _unitSpec = new DateTimeFormatUnitSpec("MILLISECONDS");
+    if (_format.matches(COLON_REGEX)) {
+      validateFormat(format);

Review Comment:
   I changed the return type of the validate call to return the tokens after 
validating. This avoids calling split twice. Is that fine?



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to