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



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/segment/processing/framework/SegmentProcessorFramework.java
##########
@@ -110,11 +113,20 @@ public SegmentProcessorFramework(List<RecordReader> 
recordReaders, SegmentProces
     // Segment creation phase
     LOGGER.info("Beginning segment creation phase on partitions: {}", 
partitionToFileManagerMap.keySet());
     List<File> outputSegmentDirs = new ArrayList<>();
-    SegmentGeneratorConfig generatorConfig =
-        new SegmentGeneratorConfig(_segmentProcessorConfig.getTableConfig(), 
_segmentProcessorConfig.getSchema());
+    TableConfig tableConfig = _segmentProcessorConfig.getTableConfig();
+    Schema schema = _segmentProcessorConfig.getSchema();
+    String segmentNamePrefix = 
_segmentProcessorConfig.getSegmentConfig().getSegmentNamePrefix();
+    SegmentGeneratorConfig generatorConfig = new 
SegmentGeneratorConfig(tableConfig, schema);
     generatorConfig.setOutDir(_segmentsOutputDir.getPath());
-    // TODO: Use NormalizedDateSegmentNameGenerator
-    
generatorConfig.setSegmentNamePrefix(_segmentProcessorConfig.getSegmentConfig().getSegmentNamePrefix());
+
+    if (tableConfig.getIndexingConfig() != null

Review comment:
       I don't think we need to have this check

##########
File path: 
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/creator/name/SegmentNameGeneratorFactory.java
##########
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.segment.spi.creator.name;
+
+import org.apache.pinot.spi.config.table.SegmentsValidationAndRetentionConfig;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.data.DateTimeFieldSpec;
+import org.apache.pinot.spi.data.DateTimeFormatSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.utils.IngestionConfigUtils;
+
+
+public class SegmentNameGeneratorFactory {
+  public static final String SIMPLE_SEGMENT_NAME_GENERATOR = "simple";
+  public static final String NORMALIZED_DATE_SEGMENT_NAME_GENERATOR = 
"normalizedDate";
+
+  private SegmentNameGeneratorFactory() {
+  }
+
+  /**
+   * Create the segment name generator given input configurations
+   */
+  public static SegmentNameGenerator createSegmentNameGenerator(TableConfig 
tableConfig, Schema schema,
+      String prefix, String postfix, boolean excludeSequenceId) {
+    String segmentNameGeneratorType = null;
+    if (tableConfig.getIndexingConfig() != null) {

Review comment:
       It will never be null

##########
File path: 
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/creator/name/SegmentNameGeneratorFactory.java
##########
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.segment.spi.creator.name;
+
+import org.apache.pinot.spi.config.table.SegmentsValidationAndRetentionConfig;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.data.DateTimeFieldSpec;
+import org.apache.pinot.spi.data.DateTimeFormatSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.utils.IngestionConfigUtils;
+
+
+public class SegmentNameGeneratorFactory {
+  public static final String SIMPLE_SEGMENT_NAME_GENERATOR = "simple";
+  public static final String NORMALIZED_DATE_SEGMENT_NAME_GENERATOR = 
"normalizedDate";
+
+  private SegmentNameGeneratorFactory() {
+  }
+
+  /**
+   * Create the segment name generator given input configurations
+   */
+  public static SegmentNameGenerator createSegmentNameGenerator(TableConfig 
tableConfig, Schema schema,
+      String prefix, String postfix, boolean excludeSequenceId) {

Review comment:
       annotate `prefix` and `postfix` as nullable

##########
File path: 
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/creator/name/SegmentNameGeneratorFactory.java
##########
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.segment.spi.creator.name;
+
+import org.apache.pinot.spi.config.table.SegmentsValidationAndRetentionConfig;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.data.DateTimeFieldSpec;
+import org.apache.pinot.spi.data.DateTimeFormatSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.utils.IngestionConfigUtils;
+
+
+public class SegmentNameGeneratorFactory {
+  public static final String SIMPLE_SEGMENT_NAME_GENERATOR = "simple";
+  public static final String NORMALIZED_DATE_SEGMENT_NAME_GENERATOR = 
"normalizedDate";
+
+  private SegmentNameGeneratorFactory() {
+  }
+
+  /**
+   * Create the segment name generator given input configurations
+   */
+  public static SegmentNameGenerator createSegmentNameGenerator(TableConfig 
tableConfig, Schema schema,
+      String prefix, String postfix, boolean excludeSequenceId) {
+    String segmentNameGeneratorType = null;
+    if (tableConfig.getIndexingConfig() != null) {
+      segmentNameGeneratorType = 
tableConfig.getIndexingConfig().getSegmentNameGeneratorType();
+    }
+    if (segmentNameGeneratorType == null || 
segmentNameGeneratorType.isEmpty()) {
+      segmentNameGeneratorType = SIMPLE_SEGMENT_NAME_GENERATOR;
+    }
+
+    String tableName = tableConfig.getTableName();
+    switch (segmentNameGeneratorType) {

Review comment:
       Consider making it case insensitive?

##########
File path: 
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/creator/name/SegmentNameGeneratorFactory.java
##########
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.segment.spi.creator.name;
+
+import org.apache.pinot.spi.config.table.SegmentsValidationAndRetentionConfig;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.data.DateTimeFieldSpec;
+import org.apache.pinot.spi.data.DateTimeFormatSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.utils.IngestionConfigUtils;
+
+
+public class SegmentNameGeneratorFactory {
+  public static final String SIMPLE_SEGMENT_NAME_GENERATOR = "simple";
+  public static final String NORMALIZED_DATE_SEGMENT_NAME_GENERATOR = 
"normalizedDate";
+
+  private SegmentNameGeneratorFactory() {
+  }
+
+  /**
+   * Create the segment name generator given input configurations
+   */
+  public static SegmentNameGenerator createSegmentNameGenerator(TableConfig 
tableConfig, Schema schema,
+      String prefix, String postfix, boolean excludeSequenceId) {
+    String segmentNameGeneratorType = null;
+    if (tableConfig.getIndexingConfig() != null) {
+      segmentNameGeneratorType = 
tableConfig.getIndexingConfig().getSegmentNameGeneratorType();
+    }
+    if (segmentNameGeneratorType == null || 
segmentNameGeneratorType.isEmpty()) {
+      segmentNameGeneratorType = SIMPLE_SEGMENT_NAME_GENERATOR;
+    }
+
+    String tableName = tableConfig.getTableName();
+    switch (segmentNameGeneratorType) {
+      case SIMPLE_SEGMENT_NAME_GENERATOR:
+        if (prefix != null) {
+          return new SimpleSegmentNameGenerator(prefix, postfix);
+        }
+        return new SimpleSegmentNameGenerator(tableName, postfix);
+      case NORMALIZED_DATE_SEGMENT_NAME_GENERATOR:
+        SegmentsValidationAndRetentionConfig validationConfig = 
tableConfig.getValidationConfig();
+        DateTimeFormatSpec dateTimeFormatSpec = null;
+        String timeColumnName = validationConfig.getTimeColumnName();
+        if (timeColumnName != null) {
+          DateTimeFieldSpec dateTimeFieldSpec = 
schema.getSpecForTimeColumn(timeColumnName);
+          if (dateTimeFieldSpec != null) {

Review comment:
       We can add a precondition on it because it should not be null




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