zoukankan      html  css  js  c++  java
  • HBase之show table

    import org.apache.hadoop.hbase.HTableDescriptor;
    import org.apache.hadoop.hbase.TableName;
    import org.apache.hadoop.hbase.client.Admin;
    import org.apache.hadoop.hbase.client.Connection;
    import org.apache.hadoop.hbase.client.ConnectionFactory;
    
    import java.io.IOException;
    import java.util.regex.Pattern;
    
    /**
     * Created by similarface on 16/8/30.
     */
    public class ShowTableInHbase {
        public static void main(String args[]) throws IOException{
            Connection connection = ConnectionFactory.createConnection();
            Admin admin = connection.getAdmin();
            HTableDescriptor[] htds = admin.listTables();
            for (HTableDescriptor htd:htds){
                System.out.println(htd);
            }
            HTableDescriptor htd1 = admin.getTableDescriptor(TableName.valueOf("user"));
            System.out.println(htd1);
    
            HTableDescriptor htd2 = admin.getTableDescriptor(TableName.valueOf("user"));
            System.out.println(htd2);
    
            HTableDescriptor[] htdsall = admin.listTables(".*");
            htds = admin.listTables(".*", true);
            htds = admin.listTables("hbase:.*", true);
            htds = admin.listTables("def.*:.*", true);
            htds = admin.listTables("test.*");
            Pattern pattern = Pattern.compile(".*2");
            htds = admin.listTables(pattern);
            htds = admin.listTableDescriptorsByNamespace("testspace1");
    
        }
    }
    
    /**
     'testtable2', {NAME => 'colfam1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
     'user', {NAME => 'info', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'ship', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
     'user', {NAME => 'info', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'ship', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
     'user', {NAME => 'info', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'ship', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
     **/
  • 相关阅读:
    Selenium+java
    小白学习安全测试(一)——Http协议基础
    解决chrome运行报错unknown error: cannot get automation extension
    Eclipse 中 不能创建 Dynamic web project
    Jmeter遇到Connection reset by peer的解决方法
    用Java检测远程主机是否能被连接
    Java 连接远程Linux 服务器执行 shell 脚本查看 CPU、内存、硬盘信息
    jenkins的svn路径中文问题
    MySql的存储引擎介绍
    Netty SSL性能调优
  • 原文地址:https://www.cnblogs.com/similarface/p/5821910.html
Copyright © 2011-2022 走看看