コード例 #1
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 public override void Write(K key, V value)
 {
     if (rawWriter == null)
     {
         rawWriter = outputFormat.GetRecordWriter(taskContext);
     }
     rawWriter.Write(key, value);
 }
コード例 #2
0
            /// <exception cref="System.IO.IOException"/>
            public override RecordWriter <object, object> GetRecordWriter(FileSystem fs, JobConf
                                                                          job, string baseFileName, Progressable progress)
            {
                string nameOutput = job.Get(ConfigNamedOutput, null);
                string fileName   = GetUniqueName(job, baseFileName);
                // The following trick leverages the instantiation of a record writer via
                // the job conf thus supporting arbitrary output formats.
                JobConf outputConf = new JobConf(job);

                outputConf.SetOutputFormat(GetNamedOutputFormatClass(job, nameOutput));
                outputConf.SetOutputKeyClass(GetNamedOutputKeyClass(job, nameOutput));
                outputConf.SetOutputValueClass(GetNamedOutputValueClass(job, nameOutput));
                OutputFormat outputFormat = outputConf.GetOutputFormat();

                return(outputFormat.GetRecordWriter(fs, outputConf, fileName, progress));
            }
コード例 #3
0
ファイル: FileBench.cs プロジェクト: orf53975/hadoop.net
        /// <exception cref="System.IO.IOException"/>
        internal static long WriteBench(JobConf conf)
        {
            // OutputFormat instantiation
            long filelen = conf.GetLong("filebench.file.bytes", 5 * 1024 * 1024 * 1024);

            Org.Apache.Hadoop.IO.Text key = new Org.Apache.Hadoop.IO.Text();
            Org.Apache.Hadoop.IO.Text val = new Org.Apache.Hadoop.IO.Text();
            string fn   = conf.Get("test.filebench.name", string.Empty);
            Path   outd = FileOutputFormat.GetOutputPath(conf);

            conf.Set("mapred.work.output.dir", outd.ToString());
            OutputFormat outf = conf.GetOutputFormat();
            RecordWriter <Org.Apache.Hadoop.IO.Text, Org.Apache.Hadoop.IO.Text> rw = outf.GetRecordWriter
                                                                                         (outd.GetFileSystem(conf), conf, fn, Reporter.Null);

            try
            {
                long     acc   = 0L;
                DateTime start = new DateTime();
                for (int i = 0; acc < filelen; ++i)
                {
                    i %= keys.Length;
                    key.Set(keys[i]);
                    val.Set(values[i]);
                    rw.Write(key, val);
                    acc += keys[i].Length;
                    acc += values[i].Length;
                }
                DateTime end = new DateTime();
                return(end.GetTime() - start.GetTime());
            }
            finally
            {
                rw.Close(Reporter.Null);
            }
        }
コード例 #4
0
            /// <exception cref="System.IO.IOException"/>
            private void CreateRecordWriter()
            {
                FileSystem fs = FileSystem.Get(job);

                rawWriter = of.GetRecordWriter(fs, job, name, progress);
            }