( ) 是表结构对象,代表的是表的schema,包含了表的名字及其对应表的列族。
查看答案
Admin提供了一个用来管理 HBase 数据库表信息,负责表的( ) 处理的接口。
Result存储 Get 或者 Scan 操作后获取表的单行值。使用此类提供的方法可以直接获取( ) 或者各种 ( ) ( key-value 对)。
//查询某个学生所选的所有课程列表 学生1 @Test public void findCourseByStudent() throws IOException{ Table table = conn.getTable(tName); String stuId="student2016030421164483174"; ListcourseIds =new ArrayList(); Scan scan = new Scan(); RowFilter rf1 = new RowFilter(CompareOp.EQUAL, new RegexStringComparator(stuId+"_")); scan.setFilter(rf1); ResultScanner rs1 = table.getScanner(scan); Iteratorit = rs1.iterator(); while(it.hasNext()){ Result result = it.next(); byte[] rowKey = result.getRow(); courseIds.add(new String(rowKey,"utf8")); } for(String id : courseIds){ String courseId = id.split("_")[1]; Table courseTable = conn.getTable(tCourse); Get get = ( ) (courseId.getBytes()); Result result= courseTable.get(get); byte[] name = result. ( ) ("cf1".getBytes(), "name".getBytes()); System.out.println("课程ID:"+courseId+" 名称:"+new String(name,"utf8")); } }
public void create() throws IOException{ Admin admin = conn.getAdmin(); if(admin.tableExists(tName)){ admin.disableTable(tName); ( ) ; } HTableDescriptor ht = new HTableDescriptor(tName); HColumnDescriptor hc = new HColumnDescriptor("cf1".getBytes()); hc.setMaxVersions(5); hc.setBlockCacheEnabled(true); hc.setBlocksize(180000); ht.addFamily(hc); admin.( ) (ht); System.out.println("表创建完成"); }