示例#1
0
        /// <exception cref="System.Exception"/>
        private void VerifyOutput(RunningJob submittedJob, FileSystem fileSystem)
        {
            FSDataInputStream dis     = null;
            long   numValidRecords    = 0;
            long   numInvalidRecords  = 0;
            long   numMappersLaunched = NumMappers;
            string prevKeyValue       = "000000000";

            Path[] fileList = FileUtil.Stat2Paths(fileSystem.ListStatus(Output, new Utils.OutputFileUtils.OutputFilesFilter
                                                                            ()));
            foreach (Path outFile in fileList)
            {
                try
                {
                    dis = fileSystem.Open(outFile);
                    string record;
                    while ((record = dis.ReadLine()) != null)
                    {
                        // Split the line into key and value.
                        int    blankPos    = record.IndexOf(" ");
                        string keyString   = Sharpen.Runtime.Substring(record, 0, blankPos);
                        string valueString = Sharpen.Runtime.Substring(record, blankPos + 1);
                        // Check for sorted output and correctness of record.
                        if (string.CompareOrdinal(keyString, prevKeyValue) >= 0 && keyString.Equals(valueString
                                                                                                    ))
                        {
                            prevKeyValue = keyString;
                            numValidRecords++;
                        }
                        else
                        {
                            numInvalidRecords++;
                        }
                    }
                }
                finally
                {
                    if (dis != null)
                    {
                        dis.Close();
                        dis = null;
                    }
                }
            }
            // Make sure we got all input records in the output in sorted order.
            NUnit.Framework.Assert.AreEqual((long)(NumMappers * NumLines), numValidRecords);
            // Make sure there is no extraneous invalid record.
            NUnit.Framework.Assert.AreEqual(0, numInvalidRecords);
        }