change mappersAdded flag to mappingsModified to better reflect any possible change in mappings, not just additions

This commit is contained in:
Shay Banon 2012-08-20 13:36:28 +02:00
parent 79cb0eafc4
commit e1fe89389c
7 changed files with 21 additions and 21 deletions

View File

@ -168,7 +168,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
indexRequest.version(version); indexRequest.version(version);
// update mapping on master if needed, we won't update changes to the same type, since once its changed, it won't have mappers added // update mapping on master if needed, we won't update changes to the same type, since once its changed, it won't have mappers added
if (op.parsedDoc().mappersAdded()) { if (op.parsedDoc().mappingsModified()) {
if (mappingsToUpdate == null) { if (mappingsToUpdate == null) {
mappingsToUpdate = Sets.newHashSet(); mappingsToUpdate = Sets.newHashSet();
} }

View File

@ -222,7 +222,7 @@ public class TransportIndexAction extends TransportShardReplicationOperationActi
// ignore // ignore
} }
} }
if (op.parsedDoc().mappersAdded()) { if (op.parsedDoc().mappingsModified()) {
updateMappingOnMaster(request); updateMappingOnMaster(request);
} }
// update the version on the request, so it will be used for the replicas // update the version on the request, so it will be used for the replicas

View File

@ -454,7 +454,7 @@ public class DocumentMapper implements ToXContent {
context.reset(parser, new Document(), source, listener); context.reset(parser, new Document(), source, listener);
// on a newly created instance of document mapper, we always consider it as new mappers that have been added // on a newly created instance of document mapper, we always consider it as new mappers that have been added
if (initMappersAdded) { if (initMappersAdded) {
context.addedMapper(); context.setMappingsModified();
initMappersAdded = false; initMappersAdded = false;
} }
@ -518,7 +518,7 @@ public class DocumentMapper implements ToXContent {
Collections.reverse(context.docs()); Collections.reverse(context.docs());
} }
ParsedDocument doc = new ParsedDocument(context.uid(), context.id(), context.type(), source.routing(), source.timestamp(), source.ttl(), context.docs(), context.analyzer(), ParsedDocument doc = new ParsedDocument(context.uid(), context.id(), context.type(), source.routing(), source.timestamp(), source.ttl(), context.docs(), context.analyzer(),
context.source(), context.mappersAdded()).parent(source.parent()); context.source(), context.mappingsModified()).parent(source.parent());
// reset the context to free up memory // reset the context to free up memory
context.reset(null, null, null, null); context.reset(null, null, null, null);
return doc; return doc;

View File

@ -72,7 +72,7 @@ public class ParseContext {
private Map<String, String> ignoredValues = new HashMap<String, String>(); private Map<String, String> ignoredValues = new HashMap<String, String>();
private boolean mappersAdded = false; private boolean mappingsModified = false;
private boolean externalValueSet; private boolean externalValueSet;
@ -103,7 +103,7 @@ public class ParseContext {
this.sourceToParse = source; this.sourceToParse = source;
this.source = source == null ? null : sourceToParse.source(); this.source = source == null ? null : sourceToParse.source();
this.path.reset(); this.path.reset();
this.mappersAdded = false; this.mappingsModified = false;
this.listener = listener == null ? DocumentMapper.ParseListener.EMPTY : listener; this.listener = listener == null ? DocumentMapper.ParseListener.EMPTY : listener;
this.allEntries = new AllEntries(); this.allEntries = new AllEntries();
this.ignoredValues.clear(); this.ignoredValues.clear();
@ -117,12 +117,12 @@ public class ParseContext {
return this.docMapperParser; return this.docMapperParser;
} }
public boolean mappersAdded() { public boolean mappingsModified() {
return this.mappersAdded; return this.mappingsModified;
} }
public void addedMapper() { public void setMappingsModified() {
this.mappersAdded = true; this.mappingsModified = true;
} }
public String index() { public String index() {

View File

@ -49,15 +49,15 @@ public class ParsedDocument {
private final BytesReference source; private final BytesReference source;
private boolean mappersAdded; private boolean mappingsModified;
private String parent; private String parent;
public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, Document document, Analyzer analyzer, BytesReference source, boolean mappersAdded) { public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, Document document, Analyzer analyzer, BytesReference source, boolean mappingsModified) {
this(uid, id, type, routing, timestamp, ttl, Arrays.asList(document), analyzer, source, mappersAdded); this(uid, id, type, routing, timestamp, ttl, Arrays.asList(document), analyzer, source, mappingsModified);
} }
public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, List<Document> documents, Analyzer analyzer, BytesReference source, boolean mappersAdded) { public ParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, List<Document> documents, Analyzer analyzer, BytesReference source, boolean mappingsModified) {
this.uid = uid; this.uid = uid;
this.id = id; this.id = id;
this.type = type; this.type = type;
@ -67,7 +67,7 @@ public class ParsedDocument {
this.documents = documents; this.documents = documents;
this.source = source; this.source = source;
this.analyzer = analyzer; this.analyzer = analyzer;
this.mappersAdded = mappersAdded; this.mappingsModified = mappingsModified;
} }
public String uid() { public String uid() {
@ -120,10 +120,10 @@ public class ParsedDocument {
} }
/** /**
* Has the parsed document caused for new mappings to be added. * Has the parsed document caused mappings to be modified?
*/ */
public boolean mappersAdded() { public boolean mappingsModified() {
return mappersAdded; return mappingsModified;
} }
public String toString() { public String toString() {

View File

@ -521,7 +521,7 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll {
putMapper(objectMapper); putMapper(objectMapper);
// now re add it // now re add it
context.path().add(currentFieldName); context.path().add(currentFieldName);
context.addedMapper(); context.setMappingsModified();
} }
} }
// traverse and parse outside of the mutex // traverse and parse outside of the mutex
@ -757,7 +757,7 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll {
} }
} }
putMapper(mapper); putMapper(mapper);
context.addedMapper(); context.setMappingsModified();
} }
} }
if (newMapper) { if (newMapper) {

View File

@ -362,7 +362,7 @@ public class PercolatorExecutor extends AbstractIndexComponent {
indexCache.clear(searcher.getIndexReader()); indexCache.clear(searcher.getIndexReader());
} }
return new Response(matches, request.doc().mappersAdded()); return new Response(matches, request.doc().mappingsModified());
} }
private IndexService percolatorIndexServiceSafe() { private IndexService percolatorIndexServiceSafe() {