예제 #1
0
 public MessagesPostprocessor(SearchAllOccurencesParams searchParams, LJTraceSource trace)
 {
     this.bulkProcessing = searchParams.Filters.StartBulkProcessing(
         MessageTextGetters.Get(searchParams.SearchInRawText),
         reverseMatchDirection: false);
     this.filteringTime = new Stopwatch();
     this.tid           = Thread.CurrentThread.ManagedThreadId;
     this.trace         = trace;
 }
예제 #2
0
        bool IAsyncLogProviderCommandHandler.RunSynchronously(CommandContext ctx)
        {
            if (ctx.Cache == null)
            {
                return(false);
            }

            if (continuationToken != null)
            {
                return(false);                // only reader knows how to handle its continuation tokens
            }
            if (!ctx.Stats.PositionsRange.Equals(ctx.Cache.MessagesRange))
            {
                return(false);                // speed up only fully cached logs. partial optimization isn't noticeable.
            }
            var elapsed = Stopwatch.StartNew();

            using (var preprocessedSearchOptions = searchParams.Filters.StartBulkProcessing(
                       messageTextGetter: MessageTextGetters.Get(searchParams.SearchInRawText),
                       reverseMatchDirection: false,
                       timeboxedMatching: true
                       ))
                foreach (var loadedMsg in ((IMessagesCollection)ctx.Cache.Messages).Forward(0, int.MaxValue))
                {
                    if (elapsed.ElapsedMilliseconds > 500)
                    {
                        return(false);
                    }
                    var msg = loadedMsg.Message;
                    if (searchParams.FromPosition != null && msg.Position < searchParams.FromPosition)
                    {
                        continue;
                    }
                    var rslt = preprocessedSearchOptions.ProcessMessage(msg, null);
                    if (rslt.Action == FilterAction.Exclude)
                    {
                        continue;
                    }
                    if (!callback(new SearchResultMessage(msg.Clone(), rslt)))
                    {
                        break;
                    }
                }

            return(true);
        }