-
HBase的各种实例包括新增、修改、删除以及批量导入操作
资源介绍
hbase各种例子新增修改删除批量导入:
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();
HBaseHelper helper = HBaseHelper.getHelper(conf);
helper.dropTable("testtable");
helper.createTable("testtable", "colfam1");
HTable table = new HTable(conf, "testtable");
// vv PutListExample
List puts = new ArrayList(); // co PutListExample-1-CreateList Create a list that holds the Put instances.
Put put1 = new Put(Bytes.toBytes("row1"));
put1.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"),
Bytes.toBytes("val1"));
puts.add(put1); // co PutListExample-2-AddPut1 Add put to list.
Put put2 = new Put(Bytes.toBytes("row2"));
put2.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"),
Bytes.toBytes("val2"));
puts.add(put2); // co PutListExample-3-AddPut2 Add another put to list.
Put put3 = new Put(Bytes.toBytes("row2"));
put3.add(Bytes.toBytes("colfam1"), Bytes.toBytes("qual2"),
Bytes.toBytes("val3"));
puts.add(put3); // co PutListExample-4-AddPut3 Add third put to list.
table.put(puts); // co PutListExample-5-DoPut Store multiple rows with columns into HBase.
// ^^ PutListExample
}
- 上一篇: hbase中文文档
- 下一篇: Hbase 官方中文文档