本文整理汇总了Java中org.apache.hadoop.hbase.client.HTableInterface.close方法的典型用法代码示例。如果您正苦于以下问题:Java HTableInterface.close方法的具体用法?Java HTableInterface.close怎么用?Java HTableInterface.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.client.HTableInterface
的用法示例。
在下文中一共展示了HTableInterface.close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: QueryAll
import org.apache.hadoop.hbase.client.HTableInterface; //导入方法依赖的package包/类
public static void QueryAll(String tableName) {
try {
HTableInterface table = conn.getTable(tableName);
ResultScanner rs = table.getScanner(new Scan());
for (Result r : rs) {
System.out.println("rowkey:" + new String(r.getRow()));
for (KeyValue keyValue : r.raw()) {
System.out.println("column:" + new String(keyValue.getFamily())
+ "====value:" + new String(keyValue.getValue()));
}
}
table.close();
} catch (IOException e) {
e.printStackTrace();
}
}
示例2: 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();
}
示例3: 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();
}
}
示例4: 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();
}
}