Example #1
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 protected override void Reduce(IntWritable key, IEnumerable <IntWritable> it, Reducer.Context
                                context)
 {
     foreach (IntWritable iw in it)
     {
         context.Write(iw, null);
     }
 }
Example #2
0
 // NOTHING
 /// <summary>This method is called once for each key.</summary>
 /// <remarks>
 /// This method is called once for each key. Most applications will define
 /// their reduce class by overriding this method. The default implementation
 /// is an identity function.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 protected internal virtual void Reduce(KEYIN key, IEnumerable <VALUEIN> values, Reducer.Context
                                        context)
 {
     foreach (VALUEIN value in values)
     {
         context.Write((KEYOUT)key, (VALUEOUT)value);
     }
 }
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 protected internal virtual void Emit(K key, V val, Reducer.Context context)
 {
     ++total;
     while ((float)kept / total < keep)
     {
         ++kept;
         context.Write(key, val);
     }
 }
Example #4
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 public virtual void Reduce(Org.Apache.Hadoop.IO.Text key, IEnumerator <Org.Apache.Hadoop.IO.Text
                                                                        > values, Reducer.Context context)
 {
     Org.Apache.Hadoop.IO.Text dumbKey = new Org.Apache.Hadoop.IO.Text(string.Empty);
     while (values.HasNext())
     {
         Org.Apache.Hadoop.IO.Text data = values.Next();
         context.Write(dumbKey, data);
     }
 }
Example #5
0
            /// <exception cref="System.IO.IOException"/>
            /// <exception cref="System.Exception"/>
            protected override void Reduce(LongWritable key, IEnumerable <Text> vals, Reducer.Context
                                           context)
            {
                long @out = 0;

                foreach (Text val in vals)
                {
                    @out++;
                }
                context.Write(key, new LongWritable(@out));
            }
Example #6
0
            /// <exception cref="System.IO.IOException"/>
            /// <exception cref="System.Exception"/>
            public virtual void Reduce(IntWritable key, IEnumerator <IntWritable> it, Reducer.Context
                                       context)
            {
                int keyint = key.Get();
                int total  = 0;

                while (it.HasNext())
                {
                    total += it.Next().Get();
                }
                context.Write(new IntWritable(keyint), new IntWritable(total));
            }
Example #7
0
            /// <exception cref="System.IO.IOException"/>
            /// <exception cref="System.Exception"/>
            protected override void Reduce(IntWritable key, IEnumerable <IntWritable> it, Reducer.Context
                                           context)
            {
                int keyint = key.Get();
                int count  = 0;

                foreach (IntWritable iw in it)
                {
                    count++;
                }
                context.Write(new IntWritable(keyint), new IntWritable(count));
            }
            /// <exception cref="System.IO.IOException"/>
            /// <exception cref="System.Exception"/>
            protected override void Reduce(LongWritable key, IEnumerable <Text> values, Reducer.Context
                                           context)
            {
                string id = context.GetTaskAttemptID().ToString();

                // Reducer 0 does not output anything
                if (!id.EndsWith("0_0"))
                {
                    foreach (Text val in values)
                    {
                        context.Write(key, val);
                    }
                }
            }
Example #9
0
            /// <exception cref="System.IO.IOException"/>
            /// <exception cref="System.Exception"/>
            protected override void Reduce(Text key, IEnumerable <LongWritable> values, Reducer.Context
                                           context)
            {
                LongWritable maxValue = null;

                foreach (LongWritable value in values)
                {
                    if (maxValue == null)
                    {
                        maxValue = value;
                    }
                    else
                    {
                        if (value.CompareTo(maxValue) > 0)
                        {
                            maxValue = value;
                        }
                    }
                }
                context.Write(key, maxValue);
            }
Example #10
0
            /// <exception cref="System.IO.IOException"/>
            /// <exception cref="System.Exception"/>
            protected override void Reduce(IntWritable key, IEnumerable <IntWritable> values,
                                           Reducer.Context context)
            {
                int errors = 0;
                MarkableIterator <IntWritable> mitr = new MarkableIterator <IntWritable>(values.GetEnumerator
                                                                                             ());

                switch (key.Get())
                {
                case 0:
                {
                    errors += Test0(key, mitr);
                    break;
                }

                case 1:
                {
                    errors += Test1(key, mitr);
                    break;
                }

                case 2:
                {
                    errors += Test2(key, mitr);
                    break;
                }

                case 3:
                {
                    errors += Test3(key, mitr);
                    break;
                }

                default:
                {
                    break;
                }
                }
                context.Write(key, new IntWritable(errors));
            }