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() {
|
||||
documentParser.close();
|
||||
mapping.root.close();
|
||||
for (RootMapper rootMapper : mapping.rootMappers) {
|
||||
rootMapper.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -129,6 +129,4 @@ public interface Mapper extends ToXContent, Iterable<Mapper> {
|
|||
String name();
|
||||
|
||||
void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMappingException;
|
||||
|
||||
void close();
|
||||
}
|
||||
|
|
|
@ -564,11 +564,6 @@ public abstract class AbstractFieldMapper implements FieldMapper {
|
|||
|
||||
protected abstract String contentType();
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
multiFields.close();
|
||||
}
|
||||
|
||||
public static class MultiFields {
|
||||
|
||||
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 {
|
||||
if (pathType != Defaults.PATH_TYPE) {
|
||||
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() {
|
||||
if (fieldType().numericPrecisionStep() == 4) {
|
||||
return tokenStream4.get();
|
||||
|
|
|
@ -739,20 +739,6 @@ public class GeoPointFieldMapper extends AbstractFieldMapper implements ArrayVal
|
|||
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
|
||||
public Iterator<Mapper> iterator() {
|
||||
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) {
|
||||
super(Defaults.FIELD_TYPE, true, null, indexSettings);
|
||||
}
|
||||
|
@ -134,8 +127,8 @@ public class VersionFieldMapper extends AbstractFieldMapper implements RootMappe
|
|||
|
||||
@Override
|
||||
protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
|
||||
// see UidFieldMapper.parseCreateField
|
||||
final Field version = fieldCache.get();
|
||||
// see InternalEngine.updateVersion to see where the real version value is set
|
||||
final Field version = new NumericDocValuesField(NAME, -1L);
|
||||
context.version(version);
|
||||
fields.add(version);
|
||||
}
|
||||
|
@ -180,9 +173,4 @@ public class VersionFieldMapper extends AbstractFieldMapper implements RootMappe
|
|||
public void merge(Mapper mergeWith, MergeResult mergeResult) throws MergeMappingException {
|
||||
// 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
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
binMapper.close();
|
||||
boolMapper.close();
|
||||
pointMapper.close();
|
||||
shapeMapper.close();
|
||||
stringMapper.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject(fieldType().names().shortName());
|
||||
|
|
|
@ -52,10 +52,6 @@ public class ExternalRootMapper implements RootMapper {
|
|||
return Collections.emptyIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
return builder.startObject(CONTENT_TYPE).endObject();
|
||||
|
|
Loading…
Reference in New Issue