Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 private bool ReadFromQueue()
 {
     Chain.KeyValuePair <KEYIN, VALUEIN> kv = null;
     // wait for input on queue
     kv = inputQueue.Dequeue();
     if (kv.endOfInput)
     {
         return(false);
     }
     key   = (KEYIN)ReflectionUtils.NewInstance(keyClass, conf);
     value = (VALUEIN)ReflectionUtils.NewInstance(valueClass, conf);
     ReflectionUtils.Copy(conf, kv.key, this.key);
     ReflectionUtils.Copy(conf, kv.value, this.value);
     return(true);
 }
Ejemplo n.º 3
0
 /// <summary>Advance to the next key, value pair, returning null if at end.</summary>
 /// <returns>the key object that was read into, or null if no more</returns>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 public override bool NextKeyValue()
 {
     if (inputQueue != null)
     {
         return(ReadFromQueue());
     }
     else
     {
         if (inputContext.NextKeyValue())
         {
             this.key   = inputContext.GetCurrentKey();
             this.value = inputContext.GetCurrentValue();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>Advance to the next key/value pair.</summary>
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        public override bool NextKeyValue()
        {
            if (!hasMore)
            {
                key   = null;
                value = null;
                return(false);
            }
            firstValue = !nextKeyIsSame;
            DataInputBuffer nextKey = input.GetKey();

            currentRawKey.Set(nextKey.GetData(), nextKey.GetPosition(), nextKey.GetLength() -
                              nextKey.GetPosition());
            buffer.Reset(currentRawKey.GetBytes(), 0, currentRawKey.GetLength());
            key = keyDeserializer.Deserialize(key);
            DataInputBuffer nextVal = input.GetValue();

            buffer.Reset(nextVal.GetData(), nextVal.GetPosition(), nextVal.GetLength() - nextVal
                         .GetPosition());
            value              = valueDeserializer.Deserialize(value);
            currentKeyLength   = nextKey.GetLength() - nextKey.GetPosition();
            currentValueLength = nextVal.GetLength() - nextVal.GetPosition();
            if (isMarked)
            {
                backupStore.Write(nextKey, nextVal);
            }
            hasMore = input.Next();
            if (hasMore)
            {
                nextKey       = input.GetKey();
                nextKeyIsSame = comparator.Compare(currentRawKey.GetBytes(), 0, currentRawKey.GetLength
                                                       (), nextKey.GetData(), nextKey.GetPosition(), nextKey.GetLength() - nextKey.GetPosition
                                                       ()) == 0;
            }
            else
            {
                nextKeyIsSame = false;
            }
            inputValueCounter.Increment(1);
            return(true);
        }
Ejemplo n.º 5
0
 // NOTHING
 /// <summary>Called once for each key/value pair in the input split.</summary>
 /// <remarks>
 /// Called once for each key/value pair in the input split. Most applications
 /// should override this, but the default is the identity function.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 protected internal virtual void Map(KEYIN key, VALUEIN value, Mapper.Context context
                                     )
 {
     context.Write((KEYOUT)key, (VALUEOUT)value);
 }