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'}
     **/
  • 相关阅读:
    出于安全考虑,office outlook禁止对潜在不安全因素的附件访问,如何解决
    70级圣骑士OK了,纪念下先!
    03.配置putty连接Linux系统,并实现中英文输入输出;配置vnc服务器
    想了解你好有的装备及属性吗,副本及飞行点的位置吗?简单!
    Windows Server 2008 下载、安装、激活
    同事的U盘写保护了!
    重新开始核心编程,Windows的开始
    如何知道某PC接入到交换机的哪个端口上
    DK装备获取线路总结
    Windows Server 2008 评估时间延期
  • 原文地址:https://www.cnblogs.com/similarface/p/5821910.html
Copyright © 2011-2022 走看看