wu-sheng commented on a change in pull request #8706:
URL: https://github.com/apache/skywalking/pull/8706#discussion_r830187354
##########
File path:
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/IndexStructures.java
##########
@@ -113,28 +113,25 @@ private Fields(Mappings mapping) {
* Returns ture when the input fields have already been stored in the
properties.
*/
private boolean containsAllFields(Fields fields) {
- return fields.properties.entrySet().stream()
- .allMatch(item ->
this.properties.containsKey(item.getKey()));
+ if (this.properties.size() < fields.properties.size()) {
+ return false;
+ }
+ boolean isContains = fields.properties.entrySet().stream()
+ .allMatch(item ->
Objects.equals(properties.get(item.getKey()), item.getValue()));
+ if (!isContains) {
+ return false;
+ }
+ return Objects.equals(this.source, fields.source);
}
/**
- * Append new fields to the properties when have new fields.
+ * Append new fields and update.
+ * Properties combine input and exist, update property's attribute,
won't remove old one.
+ * Source will be updated to the input.
*/
private void appendNewFields(Fields fields) {
- Map<String, Object> newFields =
- fields.properties.entrySet()
- .stream()
- .filter(e ->
!this.properties.containsKey(e.getKey()))
- .collect(Collectors.toMap(
- Map.Entry::getKey,
- Map.Entry::getValue
- ));
- properties.putAll(newFields);
- if (source != null) {
- Set<String> exclude = source.getExcludes();
- Set<String> newExclude = fields.source.getExcludes();
- exclude.addAll(newExclude);
- }
+ properties.putAll(fields.properties);
Review comment:
**Warning**, if there are properties conflicts, same key with different
values, they would override each other according to booting sequence. Unless we
change booting process as merging modules before merging with existing
templates and indices, we can't add check mechanism and warnings.
--
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]