表格存储服务 CloudTable
表格存储服务 CloudTable
- 最新动态
- 产品介绍
- 计费说明
- 快速入门
-
用户指南
- HBase用户指南
- Doris用户指南
- ClickHouse用户指南
- 权限管理
- 审计日志
- 集群日志管理
- 最佳实践
- 开发指南
- API参考
- SDK参考
-
常见问题
-
通用类
- CloudTable集群能够提供什么服务?
- 为什么要选择CloudTable服务?
- 创建CloudTable HBase集群要准备什么?
- 使用CloudTable服务时需要关注什么?
- CloudTable HBase集群支持哪些压缩算法?
- 能停止CloudTable服务吗?
- CloudTable中的HBase外部接口支持哪些编程语言?
- 故障RegionServer个数怎么判断?
- CloudTable HBase支持的特殊符号?
- CloudTable数据进行删除,导致索引表和数据表不对应查询异常处理办法?
- python通过thrift访问cloudtable,多个任务并行缓慢
- 如何查看HBase shell的TTL属性?
- 服务器资源为什么会被释放?
- 资源停止服务或逾期释放说明
- 哪些场景会影响数据均衡?
- 如何调整数据均衡的灵敏度,调整后有哪些影响?
- Doris集群回收站数据处理
- 连接访问类
- 数据读写类
- 数据导入
- 网络配置
- 计费类
-
通用类
- 文档下载
- 通用参考
链接复制成功!
使用Get读取数据
功能简介
要从表中读取一条数据,首先需要实例化该表对应的Table实例,然后创建一个Get对象。
可以为Get对象设定参数值,如列族的名称和列的名称。
查询到的行数据存储在Result对象中,Result中可以存储多个Cell。
代码样例
public void testGet() { LOG.info("Entering testGet."); // Specify the column family name. byte[] familyName = Bytes.toBytes("info"); // Specify the column name. byte[][] qualifier = { Bytes.toBytes("name"), Bytes.toBytes("address") }; // Specify RowKey. byte[] rowKey = Bytes.toBytes("012005000201"); Table table = null; try { // Create the Table instance. table = conn.getTable(tableName); // Instantiate a Get object. Get get = new Get(rowKey); // Set the column family name and column name. get.addColumn(familyName, qualifier[0]); get.addColumn(familyName, qualifier[1]); // Submit a get request. Result result = table.get(get); // Print query results. for (Cell cell : result.rawCells()) { LOG.info(Bytes.toString(CellUtil.cloneRow(cell)) + ":" + Bytes.toString(CellUtil.cloneFamily(cell)) + "," + Bytes.toString(CellUtil.cloneQualifier(cell)) + "," + Bytes.toString(CellUtil.cloneValue(cell))); } LOG.info("Get data successfully."); } catch (IOException e) { LOG.error("Get data failed " ,e); } finally { if (table != null) { try { // Close the HTable object. table.close(); } catch (IOException e) { LOG.error("Close table failed " ,e); } } } LOG.info("Exiting testGet."); }
父主题: 样例代码说明