精品文档。1欢迎下载实验 4 熟悉常用的HBase操作姓名:包生友专业年级:软件 143 学号: 2014012699 1. 实验目的1. 理解 HBase在 Hadoop体系结构中的角色;2. 熟练使用 HBase操作常用的Shell命令;3. 熟悉 HBase操作常用的Java API 。2. 实验环境操作系统: Linux Hadoop版本: 2.6.0或以上版本HBase版本: 1.1.2或以上版本JDK版本: 1.6 或以上版本Java IDE :Eclipse 3. 实验内容和完成情况1. 编程实现以下指定功能,并用Hadoop 提供的 HBase Shell命令完成相同任务:(完整可执行代码见代码 /QuestionOne.java)(1)列出 HBase所有的表的相关信息,例如表名;Shell: List 图 1 列出 HBase 所有表的相关信息编程://(1)列出 HBase所有的表的相关信息,例如表名、创建时间等public static void listTables() throws IOException { init();//建立连接 HTableDescriptor hTableDescriptors[] = admin.listTables(); 精品文档。2欢迎下载 for(HTableDescriptor hTableDescriptor :hTableDescriptors){ System.out.println("表名 :"+hTableDescriptor.getNameAsString()); } close();//关闭连接} (2)在终端打印出指定的表的所有记录数据;Shell: scan 's1' 图 2 打印指定表的所有记录数据编程://(2)在终端打印出指定的表的所有记录数据public static void getData(String tableName)throws IOException{ init(); Table table = connection.getTable(TableName.valueOf(tableName)); Scan scan = new Scan(); ResultScanner scanner = table.getScanner(scan); for (Result result:scanner){ printRecoder(result); } close(); } // 打印一条记录的详情public static void printRecoder(Result result)throws IOException{ for(Cell cell:result.rawCells()){ System.out.print("行健 : "+new String(CellUtil.cloneRow(cell))); System.out.print("列簇 : "+new String(CellUtil.cloneFamily(cell))); System.out.print(" 列: "+new String(CellUtil.cloneQualifier(cell))); System.out.print(" 值: "+new String(CellUtil.cloneValue(cell))); 精品文档。3欢迎下载 System.out.println("时间戳 : "+cell.getTimestamp()); } } (3)向已经创建好的表添加和删除指定的列族或列;p.s :此题请先在Shell中创建 s1...