Exemplo n.º 1
0
 public override void IterateResults(TRowResult result)
 {
     foreach (KeyValuePair <byte[], TCell> pair in result.Columns)
     {
         Console.WriteLine("\tCol=" + Decode(pair.Key) + ", Value=" + Decode(pair.Value.Value));
     }
 }
        public TEntity BuildEntity(TRowResult input)
        {
            var target   = _activator.Activate();
            var accessor = ObjectAccessor.Create(target);

            var timestamps = new ConcurrentDictionary <string, long>();


            ProcessMap(_map, accessor, input.Columns, timestamps);
            RowkeyProcessor.PopulateEntity(target, _map.RowKey, input.Row, accessor);

            if (target is ITimestamp ts)
            {
                ts.Set(new Dictionary <string, long>(timestamps));
            }

            return(target);
        }
Exemplo n.º 3
0
        public T ToReal <T>(TRowResult trr) where T : class, IHbaseTable, new()
        {
            var real = new T
            {
                RowKey = trr.Row.ToObject <string>()
            };

            var nameWithFamily = GetPropertyNameWithFamilyStr <T>();
            var properties     = typeof(T).GetProperties()
                                 .Where(t => nameWithFamily.ContainsKey(t.Name))
                                 .ToList();

            var dict = trr.Columns.ToDictionary(t => t.Key.ToObject <string>());

            foreach (var property in properties)
            {
                if (dict.TryGetValue(nameWithFamily[property.Name], out var tCell))
                {
                    object v = tCell.Value.Value.ToObject(property.PropertyType);
                    property.SetValue(real, v);
                }
            }
            return(real);
        }
Exemplo n.º 4
0
        public void ToRealTest()
        {
            var tRow = new TRowResult
            {
                Row     = 1.ToBytes(),
                Columns = new Dictionary <byte[], TCell>
                {
                    { $"{HbaseColumnAttribute.DefaultFamily}:{nameof(_student.Name)}".ToBytes(), new TCell {
                          Value = _student.Name.ToBytes()
                      } },
                    { $"{HbaseColumnAttribute.DefaultFamily}:{nameof(_student.Age)}".ToBytes(), new TCell {
                          Value = _student.Age.ToBytes()
                      } },
                    { $"{HbaseColumnAttribute.DefaultFamily}:{nameof(_student.IsWork)}".ToBytes(), new TCell {
                          Value = _student.IsWork.ToBytes()
                      } },
                }
            };
            var student = _HbaseParser.ToReal <Student>(tRow);

            Assert.Equal(_student.Age, student.Age);
            Assert.Equal(_student.Name, student.Name);
            Assert.Equal(_student.IsWork, student.IsWork);
        }
 /**
  * Iterate result rows(just for test purpose)
  * @param result
  */
 public abstract void IterateResults(TRowResult result);
Exemplo n.º 6
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 0:
         if (field.Type == TType.List) {
           {
             Success = new List<TRowResult>();
             TList _list122 = iprot.ReadListBegin();
             for( int _i123 = 0; _i123 < _list122.Count; ++_i123)
             {
               TRowResult _elem124 = new TRowResult();
               _elem124 = new TRowResult();
               _elem124.Read(iprot);
               Success.Add(_elem124);
             }
             iprot.ReadListEnd();
           }
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 1:
         if (field.Type == TType.Struct) {
           Io = new IOError();
           Io.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
Exemplo n.º 7
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 0:
         if (field.Type == TType.List) {
           {
             Success = new List<TRowResult>();
             TList _list287 = iprot.ReadListBegin();
             for( int _i288 = 0; _i288 < _list287.Count; ++_i288)
             {
               TRowResult _elem289 = new TRowResult();
               _elem289 = new TRowResult();
               _elem289.Read(iprot);
               Success.Add(_elem289);
             }
             iprot.ReadListEnd();
           }
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 1:
         if (field.Type == TType.Struct) {
           Io = new IOError();
           Io.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 2:
         if (field.Type == TType.Struct) {
           Ia = new IllegalArgument();
           Ia.Read(iprot);
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }