diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java index 44063827c..a524561b8 100644 --- a/htroot/yacysearchitem.java +++ b/htroot/yacysearchitem.java @@ -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 } diff --git a/maptest b/maptest deleted file mode 100644 index 4893be0a9..000000000 Binary files a/maptest and /dev/null differ diff --git a/source/de/anomic/search/QueryParams.java b/source/de/anomic/search/QueryParams.java index dde3e90b2..e6c6dce31 100644 --- a/source/de/anomic/search/QueryParams.java +++ b/source/de/anomic/search/QueryParams.java @@ -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(); } /** diff --git a/source/de/anomic/search/ResultFetcher.java b/source/de/anomic/search/ResultFetcher.java index 8c6070eb8..d1af5f0ac 100644 --- a/source/de/anomic/search/ResultFetcher.java +++ b/source/de/anomic/search/ResultFetcher.java @@ -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;