Merge pull request #15337 from jpountz/remove/estimatedNumberType

Remove XContentParser.estimatedNumberType().
This commit is contained in:
Adrien Grand 2015-12-10 10:09:09 +01:00
commit 29859a946d
3 changed files with 2 additions and 44 deletions

View File

@ -178,12 +178,6 @@ public interface XContentParser extends Releasable {
NumberType numberType() throws IOException; NumberType numberType() throws IOException;
/**
* Is the number type estimated or not (i.e. an int might actually be a long, its just low enough
* to be an int).
*/
boolean estimatedNumberType();
short shortValue(boolean coerce) throws IOException; short shortValue(boolean coerce) throws IOException;
int intValue(boolean coerce) throws IOException; int intValue(boolean coerce) throws IOException;

View File

@ -68,11 +68,6 @@ public class JsonXContentParser extends AbstractXContentParser {
return convertNumberType(parser.getNumberType()); return convertNumberType(parser.getNumberType());
} }
@Override
public boolean estimatedNumberType() {
return true;
}
@Override @Override
public String currentName() throws IOException { public String currentName() throws IOException {
return parser.getCurrentName(); return parser.getCurrentName();

View File

@ -560,44 +560,13 @@ class DocumentParser implements Closeable {
return builder; return builder;
} else if (token == XContentParser.Token.VALUE_NUMBER) { } else if (token == XContentParser.Token.VALUE_NUMBER) {
XContentParser.NumberType numberType = context.parser().numberType(); XContentParser.NumberType numberType = context.parser().numberType();
if (numberType == XContentParser.NumberType.INT) { if (numberType == XContentParser.NumberType.INT || numberType == XContentParser.NumberType.LONG) {
if (context.parser().estimatedNumberType()) {
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "long");
if (builder == null) {
builder = MapperBuilders.longField(currentFieldName);
}
return builder;
} else {
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "integer");
if (builder == null) {
builder = MapperBuilders.integerField(currentFieldName);
}
return builder;
}
} else if (numberType == XContentParser.NumberType.LONG) {
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "long"); Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "long");
if (builder == null) { if (builder == null) {
builder = MapperBuilders.longField(currentFieldName); builder = MapperBuilders.longField(currentFieldName);
} }
return builder; return builder;
} else if (numberType == XContentParser.NumberType.FLOAT) { } else if (numberType == XContentParser.NumberType.FLOAT || numberType == XContentParser.NumberType.DOUBLE) {
if (context.parser().estimatedNumberType()) {
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "double");
if (builder == null) {
// no templates are defined, we use float by default instead of double
// since this is much more space-efficient and should be enough most of
// the time
builder = MapperBuilders.floatField(currentFieldName);
}
return builder;
} else {
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "float");
if (builder == null) {
builder = MapperBuilders.floatField(currentFieldName);
}
return builder;
}
} else if (numberType == XContentParser.NumberType.DOUBLE) {
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "double"); Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "double");
if (builder == null) { if (builder == null) {
// no templates are defined, we use float by default instead of double // no templates are defined, we use float by default instead of double