keep the uidField around so we don't have to look it up
This commit is contained in:
parent
e2e25ffea3
commit
c09ee82ef5
|
@ -120,6 +120,10 @@ public class UidField extends Field {
|
||||||
|
|
||||||
private long version;
|
private long version;
|
||||||
|
|
||||||
|
public UidField(String uid) {
|
||||||
|
this(UidFieldMapper.NAME, uid, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public UidField(String name, String uid, long version) {
|
public UidField(String name, String uid, long version) {
|
||||||
super(name, UidFieldMapper.Defaults.UID_FIELD_TYPE);
|
super(name, UidFieldMapper.Defaults.UID_FIELD_TYPE);
|
||||||
this.uid = uid;
|
this.uid = uid;
|
||||||
|
|
|
@ -37,6 +37,11 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class BloomFilterPostingsFormatProvider extends AbstractPostingsFormatProvider {
|
public class BloomFilterPostingsFormatProvider extends AbstractPostingsFormatProvider {
|
||||||
|
|
||||||
|
public static final class Defaults {
|
||||||
|
public static final float MAX_SATURATION = 0.1f;
|
||||||
|
public static final float SATURATION_LIMIT = 0.9f;
|
||||||
|
}
|
||||||
|
|
||||||
private final float desiredMaxSaturation;
|
private final float desiredMaxSaturation;
|
||||||
private final float saturationLimit;
|
private final float saturationLimit;
|
||||||
private final PostingsFormatProvider delegate;
|
private final PostingsFormatProvider delegate;
|
||||||
|
@ -45,8 +50,8 @@ public class BloomFilterPostingsFormatProvider extends AbstractPostingsFormatPro
|
||||||
@Inject
|
@Inject
|
||||||
public BloomFilterPostingsFormatProvider(@IndexSettings Settings indexSettings, @Nullable Map<String, Factory> postingFormatFactories, @Assisted String name, @Assisted Settings postingsFormatSettings) {
|
public BloomFilterPostingsFormatProvider(@IndexSettings Settings indexSettings, @Nullable Map<String, Factory> postingFormatFactories, @Assisted String name, @Assisted Settings postingsFormatSettings) {
|
||||||
super(name);
|
super(name);
|
||||||
this.desiredMaxSaturation = postingsFormatSettings.getAsFloat("desired_max_saturation", 0.1f);
|
this.desiredMaxSaturation = postingsFormatSettings.getAsFloat("desired_max_saturation", Defaults.MAX_SATURATION);
|
||||||
this.saturationLimit = postingsFormatSettings.getAsFloat("saturation_limit", 0.9f);
|
this.saturationLimit = postingsFormatSettings.getAsFloat("saturation_limit", Defaults.SATURATION_LIMIT);
|
||||||
this.delegate = Helper.lookup(indexSettings, postingsFormatSettings.get("delegate"), postingFormatFactories);
|
this.delegate = Helper.lookup(indexSettings, postingsFormatSettings.get("delegate"), postingFormatFactories);
|
||||||
this.postingsFormat = new BloomFilteringPostingsFormat(
|
this.postingsFormat = new BloomFilteringPostingsFormat(
|
||||||
delegate.get(),
|
delegate.get(),
|
||||||
|
@ -71,11 +76,15 @@ public class BloomFilterPostingsFormatProvider extends AbstractPostingsFormatPro
|
||||||
return postingsFormat;
|
return postingsFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CustomBloomFilterFactory extends BloomFilterFactory {
|
public static class CustomBloomFilterFactory extends BloomFilterFactory {
|
||||||
|
|
||||||
private final float desiredMaxSaturation;
|
private final float desiredMaxSaturation;
|
||||||
private final float saturationLimit;
|
private final float saturationLimit;
|
||||||
|
|
||||||
|
public CustomBloomFilterFactory() {
|
||||||
|
this(Defaults.MAX_SATURATION, Defaults.SATURATION_LIMIT);
|
||||||
|
}
|
||||||
|
|
||||||
CustomBloomFilterFactory(float desiredMaxSaturation, float saturationLimit) {
|
CustomBloomFilterFactory(float desiredMaxSaturation, float saturationLimit) {
|
||||||
this.desiredMaxSaturation = desiredMaxSaturation;
|
this.desiredMaxSaturation = desiredMaxSaturation;
|
||||||
this.saturationLimit = saturationLimit;
|
this.saturationLimit = saturationLimit;
|
||||||
|
|
|
@ -45,9 +45,9 @@ public class PostingFormats {
|
||||||
buildInPostingFormatsX.put("memory", new PreBuiltPostingsFormatProvider.Factory("memory", new MemoryPostingsFormat()));
|
buildInPostingFormatsX.put("memory", new PreBuiltPostingsFormatProvider.Factory("memory", new MemoryPostingsFormat()));
|
||||||
// LUCENE UPGRADE: Need to change this to the relevant ones on a lucene upgrade
|
// LUCENE UPGRADE: Need to change this to the relevant ones on a lucene upgrade
|
||||||
buildInPostingFormatsX.put("pulsing", new PreBuiltPostingsFormatProvider.Factory("pulsing", new Pulsing40PostingsFormat()));
|
buildInPostingFormatsX.put("pulsing", new PreBuiltPostingsFormatProvider.Factory("pulsing", new Pulsing40PostingsFormat()));
|
||||||
buildInPostingFormatsX.put("bloom_pulsing", new PreBuiltPostingsFormatProvider.Factory("bloom_pulsing", new BloomFilteringPostingsFormat(new Pulsing40PostingsFormat())));
|
buildInPostingFormatsX.put("bloom_pulsing", new PreBuiltPostingsFormatProvider.Factory("bloom_pulsing", new BloomFilteringPostingsFormat(new Pulsing40PostingsFormat(), new BloomFilterPostingsFormatProvider.CustomBloomFilterFactory())));
|
||||||
buildInPostingFormatsX.put("default", new PreBuiltPostingsFormatProvider.Factory("default", new Lucene40PostingsFormat()));
|
buildInPostingFormatsX.put("default", new PreBuiltPostingsFormatProvider.Factory("default", new Lucene40PostingsFormat()));
|
||||||
buildInPostingFormatsX.put("bloom_default", new PreBuiltPostingsFormatProvider.Factory("bloom_default", new BloomFilteringPostingsFormat(new Lucene40PostingsFormat())));
|
buildInPostingFormatsX.put("bloom_default", new PreBuiltPostingsFormatProvider.Factory("bloom_default", new BloomFilteringPostingsFormat(new Lucene40PostingsFormat(), new BloomFilterPostingsFormatProvider.CustomBloomFilterFactory())));
|
||||||
|
|
||||||
builtInPostingFormats = buildInPostingFormatsX.immutableMap();
|
builtInPostingFormats = buildInPostingFormatsX.immutableMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.elasticsearch.index.VersionType;
|
||||||
import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit;
|
import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit;
|
||||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||||
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
|
|
||||||
import org.elasticsearch.index.shard.IndexShardComponent;
|
import org.elasticsearch.index.shard.IndexShardComponent;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.index.translog.Translog;
|
import org.elasticsearch.index.translog.Translog;
|
||||||
|
@ -475,7 +474,7 @@ public interface Engine extends IndexShardComponent, CloseableComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public UidField uidField() {
|
public UidField uidField() {
|
||||||
return (UidField) doc.rootDoc().getField(UidFieldMapper.NAME);
|
return doc.uid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -603,7 +602,7 @@ public interface Engine extends IndexShardComponent, CloseableComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public UidField uidField() {
|
public UidField uidField() {
|
||||||
return (UidField) doc.rootDoc().getField(UidFieldMapper.NAME);
|
return doc.uid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Index startTime(long startTime) {
|
public Index startTime(long startTime) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.lucene.document.Document;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.lucene.all.AllEntries;
|
import org.elasticsearch.common.lucene.all.AllEntries;
|
||||||
|
import org.elasticsearch.common.lucene.uid.UidField;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.index.analysis.AnalysisService;
|
import org.elasticsearch.index.analysis.AnalysisService;
|
||||||
|
@ -65,7 +66,7 @@ public class ParseContext {
|
||||||
|
|
||||||
private DocumentMapper.ParseListener listener;
|
private DocumentMapper.ParseListener listener;
|
||||||
|
|
||||||
private String uid;
|
private UidField uid;
|
||||||
|
|
||||||
private StringBuilder stringBuilder = new StringBuilder();
|
private StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
@ -218,14 +219,14 @@ public class ParseContext {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String uid() {
|
public UidField uid() {
|
||||||
return this.uid;
|
return this.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Really, just the uid mapper should set this.
|
* Really, just the uid mapper should set this.
|
||||||
*/
|
*/
|
||||||
public void uid(String uid) {
|
public void uid(UidField uid) {
|
||||||
this.uid = uid;
|
this.uid = uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper;
|
||||||
import org.apache.lucene.analysis.Analyzer;
|
import org.apache.lucene.analysis.Analyzer;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
|
import org.elasticsearch.common.lucene.uid.UidField;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -31,7 +32,7 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class ParsedDocument {
|
public class ParsedDocument {
|
||||||
|
|
||||||
private final String uid;
|
private final UidField uid;
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
|
@ -54,10 +55,10 @@ public class ParsedDocument {
|
||||||
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 mappingsModified) {
|
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, mappingsModified);
|
this(new UidField(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 mappingsModified) {
|
public ParsedDocument(UidField 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;
|
||||||
|
@ -70,7 +71,7 @@ public class ParsedDocument {
|
||||||
this.mappingsModified = mappingsModified;
|
this.mappingsModified = mappingsModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String uid() {
|
public UidField uid() {
|
||||||
return this.uid;
|
return this.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,12 +165,12 @@ public class UidFieldMapper extends AbstractFieldMapper<Uid> implements Internal
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Field parseCreateField(ParseContext context) throws IOException {
|
protected Field parseCreateField(ParseContext context) throws IOException {
|
||||||
context.uid(Uid.createUid(context.stringBuilder(), context.type(), context.id()));
|
|
||||||
// so, caching uid stream and field is fine
|
// so, caching uid stream and field is fine
|
||||||
// since we don't do any mapping parsing without immediate indexing
|
// since we don't do any mapping parsing without immediate indexing
|
||||||
// and, when percolating, we don't index the uid
|
// and, when percolating, we don't index the uid
|
||||||
UidField field = fieldCache.get();
|
UidField field = fieldCache.get();
|
||||||
field.setUid(context.uid());
|
field.setUid(Uid.createUid(context.stringBuilder(), context.type(), context.id()));
|
||||||
|
context.uid(field);
|
||||||
return field; // version get updated by the engine
|
return field; // version get updated by the engine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
DocumentMapper docMapper = mapperService.documentMapperWithAutoCreate(source.type());
|
DocumentMapper docMapper = mapperService.documentMapperWithAutoCreate(source.type());
|
||||||
ParsedDocument doc = docMapper.parse(source);
|
ParsedDocument doc = docMapper.parse(source);
|
||||||
return new Engine.Create(docMapper, docMapper.uidMapper().term(doc.uid()), doc).startTime(startTime);
|
return new Engine.Create(docMapper, docMapper.uidMapper().term(doc.uid().uid()), doc).startTime(startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -316,7 +316,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
DocumentMapper docMapper = mapperService.documentMapperWithAutoCreate(source.type());
|
DocumentMapper docMapper = mapperService.documentMapperWithAutoCreate(source.type());
|
||||||
ParsedDocument doc = docMapper.parse(source);
|
ParsedDocument doc = docMapper.parse(source);
|
||||||
return new Engine.Index(docMapper, docMapper.uidMapper().term(doc.uid()), doc).startTime(startTime);
|
return new Engine.Index(docMapper, docMapper.uidMapper().term(doc.uid().uid()), doc).startTime(startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -371,7 +371,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
||||||
query = filterQueryIfNeeded(query, types);
|
query = filterQueryIfNeeded(query, types);
|
||||||
|
|
||||||
Filter aliasFilter = indexAliasesService.aliasFilter(filteringAliases);
|
Filter aliasFilter = indexAliasesService.aliasFilter(filteringAliases);
|
||||||
Filter parentFilter = mapperService.hasNested() ? indexCache.filter().cache(NonNestedDocsFilter.INSTANCE) : null;
|
Filter parentFilter = mapperService.hasNested() ? indexCache.filter().cache(NonNestedDocsFilter.INSTANCE) : null;
|
||||||
return new Engine.DeleteByQuery(query, querySource, filteringAliases, aliasFilter, parentFilter, types).startTime(startTime);
|
return new Engine.DeleteByQuery(query, querySource, filteringAliases, aliasFilter, parentFilter, types).startTime(startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue