You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "gortiz (via GitHub)" <gi...@apache.org> on 2023/04/18 12:41:12 UTC
[GitHub] [pinot] gortiz commented on a diff in pull request #10623: WIP: API to get table configs in newer format
gortiz commented on code in PR #10623:
URL: https://github.com/apache/pinot/pull/10623#discussion_r1169976323
##########
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:
Makes sense. It should only be populated in the other case.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org