gather the field data that are changed

(we will make use of that later)
This commit is contained in:
Shay Banon 2013-01-24 15:55:15 +01:00
parent 98a674fc6e
commit a39469a252
2 changed files with 26 additions and 4 deletions

View File

@ -21,6 +21,8 @@ package org.elasticsearch.index.mapper;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -35,6 +37,8 @@ public class MergeContext {
private final FieldMapperListener.Aggregator newFieldMappers = new FieldMapperListener.Aggregator();
private final ObjectMapperListener.Aggregator newObjectMappers = new ObjectMapperListener.Aggregator();
private List<FieldMapper> fieldDataChanges = null;
public MergeContext(DocumentMapper documentMapper, DocumentMapper.MergeFlags mergeFlags) {
this.documentMapper = documentMapper;
this.mergeFlags = mergeFlags;
@ -67,4 +71,18 @@ public class MergeContext {
public String[] buildConflicts() {
return mergeConflicts.toArray(new String[mergeConflicts.size()]);
}
public void addFieldDataChange(FieldMapper mapper) {
if (fieldDataChanges == null) {
fieldDataChanges = new ArrayList<FieldMapper>();
}
fieldDataChanges.add(mapper);
}
public List<FieldMapper> fieldMapperChanges() {
if (fieldDataChanges == null) {
return Collections.emptyList();
}
return fieldDataChanges;
}
}

View File

@ -19,6 +19,7 @@
package org.elasticsearch.index.mapper.core;
import com.google.common.base.Objects;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
@ -583,10 +584,13 @@ public abstract class AbstractFieldMapper<T> implements FieldMapper<T>, Mapper {
this.postingsFormat = fieldMergeWith.postingsFormat;
}
if (fieldMergeWith.customFieldDataSettings != null) {
this.customFieldDataSettings = fieldMergeWith.customFieldDataSettings;
this.fieldDataType = new FieldDataType(defaultFieldDataType().getType(),
ImmutableSettings.builder().put(defaultFieldDataType().getSettings()).put(this.customFieldDataSettings)
);
if (!Objects.equal(fieldMergeWith.customFieldDataSettings, this.customFieldDataSettings)) {
this.customFieldDataSettings = fieldMergeWith.customFieldDataSettings;
this.fieldDataType = new FieldDataType(defaultFieldDataType().getType(),
ImmutableSettings.builder().put(defaultFieldDataType().getSettings()).put(this.customFieldDataSettings)
);
mergeContext.addFieldDataChange(this);
}
}
}
}