示例#1
0
        public static void AddColumn()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));


            transport.Open();


            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);


            //client.createTable(Unitl.StrToBytes("t"), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("default"), InMemory = false } });
            //client.createTable(Unitl.StrToBytes("thetable"), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("default"), InMemory = false } });

            for (var i = 0; i < 10; i++)
            {
                client.mutateRow(Unitl.StrToBytes("t"),

                                 Unitl.StrToBytes("key"),
                                 new List <Mutation> {
                    new Mutation {
                        Column = Unitl.StrToBytes("default:" + i), Value = Unitl.StrToBytes(System.DateTime.Now.ToString())
                    }
                });
            }
            transport.Close();
        }
示例#2
0
        public static void BatAddData()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));


            transport.Open();


            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            //client.createTable(Unitl.StrToBytes(tablename), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("zbw911"), InMemory = false } });

            var bytevalue = Unitl.StrToBytes(Longdata);

            for (var j = 0; j < 100000; j++)
            {
                //var j = 0;
                for (var i = 0; i < 1000; i++)
                {
                    client.mutateRow(Unitl.StrToBytes("1"), Unitl.StrToBytes("" + i + "___" + j), new List <Mutation> {
                        new Mutation {
                            Column = Unitl.StrToBytes("zbw911"), Value = bytevalue
                        }
                    });
                }

                Console.WriteLine(j + "批=" + 1000 * j);
            }


            transport.Close();
        }
示例#3
0
        public HClient()
        {
            socket         = new TSocket(host, port);
            this.Transport = new TBufferedTransport(socket);
            //Transport.Open();
            this.protocol = new TBinaryProtocol(Transport);
            this.Client   = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            this.IsFree = true;
        }
示例#4
0
        public HClient()
        {
            socket = new TSocket(host, port);
            this.Transport = new TBufferedTransport(socket);
            //Transport.Open();
            this.protocol = new TBinaryProtocol(Transport);
            this.Client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            this.IsFree = true;
        }
示例#5
0
        public static void Scan()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));


            transport.Open();


            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            var scanid = client.scannerOpenWithStop(Unitl.StrToBytes("t1"), Unitl.StrToBytes("rowno"), Unitl.StrToBytes("rowno"),
                                                    new List <byte[]> {
                Unitl.StrToBytes("f1:99913")
            });

            var result = client.scannerGet(scanid);

            var colum = client.getColumnDescriptors("t1".ToBytes());

            var rows = client.getRowsWithColumns("t1".ToBytes()
                                                 , new List <byte[]> {
                "rowno".ToBytes()
            }
                                                 , new List <byte[]> {
                "f1:9".ToBytes(), "f1:9999".ToBytes()
            });


            //scanid = client.scannerOpenWithPrefix("".ToBytes(), "".ToBytes(), new List<byte[]> { });

            var v = client.getVer("table".ToBytes(), "row".ToBytes(), "col".ToBytes(), 1000);

            foreach (var xx in v)
            {
            }



            foreach (var r in result)
            {
                Console.WriteLine(r.Columns[Unitl.StrToBytes("f1:99913")].Value);
            }

            client.scannerClose(scanid);

            transport.Close();
        }
示例#6
0
        public static void GetData()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));


            transport.Open();


            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            var rows = client.getRow(Unitl.StrToBytes("1"), Unitl.StrToBytes("row9916"));

            foreach (var row in rows)
            {
                Console.WriteLine(row.Columns.ToString());
            }

            transport.Close();
        }
示例#7
0
        public static void ShowTables()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));


            transport.Open();


            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            var tables = client.getTableNames();

            foreach (var table in tables)
            {
                Console.WriteLine(Unitl.BytesToStr(table));
            }

            transport.Close();
        }
