tarun11Mavani commented on code in PR #18710:
URL: https://github.com/apache/pinot/pull/18710#discussion_r3386321604
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/creator/impl/stats/AbstractColumnStatisticsCollector.java:
##########
@@ -56,13 +56,28 @@ public abstract class AbstractColumnStatisticsCollector
implements ColumnStatist
protected Comparable _previousValue = null;
public AbstractColumnStatisticsCollector(String column, StatsCollectorConfig
statsCollectorConfig) {
- _fieldSpec = statsCollectorConfig.getFieldSpecForColumn(column);
- Preconditions.checkArgument(_fieldSpec != null, "Failed to find column:
%s", column);
- _storedType = _fieldSpec.getDataType().getStoredType();
- _sorted = _fieldSpec.isSingleValueField();
- _fieldConfig = statsCollectorConfig.getFieldConfigForColumn(column);
- _partitionFunction = statsCollectorConfig.getPartitionFunction(column);
- _partitions = _partitionFunction != null ? new HashSet<>() : null;
+ this(getRequiredFieldSpec(column, statsCollectorConfig),
+ statsCollectorConfig.getFieldConfigForColumn(column),
+ statsCollectorConfig.getPartitionFunction(column));
+ }
+
+ /// Constructs a collector directly from a [FieldSpec], without a
[StatsCollectorConfig]. Lets callers
+ /// that operate outside schema-driven segment generation (e.g. OPEN_STRUCT
materialized child columns,
+ /// whose synthetic columns exist in no schema) reuse the standard stats
collectors.
+ public AbstractColumnStatisticsCollector(FieldSpec fieldSpec, @Nullable
FieldConfig fieldConfig,
+ @Nullable PartitionFunction partitionFunction) {
+ _fieldSpec = fieldSpec;
+ _storedType = fieldSpec.getDataType().getStoredType();
+ _sorted = fieldSpec.isSingleValueField();
+ _fieldConfig = fieldConfig;
+ _partitionFunction = partitionFunction;
+ _partitions = partitionFunction != null ? new HashSet<>() : null;
+ }
+
+ private static FieldSpec getRequiredFieldSpec(String column,
StatsCollectorConfig statsCollectorConfig) {
Review Comment:
Yes — OPEN_STRUCT child columns are synthetic (not in the user schema), so
they don't have a `StatsCollectorConfig` or `Schema`. This constructor lets
`StatsCollectorUtil.createStatsCollector(FieldSpec, FieldConfig)` create
collectors from just a `FieldSpec` + `FieldConfig`.
All 7 scalar collectors delegate to it, so inlining would duplicate the
initialization logic across each one.
--
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]