Jackie-Jiang commented on code in PR #19571:
URL: https://github.com/apache/pinot/pull/19571#discussion_r4087883007
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfig.java:
##########
@@ -442,16 +518,36 @@ public void addOpenStructChildConfigs(SegmentMetadataImpl
segmentMetadata) {
FieldIndexConfigsUtil.fromFieldConfig(keyFieldConfig,
childFieldSpec))
.add(StandardIndexes.inverted(), enableInverted ?
IndexConfig.ENABLED : IndexConfig.DISABLED)
.build();
- _indexConfigsByColName.put(childColumn, childConfigs);
+ if (updatedConfigs == null) {
+ updatedConfigs = new HashMap<>(indexConfigsByColName);
+ }
+ updatedConfigs.put(childColumn, childConfigs);
+ }
+ if (updatedConfigs == null) {
+ return this;
}
+ IndexLoadingConfig derived = new IndexLoadingConfig(this);
+ derived._resolvedIndexState =
resolvedIndexState.withIndexConfigsByColName(updatedConfigs);
+ return derived;
}
- public void addKnownColumns(Set<String> columns) {
- if (_knownColumns == null) {
- _knownColumns = new HashSet<>(columns);
- } else {
- _knownColumns.addAll(columns);
+ public void addOpenStructChildConfigs(SegmentMetadataImpl segmentMetadata) {
+ _resolvedIndexState =
withOpenStructChildConfigs(segmentMetadata)._resolvedIndexState;
+ }
+
+ public IndexLoadingConfig withKnownColumns(Set<String> columns) {
+ if (_knownColumns != null && _knownColumns.containsAll(columns)) {
+ return this;
}
- _dirty = true;
+ IndexLoadingConfig derived = new IndexLoadingConfig(this);
+ derived.addKnownColumns(columns);
+ return derived;
+ }
+
+ public void addKnownColumns(Set<String> columns) {
+ Set<String> knownColumns = _knownColumns != null ? new
HashSet<>(_knownColumns) : new HashSet<>();
+ knownColumns.addAll(columns);
+ _knownColumns = knownColumns;
+ _resolvedIndexState = null;
Review Comment:
Small optimization: could `addKnownColumns()` return early when
`_knownColumns != null && _knownColumns.containsAll(columns)`? Otherwise a
no-op addition copies the set and invalidates `_resolvedIndexState`.
`withKnownColumns()` already checks this, so it mainly helps direct callers.
--
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]