當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。