import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.util.Bytes;
import java.io.IOException; /**
* 修改数据
*/
public class MutateDataSingle {
public static void main(String[] args) throws IOException{
Configuration configuration = HBaseConfiguration.create();
Connection connection = ConnectionFactory.createConnection(configuration);
//建立表的连接
Table table = connection.getTable(TableName.valueOf("testtable"));
//获取put实例
Put put = new Put(Bytes.toBytes("10086"));
put.addColumn(Bytes.toBytes("colfam1"),Bytes.toBytes("qual1"),4,Bytes.toBytes("china mobile 1"));
put.addColumn(Bytes.toBytes("colfam1"),Bytes.toBytes("qual4"),4,Bytes.toBytes("china mobile 4"));
//删除
Delete delete = new Delete(Bytes.toBytes("10086"));
delete.addColumn(Bytes.toBytes("colfam1"),Bytes.toBytes("qual1"));
//更新实例
RowMutations mutations = new RowMutations(Bytes.toBytes("10086"));
mutations.add(put);
mutations.add(delete);
table.mutateRow(mutations);
}
}
//olddata
/**
10086 column=colfam1:qual1, timestamp=1471836722159, value=\xE4\xB8\xAD\xE5\x9B\xBD\xE7\xA7\xBB\xE5\x8A\xA8
*/
//newdata
/**
10086 column=colfam1:qual1, timestamp=4, value=china mobile 1
10086 column=colfam1:qual4, timestamp=4, value=china mobile 4
**/

Hbase之更新单条数据的更多相关文章

  1. Django的restframework的序列化组件之对单条数据的处理

    之前我们学习的都是处理书籍或者出版社的所有的数据的方法,下面我们来看下处理单个书籍,或者单个出版社的方法 这个时候我们就需要重新写一个类,这个类的方法,就需要有3个参数,参数1是self,参数2是re ...

  2. hbase 基本的JavaApi 数据操作及数据过滤(filter)

    本文主要是hbase的表操作.数据操作.数据查询过滤等,如果对JDBC或ADO有了解,容易理解HBASE API. hbase版本是2.0. 1.为了方便先贴helper的部分代码(文末git上有完整 ...

  3. hadoop生态系统学习之路(八)hbase与hive的数据同步以及hive与impala的数据同步

    在之前的博文中提到,hive的表数据是能够同步到impala中去的. 一般impala是提供实时查询操作的,像比較耗时的入库操作我们能够使用hive.然后再将数据同步到impala中.另外,我们也能够 ...

  4. 使用TSQL查询和更新 JSON 数据

    JSON是一个非常流行的,用于数据交换的文本数据(textual data)格式,主要用于Web和移动应用程序中.JSON 使用“键/值对”(Key:Value pair)存储数据,能够表示嵌套键值对 ...

  5. ReactNative新手学习之路06滚动更新ListView数据的小示例

    本节带领大家学习使用ListView 做一个常用的滚动更新数据示例: 知识点: initialListSize={200} 第一次加载多少数据行 onEndReached={this.onEndRea ...

  6. Working with Data » Getting started with ASP.NET Core and Entity Framework Core using Visual Studio » 更新关系数据

    Updating related data¶ 7 of 7 people found this helpful The Contoso University sample web applicatio ...

  7. [渣译文] 使用 MVC 5 的 EF6 Code First 入门 系列:为ASP.NET MVC应用程序更新相关数据

    这是微软官方教程Getting Started with Entity Framework 6 Code First using MVC 5 系列的翻译,这里是第八篇:为ASP.NET MVC应用程序 ...

  8. Contoso 大学 - 6 – 更新关联数据

    原文 Contoso 大学 - 6 – 更新关联数据 By Tom Dykstra, Tom Dykstra is a Senior Programming Writer on Microsoft's ...

  9. SQL语法集锦一:显示每个类别最新更新的数据

    本文转载http://www.cnblogs.com/lxblog/archive/2012/09/28/2707504.html (1)显示每个类别最新更新的数据 在项目中经常遇到求每个类别最新显示 ...

随机推荐

  1. python请求java Selenium Webdriver

    下载jar包: selenium-server-standalone-2.44.0.jar 运行jar包: java -jar selenium-server-standalone-2.44.0.ja ...

  2. hrtimer和work工作队列的使用

    1.hrtimers - 为高分辨率kernel定时器,可作为超时或周期性定时器使用 1). hrtimer_init初始化定时器工作模式. hrtimer_init(&vibe_timer, ...

  3. SharePoint自动化系列——Create a local user and add to SharePoint

    转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 实现过程:在本地创建一个local user并将该user添加到Administrators组中, ...

  4. 项目文件中含有两个config文件,app.config与app1.config,如何获取app1.config中的配置

    想要通过配置文件配置C#前台画面,好奇做了以下测试:在项目中新建了app.config与app1.config两个配置文件,请教一下各位高手如果想从app1.config中读取配置信息应该如何读取?采 ...

  5. html的<marquee></marquee>标签实现滚动效果

    页面的自动滚动效果,可由javascript来实现,但是今天无意中发现了一个html标签 - <marquee></marquee>可以实现多种滚动效果,无需js控制. 使用m ...

  6. python代码

    f=open('/home/xbwang/newtextsimilarity/data/glove/glove.840B.300d.txt','r') count = 0 print ' '.join ...

  7. (7)redis pipeline

    redis是一个cs模式的tcp server,使用和http类似的请求响应协议.一个client可以通过一个socket连接发起多个请求命令.每个请求命令发出后client通常 会阻塞并等待redi ...

  8. Python 2.7.9 Demo - ini文件的读、写

    ini文件 [weixin_info] hello = Nick Huang #coding=utf-8 #!/usr/bin/python import ConfigParser; cp = Con ...

  9. Android BroadcastReceiver广播接受者

    静态注册 配置清单表注册:只要曾经注册过哪怕关闭也能调用  方式一:sendBroadCastReceive   广播的步骤:       发送  无序广播,普通广播       (1).发送方    ...

  10. CodeForces 651A Joysticks 贪心

    A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...