Skip to content

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

Avoid frequent data type casting (float/long) for rwi score refactor to using long in URIMetadataNode too (and related call parameters) As remote rwi score's are not used (since v1.83) skip reading float-score , but keep in toString() for communication with older versions.

reger685d8e86bfdd
diff --git a/source/net/yacy/cora/federate/solr/responsewriter/EnhancedXMLResponseWriter.java b/source/net/yacy/cora/federate/solr/responsewriter/EnhancedXMLResponseWriter.java
index eabb456cc..8fbeae18b 100644
--- a/source/net/yacy/cora/federate/solr/responsewriter/EnhancedXMLResponseWriter.java
+++ b/source/net/yacy/cora/federate/solr/responsewriter/EnhancedXMLResponseWriter.java
@@ -172,7 +172,7 @@ public class EnhancedXMLResponseWriter implements QueryResponseWriter {
startTagOpen(writer, "doc", name);
if (includeScore) {
- writeTag(writer, "float", "score", Float.toString(score), false);
+ writeTag(writer, "float", "score", Float.toString(score), false); // this is the special Solr "score" pseudo-field
}
int sz = fields.size();
diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
index efc5cdb4b..33caf98e9 100644
--- a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
+++ b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
@@ -81,7 +81,7 @@ public class URIMetadataNode extends SolrDocument /* implements Comparable<URIMe
protected Bitfield flags = null;
protected int imagec = -1, audioc = -1, videoc = -1, appc = -1;
protected double lat = Double.NaN, lon = Double.NaN;
- protected float score = 0; // during generation of a search result this value is set
+ protected long score = 0; // during generation of a search result this value is set
protected String snippet = null;
protected WordReferenceVars word = null; // this is only used if the url is transported via remote search requests
@@ -151,7 +151,7 @@ public class URIMetadataNode extends SolrDocument /* implements Comparable<URIMe
this.videoc = Integer.parseInt(prop.getProperty("lvideo", "0"));
this.appc = Integer.parseInt(prop.getProperty("lapp", "0"));
this.snippet = crypt.simpleDecode(prop.getProperty("snippet", ""));
- this.score = Float.parseFloat(prop.getProperty("score", "0.0")); // we don't use the remote rwi ranking but the local rwi ranking profile
+ // this.score = Float.parseFloat(prop.getProperty("score", "0.0")); // we don't use the remote rwi ranking but the local rwi ranking profile
List<String> cs = new ArrayList<String>();
cs.add(collection);
this.setField(CollectionSchema.collection_sxt.name(), cs);
@@ -188,10 +188,16 @@ public class URIMetadataNode extends SolrDocument /* implements Comparable<URIMe
}
}
- public URIMetadataNode(final SolrDocument doc, final WordReferenceVars searchedWord, final float scorex) throws MalformedURLException {
+ /**
+ * @param doc metadata from (embedded) Solr index
+ * @param searchedWord rwi WordReference the metadata belong to
+ * @param scorex rwi score
+ * @throws MalformedURLException
+ */
+ public URIMetadataNode(final SolrDocument doc, final WordReferenceVars searchedWord, final long scorex) throws MalformedURLException {
this(doc);
- this.word = searchedWord;
- this.score = scorex;
+ this.word = searchedWord; // rwi index WordReference this document (metadata) belong to
+ this.score = scorex; // rwi/YaCy score
}
public URIMetadataNode(DigestURL theurl) {
@@ -334,7 +340,7 @@ public class URIMetadataNode extends SolrDocument /* implements Comparable<URIMe
* (the value is updated while adding to the result queue where score calc takes place)
* @return YaCy calculated score (number > 0)
*/
- public float score() {
+ public long score() {
return this.score;
}
@@ -343,7 +349,7 @@ public class URIMetadataNode extends SolrDocument /* implements Comparable<URIMe
* (should be set to the effective value of result queues getWeight)
* @param theScore YaCy ranking of search results
*/
- public void setScore(float theScore) {
+ public void setScore(long theScore) {
this.score = theScore;
}
@@ -472,8 +478,8 @@ public class URIMetadataNode extends SolrDocument /* implements Comparable<URIMe
}
public int urllength() {
- return getInt(CollectionSchema.url_chars_i);
- }
+ return getInt(CollectionSchema.url_chars_i);
+ }
public String snippet() {
return this.snippet;
@@ -589,7 +595,7 @@ public class URIMetadataNode extends SolrDocument /* implements Comparable<URIMe
s.append(",laudio=").append(this.laudio());
s.append(",lvideo=").append(this.lvideo());
s.append(",lapp=").append(this.lapp());
- s.append(",score=").append(Float.toString(this.score()));
+ s.append(",score=").append(Long.toString(this.score()));
if (this.word() != null) {
// append also word properties
final String wprop = this.word().toPropertyForm();
diff --git a/source/net/yacy/search/index/Fulltext.java b/source/net/yacy/search/index/Fulltext.java
index e70d1ba2e..a6132860a 100644
--- a/source/net/yacy/search/index/Fulltext.java
+++ b/source/net/yacy/search/index/Fulltext.java
@@ -285,22 +285,33 @@ public final class Fulltext {
getDefaultConnector().commit(softCommit);
if (this.writeWebgraph) getWebgraphConnector().commit(softCommit);
}
-
+
+ /**
+ * Loads the meta data stored in the embedded solr index for the url referenced
+ * by the WordReference.
+ * The WordReference and the YaCy score (element.weight()) become part (and
+ * are accessible) of the returned document.
+ * If the no document with url.hash = solrdocument.id is found in the embedded
+ * Solr index null is return.
+ *
+ * @param element rwi wordreference
+ * @return URIMetadataNode (solrdocument) with all fields stored in embedded solr index
+ */
public URIMetadataNode getMetadata(final WeakPriorityBlockingQueue.Element<WordReferenceVars> element) {
if (element == null) return null;
WordReferenceVars wre = element.getElement();
if (wre == null) return null; // all time was already wasted in takeRWI to get another element
- float score = element.getWeight();
+ long score = element.getWeight();
URIMetadataNode node = getMetadata(wre.urlhash(), wre, score);
return node;
}
public URIMetadataNode getMetadata(final byte[] urlHash) {
if (urlHash == null) return null;
- return getMetadata(urlHash, null, 0.0f);
+ return getMetadata(urlHash, null, 0L);
}
- private URIMetadataNode getMetadata(final byte[] urlHash, final WordReferenceVars wre, final float score) {
+ private URIMetadataNode getMetadata(final byte[] urlHash, final WordReferenceVars wre, final long score) {
String u = ASCII.String(urlHash);
// get the metadata from Solr