本文整理汇总了Java中org.apache.hadoop.hbase.client.HTableInterface.get方法的典型用法代码示例。如果您正苦于以下问题:Java HTableInterface.get方法的具体用法?Java HTableInterface.get怎么用?Java HTableInterface.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.client.HTableInterface
的用法示例。
在下文中一共展示了HTableInterface.get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyRows
import org.apache.hadoop.hbase.client.HTableInterface; //导入方法依赖的package包/类
private void verifyRows(HTableInterface table, Get get, List<byte[]> expectedValues) throws Exception {
Result result = table.get(get);
if (expectedValues == null) {
assertTrue(result.isEmpty());
} else {
assertFalse(result.isEmpty());
byte[] family = TestBytes.family;
byte[] col = TestBytes.qualifier;
if (get.hasFamilies()) {
family = get.getFamilyMap().keySet().iterator().next();
col = get.getFamilyMap().get(family).first();
}
Iterator<Cell> it = result.getColumnCells(family, col).iterator();
for (byte[] expectedValue : expectedValues) {
Assert.assertTrue(it.hasNext());
assertArrayEquals(expectedValue, CellUtil.cloneValue(it.next()));
}
}
}
示例2: getRegionCountForTime
import org.apache.hadoop.hbase.client.HTableInterface; //导入方法依赖的package包/类
@VisibleForTesting
int getRegionCountForTime(HTableInterface stateTable, long time) throws IOException {
Get get = new Get(makeTimeRegionCountKey(Bytes.toBytes(getInvertedTime(time))));
get.addColumn(FAMILY, REGION_TIME_COL);
Result result = stateTable.get(get);
byte[] value = result.getValue(FAMILY, REGION_TIME_COL);
return value == null ? -1 : Bytes.toInt(value);
}
示例3: getProfilesFromHBase
import org.apache.hadoop.hbase.client.HTableInterface; //导入方法依赖的package包/类
public ProfilePojo[] getProfilesFromHBase(List<Long> userIds) throws IOException {
ArrayList<Get> getList = new ArrayList<Get>();
for (Long userId: userIds) {
getList.add(new Get(generateProfileRowKey(userId)));
}
HTableInterface profileTable = hTablePool.getTable(DataModelConsts.PROFILE_TABLE);
Result[] results = profileTable.get(getList);
ProfilePojo[] profiles = new ProfilePojo[getList.size()];
int counter = 0;
for (Result result: results) {
String[] fixedInfoValues = Bytes.toString(result.getColumnLatest(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.FIXED_INFO_COL).getValue()).split("|");
String username = fixedInfoValues[0];
int age = Integer.parseInt(fixedInfoValues[1]);
long firstLogIn = Long.parseLong(fixedInfoValues[2]);
long lastLogIn = Bytes.toLong(result.getColumnLatest(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.LAST_LOG_IN_COL).getValue());
long logInCount = Bytes.toLong(result.getColumnLatest(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.LOG_IN_COUNT_COL).getValue());
long logInCountHavingASell = Bytes.toLong(result.getColumnLatest(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.TOTAL_SELLS_COL).getValue());
long logInCountHavingAPurchase = Bytes.toLong(result.getColumnLatest(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.TOTAL_PURCHASES_COL).getValue());
long totalValueOfPastPurchases = Bytes.toLong(result.getColumnLatest(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.TOTAL_VALUE_OF_PAST_PURCHASES_COL).getValue());
long totalValueOfPastSells = Bytes.toLong(result.getColumnLatest(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.TOTAL_VALUE_OF_PAST_SELLS_COL).getValue());
long currentLogInSellsValue = Bytes.toLong(result.getColumnLatest(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.CURRENT_LOG_IN_SELLS_VALUE_COL).getValue());
long currentLogInPurchasesValue = Bytes.toLong(result.getColumnLatest(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.CURRENT_LOG_IN_PURCHASES_VALUE_COL).getValue());
HashSet<String> last20LogOnIpAddresses = new HashSet<String>();
List<KeyValue> ipAddresses = result.getColumn(DataModelConsts.PROFILE_COLUMN_FAMILY, DataModelConsts.LOG_IN_IP_ADDERSSES);
boolean isFirst = true;
String lastLogInIpAddress = null;
for (KeyValue kv: ipAddresses) {
if (isFirst) {
isFirst = false;
lastLogInIpAddress = Bytes.toString(kv.getValue());
} else {
last20LogOnIpAddresses.add(Bytes.toString(kv.getValue()));
}
}
ProfilePojo pojo = new ProfilePojo(username, age, firstLogIn, lastLogIn, lastLogInIpAddress,
logInCount, logInCountHavingASell, totalValueOfPastSells,
currentLogInSellsValue, logInCountHavingAPurchase,
totalValueOfPastPurchases, currentLogInPurchasesValue,
last20LogOnIpAddresses);
profiles[counter++] = pojo;
}
return profiles;
}
示例4: getRow
import org.apache.hadoop.hbase.client.HTableInterface; //导入方法依赖的package包/类
private Cell[] getRow(HTableInterface table, Get get) throws Exception {
Result result = table.get(get);
return result.rawCells();
}