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'}
     **/
  • 相关阅读:
    Android 中日期对话框的应用
    Unity3d 生命周期
    C#读写txt文件的两种方法介绍
    C# 获取文件夹下的所有文件夹及其文件
    NPOI 导出Excel
    SqlParameter 参数化模糊查询
    项目中的一个分页功能pagination
    MVC ---- ckeditor 循环遍历并绑定blur事件
    JQUERY链式操作实例分析
    mvc ---- ajax 提交过来的Json格式如何处理(解析)
  • 原文地址:https://www.cnblogs.com/similarface/p/5821910.html
Copyright © 2011-2022 走看看