- performance enhancements in search response time using faster query ID computation and an ID cache

- code cleanup

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7113 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 0ab6a462ee
commit fb828f3767

@ -229,6 +229,8 @@ public class yacysearchitem {
if (s.length() <= length) return s;
final int p = s.lastIndexOf('.');
if (p < 0) return s.substring(0, length - 3) + "...";
assert p >= 0;
assert length - (s.length() - p) - 3 >= 0;
return s.substring(0, length - (s.length() - p) - 3) + "..." + s.substring(p); // TODO check oob
}

Binary file not shown.

@ -398,11 +398,26 @@ public final class QueryParams {
return matcher;
}
private String idCacheAnon = null, idCache = null;
final static private char asterisk = '*';
public String id(final boolean anonymized) {
final String asterisk = "*";
if (anonymized) {
if (idCacheAnon != null) return idCacheAnon;
} else {
if (idCache != null) return idCache;
}
// generate a string that identifies a search so results can be re-used in a cache
final StringBuilder context = new StringBuilder();
final StringBuilder context = new StringBuilder(120);
if (anonymized) {
context.append(anonymizedQueryHashes(this.queryHashes));
context.append('-');
context.append(anonymizedQueryHashes(this.excludeHashes));
} else {
context.append(hashSet2hashString(this.queryHashes));
context.append('-');
context.append(hashSet2hashString(this.excludeHashes));
}
context.append(asterisk);
context.append(this.domType);
context.append(asterisk);
@ -425,14 +440,12 @@ public final class QueryParams {
context.append(this.constraint);
context.append(asterisk);
context.append(this.maxDistance);
final String ret;
if (anonymized) {
ret = anonymizedQueryHashes(this.queryHashes) + "-" + anonymizedQueryHashes(this.excludeHashes) + context;
idCacheAnon = context.toString();
} else {
ret = hashSet2hashString(this.queryHashes) + "-" + hashSet2hashString(this.excludeHashes) + context;
idCache = context.toString();
}
return ret;
return context.toString();
}
/**

@ -345,7 +345,7 @@ public class ResultFetcher {
for (MediaSnippet ms: imagemedia) {
images.push(ms, Long.valueOf(ms.ranking));
c++;
System.out.println("*** image " + new String(ms.href.hash()) + " images.size = " + images.size() + "/" + images.size());
//System.out.println("*** image " + new String(ms.href.hash()) + " images.size = " + images.size() + "/" + images.size());
}
}
return c;

Loading…
Cancel
Save