Beispiel #1
0
        public static void Insert(FuncionarioModel model)
        {
            try
            {
                var socket    = new TSocket(host, port);
                var transport = new TBufferedTransport(socket);
                var proto     = new TBinaryProtocol(transport);
                _hbase = new Hbase.Client(proto);
                transport.Open();



                _hbase.mutateRows(table_name, new List <BatchMutation>()
                {
                    new BatchMutation()
                    {
                        Row       = Encoding.UTF8.GetBytes(model.GetRowKey()),
                        Mutations = new List <Mutation> {
                            new Mutation {
                                Column = Encoding.UTF8.GetBytes("fc:ano"), IsDelete = false, Value = Encoding.UTF8.GetBytes(model.Ano.ToString())
                            },
                            new Mutation {
                                Column = Encoding.UTF8.GetBytes("fc:mes"), IsDelete = false, Value = Encoding.UTF8.GetBytes(model.Mes.ToString())
                            },
                            new Mutation {
                                Column = Encoding.UTF8.GetBytes("fc:cpf"), IsDelete = false, Value = Encoding.UTF8.GetBytes(model.Cpf.ToString())
                            },
                            new Mutation {
                                Column = Encoding.UTF8.GetBytes("fc:nome"), IsDelete = false, Value = Encoding.UTF8.GetBytes(model.Nome.ToString())
                            },
                            new Mutation {
                                Column = Encoding.UTF8.GetBytes("fc:salario"), IsDelete = false, Value = Encoding.UTF8.GetBytes(model.Salario.ToString())
                            },
                            new Mutation {
                                Column = Encoding.UTF8.GetBytes("fc:jetons"), IsDelete = false, Value = Encoding.UTF8.GetBytes(model.Jetons.ToString())
                            }
                        }
                    }
                });

                transport.Close();
            }
            catch (Exception)
            {
                throw;
            }
        }