Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

replaced more double types with float

orbiter5905f912c542
diff --git a/source/de/anomic/search/RankingProcess.java b/source/de/anomic/search/RankingProcess.java
index bb1064d78..1df8b4ef5 100644
--- a/source/de/anomic/search/RankingProcess.java
+++ b/source/de/anomic/search/RankingProcess.java
@@ -591,12 +591,12 @@ public final class RankingProcess extends Thread {
final ScoreCluster<String> result = new ScoreCluster<String>();
if (!this.query.navigators.equals("all") && this.query.navigators.indexOf("topics") < 0) return result;
if (this.ref.size() < 2) this.ref.clear(); // navigators with one entry are not useful
- final Map<String, Double> counts = new HashMap<String, Double>();
+ final Map<String, Float> counts = new HashMap<String, Float>();
final Iterator<String> i = this.ref.keys(false);
String word;
byte[] termHash;
int c;
- double q, min = Double.MAX_VALUE, max = Double.MIN_VALUE;
+ float q, min = Float.MAX_VALUE, max = Float.MIN_VALUE;
int ic = count;
while (ic-- > 0 && i.hasNext()) {
word = i.next();
@@ -604,13 +604,13 @@ public final class RankingProcess extends Thread {
termHash = Word.word2hash(word);
c = this.query.getSegment().termIndex().count(termHash);
if (c > 0) {
- q = ((double) this.ref.get(word)) / ((double) c);
+ q = ((float) this.ref.get(word)) / ((float) c);
min = Math.min(min, q);
max = Math.max(max, q);
counts.put(word, q);
}
}
- if (max > min) for (Map.Entry<String, Double> ce: counts.entrySet()) {
+ if (max > min) for (Map.Entry<String, Float> ce: counts.entrySet()) {
result.set(ce.getKey(), (int) (((double) count) * (ce.getValue() - min) / (max - min)));
}
return this.ref;
diff --git a/source/net/yacy/cora/document/JSONObject.java b/source/net/yacy/cora/document/JSONObject.java
index 111770072..0d6944cad 100644
--- a/source/net/yacy/cora/document/JSONObject.java
+++ b/source/net/yacy/cora/document/JSONObject.java
@@ -378,7 +378,7 @@ public class JSONObject {
* @return A String.
*/
static public String floatToString(float d) {
- if (Double.isInfinite(d) || Double.isNaN(d)) {
+ if (Float.isInfinite(d) || Float.isNaN(d)) {
return "null";
}
@@ -749,7 +749,7 @@ public class JSONObject {
/**
- * Get an optional double associated with a key,
+ * Get an optional float associated with a key,
* or NaN if there is no such key or if its value is not a number.
* If the value is a string, an attempt will be made to evaluate it as
* a number.
@@ -757,13 +757,13 @@ public class JSONObject {
* @param key A string which is the key.
* @return An object which is the value.
*/
- public double optDouble(String key) {
- return optDouble(key, Double.NaN);
+ public float optFloat(String key) {
+ return optFloat(key, Float.NaN);
}
/**
- * Get an optional double associated with a key, or the
+ * Get an optional float associated with a key, or the
* defaultValue if there is no such key or if its value is not a number.
* If the value is a string, an attempt will be made to evaluate it as
* a number.
@@ -772,11 +772,11 @@ public class JSONObject {
* @param defaultValue The default.
* @return An object which is the value.
*/
- public double optDouble(String key, double defaultValue) {
+ public float optFloat(String key, float defaultValue) {
try {
Object o = opt(key);
- return o instanceof Number ? ((Number)o).doubleValue() :
- new Double((String)o).doubleValue();
+ return o instanceof Number ? ((Number)o).floatValue() :
+ new Float((String)o).floatValue();
} catch (Exception e) {
return defaultValue;
}
@@ -979,15 +979,15 @@ public class JSONObject {
/**
- * Put a key/double pair in the JSONObject.
+ * Put a key/float pair in the JSONObject.
*
* @param key A key string.
- * @param value A double which is the value.
+ * @param value A float which is the value.
* @return this.
* @throws JSONException If the key is null or if the number is invalid.
*/
- public JSONObject put(String key, double value) throws JSONException {
- put(key, new Double(value));
+ public JSONObject put(String key, float value) throws JSONException {
+ put(key, new Float(value));
return this;
}
diff --git a/source/net/yacy/cora/storage/ScoreCluster.java b/source/net/yacy/cora/storage/ScoreCluster.java
index 59a83bbcf..db9470a3c 100644
--- a/source/net/yacy/cora/storage/ScoreCluster.java
+++ b/source/net/yacy/cora/storage/ScoreCluster.java
@@ -114,6 +114,10 @@ public final class ScoreCluster<E> implements DynamicScore<E> {
if (l < Integer.MAX_VALUE) return (int) l;
o = ((Long) o).toString();
}
+ if (o instanceof Float) {
+ final double d = 1000f * ((Float) o).floatValue();
+ return (int) Math.round(d);
+ }
if (o instanceof Double) {
final double d = 1000d * ((Double) o).doubleValue();
return (int) Math.round(d);