Esempio n. 1
0
 private void CreateAggregator(Configuration conf)
 {
     if (theAggregatorDescriptor == null)
     {
         theAggregatorDescriptor = (ValueAggregatorDescriptor)CreateInstance(this.className
                                                                             );
         theAggregatorDescriptor.Configure(conf);
     }
 }
        protected internal static AList <ValueAggregatorDescriptor> GetAggregatorDescriptors
            (Configuration conf)
        {
            int num = conf.GetInt(DescriptorNum, 0);
            AList <ValueAggregatorDescriptor> retv = new AList <ValueAggregatorDescriptor>(num);

            for (int i = 0; i < num; i++)
            {
                string spec = conf.Get(Descriptor + "." + i);
                ValueAggregatorDescriptor ad = GetValueAggregatorDescriptor(spec, conf);
                if (ad != null)
                {
                    retv.AddItem(ad);
                }
            }
            return(retv);
        }
        /// <summary>the map function.</summary>
        /// <remarks>
        /// the map function. It iterates through the value aggregator descriptor
        /// list to generate aggregation id/value pairs and emit them.
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        protected internal override void Map(K1 key, V1 value, Mapper.Context context)
        {
            IEnumerator <object> iter = ValueAggregatorJobBase.aggregatorDescriptorList.GetEnumerator
                                            ();

            while (iter.HasNext())
            {
                ValueAggregatorDescriptor ad = (ValueAggregatorDescriptor)iter.Next();
                IEnumerator <KeyValuePair <Text, Text> > ens = ad.GenerateKeyValPairs(key, value).GetEnumerator
                                                                   ();
                while (ens.HasNext())
                {
                    KeyValuePair <Text, Text> en = ens.Next();
                    context.Write(en.Key, en.Value);
                }
            }
        }