shounakmk219 commented on code in PR #10623:
URL: https://github.com/apache/pinot/pull/10623#discussion_r1169743623


##########
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/index/AbstractIndexType.java:
##########
@@ -62,6 +70,38 @@ public IndexReaderFactory<IR> getReaderFactory() {
     return _readerFactory;
   }
 
+  public void convertToNewFormat(TableConfig tableConfig, Schema schema) {
+    Map<String, C> deserialize = getConfig(tableConfig, schema);
+    for (Map.Entry<String, C> entry : deserialize.entrySet()) {
+      AtomicBoolean fieldConfigFound = new AtomicBoolean(false);
+      List<FieldConfig> fieldConfigList = 
Optional.ofNullable(tableConfig.getFieldConfigList())
+          .orElse(List.of())
+          .stream()
+          .map(fc -> {
+            if (fc.getName().equals(entry.getKey())) {
+              fieldConfigFound.set(true);
+              ObjectNode currentIndexes = fc.getIndexes().isNull()
+                  ? new ObjectMapper().createObjectNode()
+                  : (ObjectNode) fc.getIndexes();
+              JsonNode indexes = currentIndexes.set(getPrettyName(), 
entry.getValue().toJsonNode());
+              FieldConfig.Builder builder = new FieldConfig.Builder(fc);
+              builder.withIndexes(indexes);
+              return builder.build();
+            }
+            return fc;
+          })
+          .collect(Collectors.toList());
+      if (!fieldConfigFound.get()) {
+        JsonNode indexes = new 
ObjectMapper().createObjectNode().set(getPrettyName(), 
entry.getValue().toJsonNode());
+        FieldConfig.Builder builder = new FieldConfig.Builder();
+        builder.withName(entry.getKey());
+        builder.withIndexes(indexes);

Review Comment:
   timestamp config will already have its own FieldConfig entry hence it's not 
considered in the flow where new FieldConfig entry is created where its not 
present for a column



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