Ejemplo n.º 1
0
        /// <summary>
        /// Merge sorted batches.
        /// </summary>
        public void Merge(BatchInfo[] sortedBatches)
        {
            if (File.Exists(sortFileName))
            {
                File.Delete(sortFileName);
            }

#if DEBUG
            long length     = 0;
            long linesCount = 0;
            foreach (var sortedBatch in sortedBatches)
            {
                length += new FileInfo(sortedBatch.FileName).Length;
                using (FileStream stream = new FileStream(sortedBatch.FileName, FileMode.Open))
                {
                    linesCount += CountLinesHelper.CountLines(stream);
                }
            }

            Console.WriteLine($"length of batched files: {length}");
            Console.WriteLine($"lines of files: {linesCount}.");
#endif

            MergeInternal(sortedBatches);

            // delete the temp files
            foreach (BatchInfo batch in sortedBatches)
            {
                batch.Reader.Dispose();
                File.Delete(batch.FileName);
            }
        }
Ejemplo n.º 2
0
        private static void DebugInfo(string fileName, string sortFileName)
        {
            using (var stream = new FileStream(fileName, FileMode.Open))
            {
                Console.WriteLine($"not sorted:{CountLinesHelper.CountLines(stream)}");
            }

            using (var stream = new FileStream(sortFileName, FileMode.Open))
            {
                Console.WriteLine($"sorted:{CountLinesHelper.CountLines(stream)}");
            }
        }