because of a bug in search result caching count search results had not been generated as fast as possible.

with this fix search results are (even) faster.
Also enhanced: image search. This is now speeded up using a image search result look-ahead

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7105 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 15 years ago
parent fa2eb9676e
commit 9c0c94683c

@ -205,14 +205,12 @@ public class yacysearchitem {
final ArrayList<MediaSnippet> media = result.mediaSnippets();
if (item == 0) col = true;
if (media != null) {
MediaSnippet ms;
int c = 0;
for (int i = 0; i < media.size(); i++) {
ms = media.get(i);
prop.putHTML("content_items_" + i + "_href", ms.href.toNormalform(true, false));
prop.putHTML("content_items_" + i + "_hrefshort", nxTools.shortenURLString(ms.href.toNormalform(true, false), urllength));
prop.putHTML("content_items_" + i + "_name", shorten(ms.name, namelength));
prop.put("content_items_" + i + "_col", (col) ? "0" : "1");
for (MediaSnippet ms : media) {
prop.putHTML("content_items_" + c + "_href", ms.href.toNormalform(true, false));
prop.putHTML("content_items_" + c + "_hrefshort", nxTools.shortenURLString(ms.href.toNormalform(true, false), urllength));
prop.putHTML("content_items_" + c + "_name", shorten(ms.name, namelength));
prop.put("content_items_" + c + "_col", (col) ? "0" : "1");
c++;
col = !col;
}

@ -281,7 +281,7 @@ public class ResultFetcher {
// check if we already retrieved this item
// (happens if a search pages is accessed a second time)
EventTracker.update("SEARCH", new ProfilingGraph.searchEvent(query.id(true), "obtain one result entry - start", 0, 0), false, 30000, ProfilingGraph.maxTime);
if (this.result.sizeStore() > item) {
if (this.result.size() > item) {
// we have the wanted result already in the result array .. return that
return this.result.element(item).element;
}
@ -319,32 +319,38 @@ public class ResultFetcher {
}
public MediaSnippet oneImage(final int item) {
// check if we already retrieved this item (happens if a search pages is accessed a second time)
if (this.images.sizeStore() > item) {
// we have the wanted result already in the result array .. return that
return this.images.element(item).element;
}
// always look for a next object if there are way too less
if (this.images.size() <= item + 10) fillImagesCache();
// check if we already retrieved the item
if (this.images.size() > item) return this.images.element(item).element;
// generate result object
final ResultEntry result = nextResult();
MediaSnippet ms;
if (result != null) {
// iterate over all images in the result
final ArrayList<MediaSnippet> imagemedia = result.mediaSnippets();
if (imagemedia != null) {
for (int j = 0; j < imagemedia.size(); j++) {
ms = imagemedia.get(j);
images.push(ms, Long.valueOf(ms.ranking));
//System.out.println("*** image " + ms.href.hash() + " images.size = " + images.size() + "/" + images.size());
}
}
}
// look again if there are not enough for presentation
while (this.images.size() <= item) {
if (fillImagesCache() == 0) break;
}
if (this.images.size() <= item) return null;
// now take the specific item from the image stack
if (this.images.size() <= item) return null;
return this.images.element(item).element;
}
private int fillImagesCache() {
ResultEntry result = nextResult();
int c = 0;
if (result == null) return c;
// iterate over all images in the result
final ArrayList<MediaSnippet> imagemedia = result.mediaSnippets();
if (imagemedia != null) {
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());
}
}
return c;
}
public ArrayList<SortStack<ResultEntry>.stackElement> completeResults(final long waitingtime) {
final long timeout = System.currentTimeMillis() + waitingtime;
while ((result.size() < query.neededResults()) && (anyWorkerAlive()) && (System.currentTimeMillis() < timeout)) {

@ -155,6 +155,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
try { Thread.sleep(100); } catch (final InterruptedException ex) {}
// trying to interrupt session
s.notify();
s.interrupt();
try {Thread.sleep(10);} catch (final InterruptedException ex) {}

@ -70,10 +70,6 @@ public class SortStore<E> extends SortStack<E> {
public int size() {
return super.size() + this.offstack.size();
}
public int sizeStore() {
return this.offstack.size();
}
public void push(final E element, final Long weight) {
if (this.offset.containsKey(element)) return;

Loading…
Cancel
Save