You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/09/09 23:03:24 UTC

[GitHub] [pinot] Jackie-Jiang commented on a change in pull request #7085: modify segment generator to not return illegal filenames

Jackie-Jiang commented on a change in pull request #7085:
URL: https://github.com/apache/pinot/pull/7085#discussion_r705774287



##########
File path: pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/creator/name/NormalizedDateSegmentNameGenerator.java
##########
@@ -52,6 +52,10 @@
   public NormalizedDateSegmentNameGenerator(String tableName, @Nullable String segmentNamePrefix,
       boolean excludeSequenceId, @Nullable String pushType, @Nullable String pushFrequency,
       @Nullable DateTimeFormatSpec dateTimeFormatSpec) {
+    Preconditions.checkArgument(
+        tableName != null && !tableName.matches(INVALID_SEGMENT_NAME_REGEX));
+    Preconditions.checkArgument(
+        segmentNamePrefix == null || !segmentNamePrefix.matches(INVALID_SEGMENT_NAME_REGEX));

Review comment:
       Let's check the `_segmentNamePrefix` instead

##########
File path: pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/creator/name/SimpleSegmentNameGenerator.java
##########
@@ -39,12 +40,20 @@
   private final String _segmentNamePostfix;
 
   public SimpleSegmentNameGenerator(String segmentNamePrefix, @Nullable String segmentNamePostfix) {
+    Preconditions.checkArgument(
+        segmentNamePrefix != null && !segmentNamePrefix.matches(INVALID_SEGMENT_NAME_REGEX));
+    Preconditions.checkArgument(
+        segmentNamePostfix == null || !segmentNamePostfix.matches(INVALID_SEGMENT_NAME_REGEX));
     _segmentNamePrefix = segmentNamePrefix;
     _segmentNamePostfix = segmentNamePostfix;
   }
 
   @Override
   public String generateSegmentName(int sequenceId, @Nullable Object minTimeValue, @Nullable Object maxTimeValue) {
+    Preconditions.checkArgument(
+        minTimeValue == null  || !minTimeValue.toString().matches(INVALID_SEGMENT_NAME_REGEX));

Review comment:
       (code style) extra space?

##########
File path: pinot-segment-spi/src/test/java/org/apache/pinot/segment/spi/creator/name/NormalizedDateSegmentNameGeneratorTest.java
##########
@@ -20,20 +20,24 @@
 
 import java.util.concurrent.TimeUnit;
 import org.apache.pinot.spi.data.DateTimeFormatSpec;
+import org.testng.Assert;
 import org.testng.annotations.Test;
 
 import static org.testng.Assert.assertEquals;
 
 
 public class NormalizedDateSegmentNameGeneratorTest {
   private static final String TABLE_NAME = "myTable";
+  private static final String MALFORMED_TABLE_NAME = "my/Table";
   private static final String SEGMENT_NAME_PREFIX = "myTable_daily";
+  private static final String MALFORMED_SEGMENT_NAME_PREFIX = "myTable\\daily";
   private static final String APPEND_PUSH_TYPE = "APPEND";
   private static final String REFRESH_PUSH_TYPE = "REFRESH";
   private static final String EPOCH_TIME_FORMAT = "EPOCH";
   private static final String SIMPLE_DATE_TIME_FORMAT = "SIMPLE_DATE_FORMAT";
   private static final String LONG_SIMPLE_DATE_FORMAT = "yyyyMMdd";
   private static final String STRING_SIMPLE_DATE_FORMAT = "yyyy-MM-dd";
+  private static final String STRING_SLASH_DATE_FORMAT = "yyyy/MM/dd";

Review comment:
       `MALFORMED_SIMPLE_DATE_FORMAT`?




-- 
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-unsubscribe@pinot.apache.org

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



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