当前位置: 首页>>代码示例>>Java>>正文


Java HTableInterface.get方法代码示例

本文整理汇总了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()));
    }
  }
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:20,代码来源:TransactionAwareHTableTest.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:9,代码来源:DataJanitorState.java

示例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;
}
 
开发者ID:amitchmca,项目名称:hadooparchitecturebook,代码行数:59,代码来源:BasicFraudHBaseService.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:5,代码来源:TransactionAwareHTableTest.java


注:本文中的org.apache.hadoop.hbase.client.HTableInterface.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。