@ -68,7 +68,7 @@ public final class plasmaSearchEvent {
public static String lastEventID = "" ;
public static String lastEventID = "" ;
private static ConcurrentHashMap < String , plasmaSearchEvent > lastEvents = new ConcurrentHashMap < String , plasmaSearchEvent > ( ) ; // a cache for objects from this class: re-use old search requests
private static ConcurrentHashMap < String , plasmaSearchEvent > lastEvents = new ConcurrentHashMap < String , plasmaSearchEvent > ( ) ; // a cache for objects from this class: re-use old search requests
public static final long eventLifetime = 600000 ; // the time an event will stay in the cache, 10 Minutes
public static final long eventLifetime = 600000 ; // the time an event will stay in the cache, 10 Minutes
private static final int max_results_preparation = 2 00;
private static final int max_results_preparation = 3 00;
private long eventTime ;
private long eventTime ;
plasmaSearchQuery query ;
plasmaSearchQuery query ;
@ -240,8 +240,8 @@ public final class plasmaSearchEvent {
serverProfiling . update ( "SEARCH" , new plasmaProfiling . searchEvent ( query . id ( true ) , "event-cleanup" , 0 , 0 ) ) ;
serverProfiling . update ( "SEARCH" , new plasmaProfiling . searchEvent ( query . id ( true ) , "event-cleanup" , 0 , 0 ) ) ;
// store this search to a cache so it can be re-used
// store this search to a cache so it can be re-used
lastEvents . put ( query . id ( false ) , this ) ;
lastEventID = query . id ( false ) ;
lastEventID = query . id ( false ) ;
lastEvents . put ( lastEventID , this ) ;
}
}
private class localSearchProcess extends Thread {
private class localSearchProcess extends Thread {
@ -460,24 +460,28 @@ public final class plasmaSearchEvent {
final ResultURLs crawlResults ,
final ResultURLs crawlResults ,
final TreeMap < String , String > preselectedPeerHashes ,
final TreeMap < String , String > preselectedPeerHashes ,
final boolean generateAbstracts ) {
final boolean generateAbstracts ) {
plasmaSearchEvent event = lastEvents . get ( query . id ( false ) ) ;
if ( event = = null ) {
String id = query . id ( false ) ;
event = new plasmaSearchEvent ( query , wordIndex , crawlResults , preselectedPeerHashes , generateAbstracts ) ;
plasmaSearchEvent event = lastEvents . get ( id ) ;
if ( plasmaSwitchboard . getSwitchboard ( ) . crawlQueues . noticeURL . size ( ) > 0 & & event ! = null & & System . currentTimeMillis ( ) - event . eventTime > 60000 ) {
// if a local crawl is ongoing, don't use the result from the cache to use possibly more results that come from the current crawl
// to prevent that this happens during a person switches between the different result pages, a re-search happens no more than
// once a minute
lastEvents . remove ( id ) ;
event = null ;
} else {
} else {
//re-new the event time for this event, so it is not deleted next time too early
if ( event ! = null ) {
event . eventTime = System . currentTimeMillis ( ) ;
//re-new the event time for this event, so it is not deleted next time too early
// replace the query, because this contains the current result offset
event . eventTime = System . currentTimeMillis ( ) ;
event . query = query ;
// replace the query, because this contains the current result offset
}
event . query = query ;
// if a local crawl is ongoing, do another local search to enrich the current results with more
// entries that can possibly come out of the running crawl
if ( plasmaSwitchboard . getSwitchboard ( ) . crawlQueues . noticeURL . size ( ) > 0 ) {
synchronized ( event . rankedCache ) {
event . rankedCache . execQuery ( ) ;
}
}
}
}
if ( event = = null ) {
// generate a new event
event = new plasmaSearchEvent ( query , wordIndex , crawlResults , preselectedPeerHashes , generateAbstracts ) ;
}
// if worker threads had been alive, but did not succeed, start them again to fetch missing links
// if worker threads had been alive, but did not succeed, start them again to fetch missing links
if ( ( query . onlineSnippetFetch ) & &
if ( ( query . onlineSnippetFetch ) & &
( ! event . anyWorkerAlive ( ) ) & &
( ! event . anyWorkerAlive ( ) ) & &