示例#8
0
        public static void AddData(string row)
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));


            transport.Open();


            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);


            //client.createTable(Unitl.StrToBytes(tablename), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("zbw911"), InMemory = false } });

            client.mutateRow(Unitl.StrToBytes("1"), Unitl.StrToBytes(row), new List <Mutation> {
                new Mutation {
                    Column = Unitl.StrToBytes("zbw911"), Value = Unitl.StrToBytes("zbw911")
                }
            });

            transport.Close();
        }
示例#9
0
        public static void UpdateData()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));

            transport.Open();

            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            //client.createTable(Unitl.StrToBytes(tablename), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("zbw911"), InMemory = false } });

            client.mutateRow(Unitl.StrToBytes("1"), Unitl.StrToBytes("key"), new List<Mutation> { new Mutation { Column = Unitl.StrToBytes("zbw911"), Value = Unitl.StrToBytes("zbw911-Modifyed") } });

            transport.Close();
        }
示例#10
0
        public static void ShowTables()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));

            transport.Open();

            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            var tables = client.getTableNames();

            foreach (var table in tables)
            {
                Console.WriteLine(Unitl.BytesToStr(table));
            }

            transport.Close();
        }
示例#11
0
        public static void Scan()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));

            transport.Open();

            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            var scanid = client.scannerOpenWithStop(Unitl.StrToBytes("t1"), Unitl.StrToBytes("rowno"), Unitl.StrToBytes("rowno"),
                new List<byte[]> { Unitl.StrToBytes("f1:99913") });

            var result = client.scannerGet(scanid);

            var colum = client.getColumnDescriptors("t1".ToBytes());

            var rows = client.getRowsWithColumns("t1".ToBytes()
                  , new List<byte[]> { "rowno".ToBytes() }
                  , new List<byte[]> { "f1:9".ToBytes(), "f1:9999".ToBytes() });

            //scanid = client.scannerOpenWithPrefix("".ToBytes(), "".ToBytes(), new List<byte[]> { });

            var v = client.getVer("table".ToBytes(), "row".ToBytes(), "col".ToBytes(), 1000);

            foreach (var xx in v)
            {

            }

            foreach (var r in result)
            {
                Console.WriteLine(r.Columns[Unitl.StrToBytes("f1:99913")].Value);
            }

            client.scannerClose(scanid);

            transport.Close();
        }
示例#12
0
        public static void GetData()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));

            transport.Open();

            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            var rows = client.getRow(Unitl.StrToBytes("1"), Unitl.StrToBytes("row9916"));

            foreach (var row in rows)
            {
                Console.WriteLine(row.Columns.ToString());
            }

            transport.Close();
        }
示例#13
0
        public static void BatAddData()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));

            transport.Open();

            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            //client.createTable(Unitl.StrToBytes(tablename), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("zbw911"), InMemory = false } });

            var bytevalue = Unitl.StrToBytes(Longdata);

            for (var j = 0; j < 100000; j++)
            {
                //var j = 0;
                for (var i = 0; i < 1000; i++)
                {
                    client.mutateRow(Unitl.StrToBytes("1"), Unitl.StrToBytes("" + i + "___" + j), new List<Mutation> { new Mutation { Column = Unitl.StrToBytes("zbw911"), Value = bytevalue } });
                }

                Console.WriteLine(j + "批=" + 1000 * j);
            }

            transport.Close();
        }
示例#14
0
        public static void AddTable(string tablename)
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));

            transport.Open();

            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            client.createTable(Unitl.StrToBytes(tablename), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("zbw911"), InMemory = false } });

            transport.Close();
        }
示例#15
0
        public static void AddColumn()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));

            transport.Open();

            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            //client.createTable(Unitl.StrToBytes("t"), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("default"), InMemory = false } });
            //client.createTable(Unitl.StrToBytes("thetable"), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("default"), InMemory = false } });

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

                client.mutateRow(Unitl.StrToBytes("t"),

                    Unitl.StrToBytes("key"),
                    new List<Mutation> {
                        new Mutation { Column = Unitl.StrToBytes("default:"+i ), Value = Unitl.StrToBytes( System.DateTime.Now.ToString() ) }

                    });

            }
            transport.Close();
        }