Пример #1
0
		private void DisconnectResult ()
		{
			if (this.result == null)
				return;

			this.result.HitsAddedEvent -= OnResultHitsAdded;
			this.result.HitsSubtractedEvent -= OnResultHitsSubtracted;
			this.result.FinishedEvent -= OnResultFinished;
					
			this.result.Cancel ();
			this.result.Dispose ();
			this.result = null;
		}
Пример #2
0
			public QueryWorkerClosure (IQueryWorker _worker, QueryResult _result)
			{
				worker = _worker;
				result = _result;
			}
Пример #3
0
 public QueryWorkerClosure(IQueryWorker _worker, QueryResult _result)
 {
     worker = _worker;
     result = _result;
 }
Пример #4
0
		static public void DoQuery (Query                                query,
					    QueryResult                          result,
					    RequestMessageExecutor.AsyncResponse send_response)
		{
			DehumanizeQuery (query);

			SearchTermResponse search_term_response;
			search_term_response = AssembleSearchTermResponse (query);
			send_response (search_term_response);

			QueryEachQueryable (query, result);
		}
Пример #5
0
		static public void DoQueryLocal (Query       query,
						 QueryResult result)
		{
			DehumanizeQuery (query);

			SearchTermResponse search_term_response;
			search_term_response = AssembleSearchTermResponse (query);
			query.ProcessSearchTermResponse (search_term_response);

			QueryEachQueryable (query, result);
		}
Пример #6
0
		static private void QueryEachQueryable (Query query, QueryResult result)
		{
			// The extra pair of calls to WorkerStart/WorkerFinished ensures:
			// (1) that the QueryResult will fire the StartedEvent
			// and FinishedEvent, even if no queryable accepts the
			// query.
			// (2) that the FinishedEvent will only get called when all of the
			// backends have had time to finish.

			object dummy_worker = new object ();

			if (! result.WorkerStart (dummy_worker))
				return;

			try {
				iqueryable_lock.AcquireReaderLock (System.Threading.Timeout.Infinite);

				foreach (Queryable queryable in Queryables)
					DoOneQuery (queryable, query, result, null);
			} finally {
				iqueryable_lock.ReleaseReaderLock ();
			}
			
			result.WorkerFinished (dummy_worker);
		}
Пример #7
0
		static public void DoOneQuery (Queryable            queryable,
					       Query                query,
					       QueryResult          result,
					       IQueryableChangeData change_data)
		{
			try {
				if (queryable.AcceptQuery (query)) {
					QueryClosure qc = new QueryClosure (queryable, query, result, change_data);
					result.AttachWorker (qc);
				}
			} catch (Exception ex) {
				Logger.Log.Warn (ex, "Caught exception calling DoOneQuery on '{0}'", queryable.Name);
			}
		}
Пример #8
0
			public QueryClosure (Queryable            queryable,
					     Query                query,
					     QueryResult          result,
					     IQueryableChangeData change_data)
			{
				this.queryable = queryable;
				this.query = query;
				this.result = result;
				this.change_data = change_data;
			}
Пример #9
0
		public override ResponseMessage Execute (RequestMessage req)
		{
			this.query = (Query) req;

			this.result = new QueryResult ();
			this.result.IsIndexListener = this.query.IsIndexListener;
			AttachResult ();

			QueryDriver.ChangedEvent += OnQueryDriverChanged;
			QueryDriver.DoQuery (query,
					     this.result,
					     new RequestMessageExecutor.AsyncResponse (this.SendAsyncResponse));

			// Don't send a response; we'll be sending them async
			return null;
		}
Пример #10
0
		public void OnResultFinished (QueryResult result)
		{
			this.SendAsyncResponse (new FinishedResponse ());
		}
Пример #11
0
		public void OnResultHitsSubtracted (QueryResult result, ICollection some_uris)
		{
			HitsSubtractedResponse response = new HitsSubtractedResponse (some_uris);

			this.SendAsyncResponse (response);
		}
Пример #12
0
		public void OnResultHitsAdded (QueryResult result, ICollection some_hits, int total_results)
		{
			HitsAddedResponse response = new HitsAddedResponse (some_hits, total_results);

			this.SendAsyncResponse (response);
		}