Пример #1
0
 public TResult get(byte[] table, TGet get)
 {
     send_get(table, get);
     return recv_get();
 }
Пример #2
0
 public bool exists(byte[] table, TGet get)
 {
     send_exists(table, get);
     return recv_exists();
 }
Пример #3
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 1:
       if (field.Type == TType.String) {
     Table = iprot.ReadBinary();
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 2:
       if (field.Type == TType.Struct) {
     Get = new TGet();
     Get.Read(iprot);
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     default:
       TProtocolUtil.Skip(iprot, field.Type);
       break;
       }
       iprot.ReadFieldEnd();
     }
     iprot.ReadStructEnd();
 }
Пример #4
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 1:
       if (field.Type == TType.String) {
     Table = iprot.ReadBinary();
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     case 2:
       if (field.Type == TType.List) {
     {
       Gets = new List<TGet>();
       TList _list24 = iprot.ReadListBegin();
       for( int _i25 = 0; _i25 < _list24.Count; ++_i25)
       {
         TGet _elem26 = new TGet();
         _elem26 = new TGet();
         _elem26.Read(iprot);
         Gets.Add(_elem26);
       }
       iprot.ReadListEnd();
     }
       } else {
     TProtocolUtil.Skip(iprot, field.Type);
       }
       break;
     default:
       TProtocolUtil.Skip(iprot, field.Type);
       break;
       }
       iprot.ReadFieldEnd();
     }
     iprot.ReadStructEnd();
 }
Пример #5
0
 public void send_get(byte[] table, TGet get)
 {
     oprot_.WriteMessageBegin(new TMessage("get", TMessageType.Call, seqid_));
     get_args args = new get_args();
     args.Table = table;
     args.Get = get;
     args.Write(oprot_);
     oprot_.WriteMessageEnd();
     oprot_.Transport.Flush();
 }
Пример #6
0
        public static void FistTest()
        {
            Console.WriteLine("Thrift2 Demo");
            Console.WriteLine("This demo assumes you have a table called \"example\" with a column family called \"family1\"");

            String host = "hserver";
            int port = 9090;
            int timeout = 10000;
            var framed = false;

            TTransport transport = new TSocket(host, port, timeout);
            if (framed)
            {
                transport = new TFramedTransport(transport);
            }
            TProtocol protocol = new TBinaryProtocol(transport);
            // This is our thrift client.
            THBaseService.Iface client = new THBaseService.Client(protocol);

            // open the transport
            transport.Open();

            var table = "t1".ToBytes();

            TPut put = new TPut();
            put.Row = ("row1".ToBytes());

            for (var i = 0; i < 1000; i++)
            {

                TColumnValue columnValue = new TColumnValue();
                columnValue.Family = ("f1".ToBytes());
                columnValue.Qualifier = ("qualifier" + i).ToBytes();
                columnValue.Value = ("value" + i).ToBytes();
                List<TColumnValue> columnValues = new List<TColumnValue>();
                columnValues.Add(columnValue);
                put.ColumnValues = columnValues;

                client.put(table, put);
            }

            TGet get = new TGet();
            get.Row = ("row1".ToBytes());

            TResult result = client.get(table, get);

            Console.WriteLine("row = " + result.Row.ToStr());
            foreach (TColumnValue resultColumnValue in result.ColumnValues)
            {
                Console.WriteLine("family = " + resultColumnValue.Family.ToStr());
                Console.WriteLine("qualifier = " + resultColumnValue.Qualifier.ToStr());
                Console.WriteLine("value = " + resultColumnValue.Value.ToStr());
                Console.WriteLine("timestamp = " + resultColumnValue.Timestamp);
            }

            transport.Close();
        }