Mappings: Remove close() from Mapper
There was only a single actual "use" of close, for a threadlocal in VersionFieldMapper. However, that threadlocal is completely unnecessary, so this change removes the threadlocal and close() altogether.
This commit is contained in:
parent
26ff6e452e
commit
e8e74ae569
|
@ -442,10 +442,6 @@ public class DocumentMapper implements ToXContent {
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
documentParser.close();
|
documentParser.close();
|
||||||
mapping.root.close();
|
|
||||||
for (RootMapper rootMapper : mapping.rootMappers) {
|
|
||||||
rootMapper.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -129,6 +129,4 @@ public interface Mapper extends ToXContent, Iterable<Mapper> {
|
||||||
String name();
|
String name();
|
||||||
|
|
||||||
void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMappingException;
|
void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMappingException;
|
||||||
|
|
||||||
void close();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -564,11 +564,6 @@ public abstract class AbstractFieldMapper implements FieldMapper {
|
||||||
|
|
||||||
protected abstract String contentType();
|
protected abstract String contentType();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
multiFields.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class MultiFields {
|
public static class MultiFields {
|
||||||
|
|
||||||
public static MultiFields empty() {
|
public static MultiFields empty() {
|
||||||
|
@ -702,12 +697,6 @@ public abstract class AbstractFieldMapper implements FieldMapper {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
|
||||||
for (ObjectCursor<FieldMapper> cursor : mappers.values()) {
|
|
||||||
cursor.value.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
if (pathType != Defaults.PATH_TYPE) {
|
if (pathType != Defaults.PATH_TYPE) {
|
||||||
builder.field("path", pathType.name().toLowerCase(Locale.ROOT));
|
builder.field("path", pathType.name().toLowerCase(Locale.ROOT));
|
||||||
|
|
|
@ -335,10 +335,6 @@ public abstract class NumberFieldMapper extends AbstractFieldMapper implements A
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected NumericTokenStream popCachedStream() {
|
protected NumericTokenStream popCachedStream() {
|
||||||
if (fieldType().numericPrecisionStep() == 4) {
|
if (fieldType().numericPrecisionStep() == 4) {
|
||||||
return tokenStream4.get();
|
return tokenStream4.get();
|
||||||
|
|
|
@ -739,20 +739,6 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implements ArrayVal
|
||||||
multiFields.parse(this, context);
|
multiFields.parse(this, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
super.close();
|
|
||||||
if (latMapper != null) {
|
|
||||||
latMapper.close();
|
|
||||||
}
|
|
||||||
if (lonMapper != null) {
|
|
||||||
lonMapper.close();
|
|
||||||
}
|
|
||||||
if (geohashMapper != null) {
|
|
||||||
geohashMapper.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<Mapper> iterator() {
|
public Iterator<Mapper> iterator() {
|
||||||
List<Mapper> extras = new ArrayList<>();
|
List<Mapper> extras = new ArrayList<>();
|
||||||
|
|
|
@ -116,13 +116,6 @@ public class VersionFieldMapper extends AbstractFieldMapper implements RootMappe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ThreadLocal<Field> fieldCache = new ThreadLocal<Field>() {
|
|
||||||
@Override
|
|
||||||
protected Field initialValue() {
|
|
||||||
return new NumericDocValuesField(NAME, -1L);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public VersionFieldMapper(Settings indexSettings) {
|
public VersionFieldMapper(Settings indexSettings) {
|
||||||
super(Defaults.FIELD_TYPE, true, null, indexSettings);
|
super(Defaults.FIELD_TYPE, true, null, indexSettings);
|
||||||
}
|
}
|
||||||
|
@ -134,8 +127,8 @@ public class VersionFieldMapper extends AbstractFieldMapper implements RootMappe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
|
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
|
||||||
// see UidFieldMapper.parseCreateField
|
// see InternalEngine.updateVersion to see where the real version value is set
|
||||||
final Field version = fieldCache.get();
|
final Field version = new NumericDocValuesField(NAME, -1L);
|
||||||
context.version(version);
|
context.version(version);
|
||||||
fields.add(version);
|
fields.add(version);
|
||||||
}
|
}
|
||||||
|
@ -180,9 +173,4 @@ public class VersionFieldMapper extends AbstractFieldMapper implements RootMappe
|
||||||
public void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMappingException {
|
public void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMappingException {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
fieldCache.remove();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -544,13 +544,6 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll, Clonea
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
for (Mapper mapper : mappers.values()) {
|
|
||||||
mapper.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
toXContent(builder, params, null);
|
toXContent(builder, params, null);
|
||||||
|
|
|
@ -236,15 +236,6 @@ public class ExternalMapper extends AbstractFieldMapper {
|
||||||
return Iterators.concat(super.iterator(), Lists.newArrayList(binMapper, boolMapper, pointMapper, shapeMapper, stringMapper).iterator());
|
return Iterators.concat(super.iterator(), Lists.newArrayList(binMapper, boolMapper, pointMapper, shapeMapper, stringMapper).iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
binMapper.close();
|
|
||||||
boolMapper.close();
|
|
||||||
pointMapper.close();
|
|
||||||
shapeMapper.close();
|
|
||||||
stringMapper.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(fieldType().names().shortName());
|
builder.startObject(fieldType().names().shortName());
|
||||||
|
|
|
@ -52,10 +52,6 @@ public class ExternalRootMapper implements RootMapper {
|
||||||
return Collections.emptyIterator();
|
return Collections.emptyIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
return builder.startObject(CONTENT_TYPE).endObject();
|
return builder.startObject(CONTENT_TYPE).endObject();
|
||||||
|
|
Loading…
Reference in New Issue