Пример #1
0
        private void Merge_Runs_into_One_File(int runFileNum)
        {
            try
            {
                long totalLength    = 0;
                long destFileLength = 0;
                int  threshold      = 1000;
                if (!file2.isExist())
                {
                    ArrayList listOfRuns = new ArrayList();
                    for (int i = 1; i <= runFileNum; i++)
                    {
                        string str = string.Concat(indexDirPath, "\\run", (i), ".txt");
                        totalLength += (new FileInfo(str)).Length;
                        listOfRuns.Add((new run(str)));
                    }
                    using (StreamWriter SW = file2.StreamWriterFile2())
                    {
                        while (!isEmpty(listOfRuns))
                        {
                            run smallerObj = getSmallestRun(listOfRuns);
                            SW.WriteLine(smallerObj.currentLine);
                            smallerObj.nextLine();
                            removeNullObj(listOfRuns);

                            if (numberOfLinesInFile++ > threshold)
                            {
                                threshold     += 8000;
                                destFileLength = file2.destFile2Length();
                            }
                        }
                    }
                } //if file exist
                GarbageCollection();
            }     //end of try
            catch (Exception ee)
            {
                MessageBox.Show("Namespace: Indexing; \nClass: InvertedFile; \nerror# 08:\n" + ee.Message);
            }
        }
Пример #2
0
 private run getSmallestRun(ArrayList runs)
 {
     try
     {
         run small = (run)runs[0];
         for (int i = 1; i < runs.Count; i++)
         {
             if (tokenToBeProcessed(small.currentLine).CompareTo(tokenToBeProcessed(((run)runs[i]).currentLine)) > 0)
             {
                 small = (run)runs[i];
             }
         }
         return(small);
     }
     catch (ThreadAbortException te)
     { return(null); }
     catch (Exception ee)
     {
         MessageBox.Show("error# 8" + ee.Message);
         return(null);
     }
 }