Beispiel #1
0
        /// <summary>Map file name and offset into statistical data.</summary>
        /// <remarks>
        /// Map file name and offset into statistical data.
        /// <p>
        /// The map task is to get the
        /// <tt>key</tt>, which contains the file name, and the
        /// <tt>value</tt>, which is the offset within the file.
        /// The parameters are passed to the abstract method
        /// <see cref="IOMapperBase{T}.DoIO(Org.Apache.Hadoop.Mapred.Reporter, string, long)"
        ///     />
        /// , which performs the io operation,
        /// usually read or write data, and then
        /// <see cref="IOMapperBase{T}.CollectStats(Org.Apache.Hadoop.Mapred.OutputCollector{K, V}, string, long, object)
        ///     "/>
        ///
        /// is called to prepare stat data for a subsequent reducer.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        public virtual void Map(Text key, LongWritable value, OutputCollector <Text, Text>
                                output, Reporter reporter)
        {
            string name      = key.ToString();
            long   longValue = value.Get();

            reporter.SetStatus("starting " + name + " ::host = " + hostName);
            this.stream = GetIOStream(name);
            T    statValue = null;
            long tStart    = Runtime.CurrentTimeMillis();

            try
            {
                statValue = DoIO(reporter, name, longValue);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
            long tEnd     = Runtime.CurrentTimeMillis();
            long execTime = tEnd - tStart;

            CollectStats(output, name, execTime, statValue);
            reporter.SetStatus("finished " + name + " ::host = " + hostName);
        }