本文整理匯總了Java中org.apache.hadoop.hbase.client.HTableInterface.put方法的典型用法代碼示例。如果您正苦於以下問題:Java HTableInterface.put方法的具體用法?Java HTableInterface.put怎麽用?Java HTableInterface.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.client.HTableInterface
的用法示例。
在下文中一共展示了HTableInterface.put方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: copyTable
import org.apache.hadoop.hbase.client.HTableInterface; //導入方法依賴的package包/類
/**
* 拷貝表
*
* @throws IOException
*/
public static void copyTable(String oldTableName, String newTableName,String ColumnFamily, String ColumnName)throws IOException {
if(CreateNewTable(newTableName))
logger.info("創建表"+newTableName+"表成功");
else{
logger.info("創建表"+newTableName+"表失敗");
}
Scan s = new Scan();
s.addColumn(Bytes.toBytes(ColumnFamily), Bytes.toBytes(ColumnName));
s.setMaxVersions(1);
s.setCacheBlocks(false);
ResultScanner rs = hbase_table.getScanner(s);
HTableInterface hbase_table_new = conn.getTable(newTableName);
for (Result r : rs) {
byte[] key = r.getRow();
byte[] value = r.getValue(Bytes.toBytes(ColumnFamily), Bytes.toBytes(ColumnName));
Put put = new Put(key);
put.add(Bytes.toBytes(ColumnFamily), Bytes.toBytes(ColumnName), value);
hbase_table_new.put(put);
}
rs.close();
hbase_table_new.close();
}
示例2: populateUserProfile
import org.apache.hadoop.hbase.client.HTableInterface; //導入方法依賴的package包/類
public static void populateUserProfile(HConnection connection, UserProfile userProfile) throws Exception {
HTableInterface table = connection.getTable(HBaseTableMetaModel.profileCacheTableName);
try {
Put put = new Put(convertKeyToRowKey(HBaseTableMetaModel.profileCacheTableName, userProfile.userId));
put.add(HBaseTableMetaModel.profileCacheColumnFamily, HBaseTableMetaModel.profileCacheJsonColumn, Bytes.toBytes(userProfile.getJSONObject().toString()));
put.add(HBaseTableMetaModel.profileCacheColumnFamily, HBaseTableMetaModel.profileCacheTsColumn, Bytes.toBytes(System.currentTimeMillis()));
table.put(put);
} finally {
table.close();
}
}
示例3: populateValidationRules
import org.apache.hadoop.hbase.client.HTableInterface; //導入方法依賴的package包/類
public static void populateValidationRules(HConnection connection, ValidationRules rules) throws Exception {
HTableInterface table = connection.getTable(HBaseTableMetaModel.profileCacheTableName);
try {
Put put = new Put(HBaseTableMetaModel.validationRulesRowKey);
put.add(HBaseTableMetaModel.profileCacheColumnFamily, HBaseTableMetaModel.validationRulesRowKey, Bytes.toBytes(rules.getJSONObject().toString()));
table.put(put);
} finally {
table.close();
}
}
示例4: saveRegionCountForTime
import org.apache.hadoop.hbase.client.HTableInterface; //導入方法依賴的package包/類
@VisibleForTesting
void saveRegionCountForTime(HTableInterface stateTable, byte[] timeBytes, int count) throws IOException {
Put put = new Put(makeTimeRegionCountKey(timeBytes));
put.add(FAMILY, REGION_TIME_COL, Bytes.toBytes(count));
stateTable.put(put);
}