rohityadav1993 commented on code in PR #16727:
URL: https://github.com/apache/pinot/pull/16727#discussion_r2468681542


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/stats/ColumnarSegmentPreIndexStatsContainer.java:
##########
@@ -0,0 +1,217 @@
+/**
+ * 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.local.segment.creator.impl.stats;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.pinot.segment.spi.creator.ColumnStatistics;
+import org.apache.pinot.segment.spi.creator.SegmentPreIndexStatsCollector;
+import org.apache.pinot.segment.spi.creator.StatsCollectorConfig;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.data.readers.ColumnReader;
+import org.apache.pinot.spi.data.readers.GenericRow;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Stats container that efficiently collects statistics from columnar data 
using ColumnReader instances.
+ *
+ * <p>This implementation collects statistics by iterating column-wise instead 
of row-wise,
+ * which is more efficient for columnar data sources. It supports:
+ * <ul>
+ *   <li>Column-wise statistics collection</li>
+ *   <li>Existing columns from source data</li>
+ *   <li>New columns with default values</li>
+ *   <li>Data type conversions during schema evolution</li>
+ * </ul>
+ *
+ * <p>The statistics are collected using the same underlying collectors as the 
row-based approach
+ * (SegmentPreIndexStatsCollectorImpl) but with more efficient column-wise 
iteration.
+ */
+public class ColumnarSegmentPreIndexStatsContainer implements 
SegmentPreIndexStatsCollector {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ColumnarSegmentPreIndexStatsContainer.class);
+
+  private final Map<String, ColumnReader> _columnReaders;
+  private final StatsCollectorConfig _statsCollectorConfig;
+  private final Schema _targetSchema;
+  private final Map<String, AbstractColumnStatisticsCollector> 
_columnStatsCollectorMap;
+  private int _totalDocCount;
+
+  /**
+   * Create a ColumnarSegmentPreIndexStatsContainer.
+   *
+   * @param columnReaders Map of column name to ColumnReader instances
+   * @param statsCollectorConfig Configuration for statistics collection
+   */
+  public ColumnarSegmentPreIndexStatsContainer(Map<String, ColumnReader> 
columnReaders,
+                                              StatsCollectorConfig 
statsCollectorConfig) {
+    _columnReaders = columnReaders;
+    _statsCollectorConfig = statsCollectorConfig;
+    _targetSchema = statsCollectorConfig.getSchema();
+    _columnStatsCollectorMap = new HashMap<>();
+    _totalDocCount = -1; // indicates unset
+
+    initializeStatsCollectors();

Review Comment:
   updating, I don't see any benefit in delaying the initialization by calling 
it immediately after object creation. These are not service start up objects 
but more to be used in the segment generation flow where there is not much 
benefit by split contructor logic into init method and calling it immediately. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to