zoukankan      html  css  js  c++  java
  • Hbase之尝试使用错误列族获取数据

    import com.google.common.base.Strings;
    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;
    import java.util.ArrayList;
    import java.util.List;
    
    /**
     * 尝试获取数据使用错误的列族
     */
    public class GetDataWithErrorColFamily {
        public static void main(String args[]) throws IOException {
            Configuration configuration = HBaseConfiguration.create();
            Connection connection = ConnectionFactory.createConnection(configuration);
            //建立表的连接
            Table table = connection.getTable(TableName.valueOf("testtable"));
            List<Get> gets = new ArrayList<Get>();
            //列族
            byte[] cf1 = Bytes.toBytes("colfam1");
            //列限定符
            byte[] qf1 = Bytes.toBytes("qual1");
            //列限定符
            byte[] qf2 = Bytes.toBytes("qual2");
            //行键
            byte[] row1 = Bytes.toBytes("10010");
            //行键
            byte[] row2 = Bytes.toBytes("10086");
            Get get1 = new Get(row1);
            get1.addColumn(cf1,qf1);
            gets.add(get1);
    
            Get get2 = new Get(row2);
            get2.addColumn(cf1,qf1);
            gets.add(get2);
    
            Get get3 = new Get(row2);
            get3.addColumn(cf1,qf2);
            gets.add(get3);
    
            Get get4 = new Get(row2);
            //这个列族根本不存在
            get4.addColumn(Bytes.toBytes("BOGUS"), qf2);
            gets.add(get4);
    
            //抛出异常 进程中断
            //Exception in thread "main" org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException: Failed 1 action: org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException: Column family BOGUS does not exist in region testtable,,1470907049676.32bcdb9d8df5829ae7eda1ae06cc9dc0. in table 'testtable', {NAME => 'colfam1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', COMPRESSION => 'NONE', VERSIONS => '1', TTL => 'FOREVER', MIN_VERSIONS => '0', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
            Result[] results = table.get(gets);
            //下面的打印到达并了
            System.out.println("Result count: " + results.length);
        }
    }
    
  • 相关阅读:
    R语言中gsub使用示例记录
    linux 系统中wget实现并行下载
    R语言中实现将多行数据合并为一行
    python安装包国内镜像加速
    VMware Workstation 与 Device/Credential Guard不兼容
    缩放矩阵, 这里面有关于矩阵的 种种操作 这个要学下 很有用
    ffd 点的控制效果、
    摘抄 : max mel 的一些用法。
    帮朋友写的查找选择的父子骨骼。之前我都是用递归,这个好、
    距离的算法。 下面两个是对等的。
  • 原文地址:https://www.cnblogs.com/similarface/p/5795515.html
Copyright © 2011-2022 走看看