From fb828f37672b64f0806b6bd5c488f48c754d1077 Mon Sep 17 00:00:00 2001 From: orbiter Date: Mon, 6 Sep 2010 10:00:07 +0000 Subject: [PATCH] - 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 --- htroot/yacysearchitem.java | 2 ++ maptest | Bin 54 -> 0 bytes source/de/anomic/search/QueryParams.java | 29 +++++++++++++++------ source/de/anomic/search/ResultFetcher.java | 2 +- 4 files changed, 24 insertions(+), 9 deletions(-) delete mode 100644 maptest 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 4893be0a935ce56b5903b803632c9a0d6f3669b9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 54 ucmZQzVBj+}GG<6Iw8}QNGB7YmWdMqpn3_RF3=IvzBIXvBP!S^|qf`L*rwQc% 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;