rowkey查询
public static User
getDataByRowKey(String tableName
, String rowKey
,String password
) throws IOException
{
Admin admin
= connection
.getAdmin();
Table table
= connection
.getTable(TableName
.valueOf(tableName
));
Get get
= new Get(rowKey
.getBytes());
User user
= new User();
user
.setName(rowKey
);
if(!get
.isCheckExistenceOnly()){
Result result
= table
.get(get
);
Cell
[] cells
= result
.rawCells();
for ( Cell cell
: cells
){
String colName
= Bytes
.toString(cell
.getQualifierArray(), cell
.getQualifierOffset(), cell
.getQualifierLength());
String value
= Bytes
.toString(cell
.getValueArray(), cell
.getValueOffset(), cell
.getValueLength());
System
.out
.println(" ========= "+colName
);
System
.out
.println("=========" + value
);
if(colName
.equals("pwd")){
user
.setPwd(value
);
}
if (colName
.equals("email")){
user
.setEmail(value
);
}
}
}
return user
;
}
转载请注明原文地址: https://lol.8miu.com/read-22052.html