Esempio n. 1
0
        /// <summary>
        /// starts new new asyncronous task to index a single log entry
        /// </summary>
        /// <param name="entryId">The index of the log entry</param>
        /// <param name="logEntry">the complete log entry</param>
        /// <param name="index">The reverse index for this log</param>
        void StartParseLineTask(int entryId, string logEntry, InvertedIndex index)
        {
            Task t = Task.Run(() =>
            {
                index.AddLogEntry(entryId, logEntry);
                if (entryId % 100 == 99 && ProgressUpdate != null)
                {
                    ProgressUpdate(this, new LoadEventArgs()
                    {
                        line_number = entryId + 1
                    });
                }
            });

            openTasks.Add(t);
        }
Esempio n. 2
0
        public void Build()
        {
            if (fileReader == null)
            {
                return;
            }
            string line;
            int    stopCount = int.MaxValue;

            while (null != (line = fileReader.ReadLine()))
            {
                int    lineNo = logEntries.Count();
                string prefix = string.Format("{0}, ", lineNo);
                if (!line.StartsWith(prefix))
                {
                    line = prefix + line;
                }

                lock (logEntries)
                {
                    logEntries.Add(line);
                }
#if NOTASKS
                index.AddLogEntry(lineNo, line);
#else
                StartParseLineTask(lineNo, line, index);
#endif
                if (lineNo > stopCount)
                {
                    break;
                }
            }

#if NOTASKS
#else
            foreach (var task in openTasks)
            {
                task.Wait();
            }
#endif
        }