Esempio n. 1
0
 /// <exception cref="System.IO.IOException"/>
 public override void ReadFields(DataInput @in)
 {
     lock (this)
     {
         name        = StringInterner.WeakIntern(Text.ReadString(@in));
         displayName = @in.ReadBoolean() ? StringInterner.WeakIntern(Text.ReadString(@in))
                                  : name;
         value = WritableUtils.ReadVLong(@in);
     }
 }
Esempio n. 2
0
            /// <exception cref="System.IO.IOException"/>
            public virtual void ReadFields(DataInput @in)
            {
                int len = WritableUtils.ReadVInt(@in);

                locations = new string[len];
                for (int i = 0; i < locations.Length; i++)
                {
                    locations[i] = Text.ReadString(@in);
                }
                startOffset     = WritableUtils.ReadVLong(@in);
                inputDataLength = WritableUtils.ReadVLong(@in);
            }
Esempio n. 3
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void ReadFields(DataInput @in)
        {
            Clear();
            int len = WritableUtils.ReadVInt(@in);

            T[] enums = enumClass.GetEnumConstants();
            for (int i = 0; i < len; ++i)
            {
                int     ord     = WritableUtils.ReadVInt(@in);
                Counter counter = NewCounter(enums[ord]);
                counter.SetValue(WritableUtils.ReadVLong(@in));
                counters[ord] = counter;
            }
        }
        /// <exception cref="System.IO.IOException"/>
        public virtual void ReadFields(DataInput @in)
        {
            int numSchemes = WritableUtils.ReadVInt(@in);

            // #scheme
            FileSystemCounter[] enums = FileSystemCounter.Values();
            for (int i = 0; i < numSchemes; ++i)
            {
                string scheme = WritableUtils.ReadString(@in);
                // scheme
                int numCounters = WritableUtils.ReadVInt(@in);
                // #counter
                for (int j = 0; j < numCounters; ++j)
                {
                    FindCounter(scheme, enums[WritableUtils.ReadVInt(@in)]).SetValue(WritableUtils.ReadVLong
                                                                                         (@in));
                }
            }
        }
        /// <exception cref="System.IO.IOException"/>
        public static Block[] ReadCompactBlockArray(DataInput @in, int logVersion)
        {
            int num = WritableUtils.ReadVInt(@in);

            if (num < 0)
            {
                throw new IOException("Invalid block array length: " + num);
            }
            Block prev = null;

            Block[] ret = new Block[num];
            for (int i = 0; i < num; i++)
            {
                long id = @in.ReadLong();
                long sz = WritableUtils.ReadVLong(@in) + ((prev != null) ? prev.GetNumBytes() : 0
                                                          );
                long gs = WritableUtils.ReadVLong(@in) + ((prev != null) ? prev.GetGenerationStamp
                                                              () : 0);
                ret[i] = new Block(id, sz, gs);
                prev   = ret[i];
            }
            return(ret);
        }
Esempio n. 6
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void ReadFields(DataInput @in)
 {
     file = new Path(WritableUtils.ReadString(@in));
     len  = WritableUtils.ReadVLong(@in);
 }
Esempio n. 7
0
 /// <summary>Reads a zero-compressed encoded long from a stream and return it.</summary>
 /// <param name="in">input stream</param>
 /// <exception cref="System.IO.IOException"/>
 /// <returns>deserialized long</returns>
 public static long ReadVLong(BinaryReader reader)
 {
     return(WritableUtils.ReadVLong(@in));
 }
Esempio n. 8
0
 /// <exception cref="System.IO.IOException"/>
 public virtual void ReadFields(DataInput @in)
 {
     splitLocation = Org.Apache.Hadoop.IO.Text.ReadString(@in);
     startOffset   = WritableUtils.ReadVLong(@in);
 }
Esempio n. 9
0
 public override void Run()
 {
     while (true)
     {
         try
         {
             if (Sharpen.Thread.CurrentThread().IsInterrupted())
             {
                 throw new Exception();
             }
             int cmd = WritableUtils.ReadVInt(inStream);
             Log.Debug("Handling uplink command " + cmd);
             if (cmd == BinaryProtocol.MessageType.AuthenticationResp.code)
             {
                 string digest = Text.ReadString(inStream);
                 authPending = !handler.Authenticate(digest);
             }
             else
             {
                 if (authPending)
                 {
                     Log.Warn("Message " + cmd + " received before authentication is " + "complete. Ignoring"
                              );
                     continue;
                 }
                 else
                 {
                     if (cmd == BinaryProtocol.MessageType.Output.code)
                     {
                         ReadObject(key);
                         ReadObject(value);
                         handler.Output(key, value);
                     }
                     else
                     {
                         if (cmd == BinaryProtocol.MessageType.PartitionedOutput.code)
                         {
                             int part = WritableUtils.ReadVInt(inStream);
                             ReadObject(key);
                             ReadObject(value);
                             handler.PartitionedOutput(part, key, value);
                         }
                         else
                         {
                             if (cmd == BinaryProtocol.MessageType.Status.code)
                             {
                                 handler.Status(Text.ReadString(inStream));
                             }
                             else
                             {
                                 if (cmd == BinaryProtocol.MessageType.Progress.code)
                                 {
                                     handler.Progress(inStream.ReadFloat());
                                 }
                                 else
                                 {
                                     if (cmd == BinaryProtocol.MessageType.RegisterCounter.code)
                                     {
                                         int    id    = WritableUtils.ReadVInt(inStream);
                                         string group = Text.ReadString(inStream);
                                         string name  = Text.ReadString(inStream);
                                         handler.RegisterCounter(id, group, name);
                                     }
                                     else
                                     {
                                         if (cmd == BinaryProtocol.MessageType.IncrementCounter.code)
                                         {
                                             int  id     = WritableUtils.ReadVInt(inStream);
                                             long amount = WritableUtils.ReadVLong(inStream);
                                             handler.IncrementCounter(id, amount);
                                         }
                                         else
                                         {
                                             if (cmd == BinaryProtocol.MessageType.Done.code)
                                             {
                                                 Log.Debug("Pipe child done");
                                                 handler.Done();
                                                 return;
                                             }
                                             else
                                             {
                                                 throw new IOException("Bad command code: " + cmd);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         catch (Exception)
         {
             return;
         }
         catch (Exception e)
         {
             Log.Error(StringUtils.StringifyException(e));
             handler.Failed(e);
             return;
         }
     }
 }