예제 #1
0
        private void Step1(int runFileNum)
        {
            try
            {
                string path           = indexDirPath + "\\step2.txt";
                long   totalLength    = 0;
                long   destFileLength = 0;
                int    threshold      = 1000;
                if (!File.Exists(path))
                {
                    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 = new StreamWriter(path, false, Encoding.Unicode))
                    {
                        while (!isEmpty(listOfRuns))
                        {
                            run smallerObj = getSmallestRun(listOfRuns);
                            sw.WriteLine(smallerObj.currentLine);
                            smallerObj.nextLine();
                            removeNullObj(listOfRuns);

                            if (numberOfLinesInFile++ > threshold)
                            {
                                threshold     += 8000;
                                destFileLength = (new FileInfo(path)).Length;
                                //singleProc.Value = (int)(100*destFileLength/totalLength);
                                BeginInvoke(APD, new object[] { (int)((100 * destFileLength / totalLength) / 4) + 25, (int)(100 * destFileLength / totalLength), "sorting tokens ...." });
                            }
                        }
                    }
                }        //if file exist
                GarbageCollection();
            }            //end of try

            catch (Exception ee)
            {
                MessageBox.Show("Step1: " + 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);
     }
 }