gortiz commented on code in PR #10191:
URL: https://github.com/apache/pinot/pull/10191#discussion_r1093098424


##########
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/FieldIndexConfigs.java:
##########
@@ -0,0 +1,131 @@
+/**
+ * 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.index;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.google.common.base.Preconditions;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import javax.annotation.Nullable;
+
+
+/**
+ * FieldIndexConfigs are a map like structure that relates index types with 
their configuration, providing a type safe
+ * interface.
+ */
+public class FieldIndexConfigs {
+
+  private final Map<IndexType, IndexDeclaration<?>> _configMap;
+  public static final FieldIndexConfigs EMPTY = new FieldIndexConfigs(new 
HashMap<>());
+
+  private FieldIndexConfigs(Map<IndexType, IndexDeclaration<?>> configMap) {
+    _configMap = Collections.unmodifiableMap(configMap);
+  }
+
+
+  /**
+   * The method most of the code should call to know how is configured a given 
index.
+   *
+   * @param indexType the type of the index we are interested in.
+   * @return How the index has been configured, which can be {@link 
IndexDeclaration#isDeclared() not declared},
+   * {@link IndexDeclaration#isEnabled()} not enabled} or an actual 
configuration object (which can be obtained with
+   * {@link IndexDeclaration#getEnabledConfig()}.
+   */
+  @JsonIgnore
+  public <C, I extends IndexType<C, ?, ?>> IndexDeclaration<C> getConfig(I 
indexType) {
+    @SuppressWarnings("unchecked")
+    IndexDeclaration<C> config = (IndexDeclaration<C>) 
_configMap.get(indexType);
+    if (config == null) {
+      return IndexDeclaration.notDeclared(indexType);
+    }
+    return config;
+  }
+
+  @JsonIgnore
+  public Set<IndexType> getIndexes() {

Review Comment:
   I've removed this method and modified the complete PR to do not use it. It 
doesn't actually makes sense when `FieldIndexConfigs` returns info (even if it 
is undeclared) for all index types. Instead calling code show call 
`IndexService.getInstance().getAllIndexes()`, which is in the corresponding PR



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