zoukankan      html  css  js  c++  java
  • Hbase API 写入操作代码,基于hbase-client 1.0.3版本

        <dependency>
          <groupId>org.apache.hbase</groupId>
          <artifactId>hbase-client</artifactId>
          <version>1.0.3</version>
        </dependency>
    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.hbase.HBaseConfiguration;
    import org.apache.hadoop.hbase.TableName;
    import org.apache.hadoop.hbase.client.BufferedMutator;
    import org.apache.hadoop.hbase.client.BufferedMutatorParams;
    import org.apache.hadoop.hbase.client.Connection;
    import org.apache.hadoop.hbase.client.ConnectionFactory;
    import org.apache.hadoop.hbase.client.Put;
    import org.apache.hadoop.hbase.client.Table;
    import org.apache.hadoop.hbase.util.Bytes;
    import java.io.IOException;
    
    public class HbaseTest01 {
        public static void main(String[] args) throws IOException{
            TableName name = TableName.valueOf("testtable");
            Configuration conf = HBaseConfiguration.create();
            Connection connection = ConnectionFactory.createConnection(conf);
            Table table = connection.getTable(name);
            
            BufferedMutator mutator = connection.getBufferedMutator(name);
            
            for (int i = 0; i < 1000000; i++){
                
                String rowStr = "row"+i;
                String valStr = "val"+i;
                
                Put put = new Put(Bytes.toBytes(rowStr));
                put.addColumn(Bytes.toBytes("colfam1"), Bytes.toBytes("qual1"), Bytes.toBytes(valStr));
                
                mutator.mutate(put);
            }
            
            mutator.close();
            table.close();
            connection.close(); 
            System.out.println("done!");
        }
    }
  • 相关阅读:
    Splashtop :符合 HIPAA 标准的远程桌面软件
    学生如何在家中访问学校许可的软件
    Splashtop用于远程实验室的功能得到增强
    docker环境安装,镜像和容器常用命令
    vue-cli入门
    webpack快速入门
    Vue路由vue-router
    Vue组件化
    Vue指令
    Vue实例
  • 原文地址:https://www.cnblogs.com/zhengchunhao/p/5684111.html
Copyright © 2011-2022 走看看