Skip to content

Commit

Permalink
deprecate and start to remove LTRUtils.convertToFloat (apache#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpoerschke authored and Michael Nilsson committed Sep 27, 2016
1 parent 62c73fd commit 8167373
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.lucene.search.Query;
import org.apache.solr.ltr.feature.FeatureException;
import org.apache.solr.ltr.ranking.Feature;
import org.apache.solr.ltr.util.LTRUtils;
import org.apache.solr.request.SolrQueryRequest;

public class ValueFeature extends Feature {
Expand All @@ -51,13 +50,16 @@ public void setValue(Object value) {
if (configValueStr.trim().isEmpty()) {
throw new FeatureException("Empty field 'value' in params for " + this);
}
} else if (value instanceof Double) {
configValue = ((Double) value).floatValue();
} else if (value instanceof Float) {
configValue = ((Float) value).floatValue();
} else if (value instanceof Integer) {
configValue = ((Integer) value).floatValue();
} else if (value instanceof Long) {
configValue = ((Long) value).floatValue();
} else {
try {
configValue = LTRUtils.convertToFloat(value);
} catch (final NumberFormatException e) {
throw new FeatureException("Invalid type for 'value' in params for "
+ this);
}
throw new FeatureException("Invalid type for 'value' in params for " + this);
}
}

Expand Down Expand Up @@ -106,8 +108,6 @@ public ValueFeatureWeight(IndexSearcher searcher,
} else {
featureValue=null;
}


} else {
featureValue = configValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static Map<String,String[]> extractEFIParams(SolrParams localParams) {
return externalFeatureInfo;
}

@Deprecated
public static float convertToFloat(Object o) {
float f = 0;
if (o instanceof Double) {
Expand Down

0 comments on commit 8167373

Please sign in to comment.