20,808
社区成员
发帖
与我相关
我的任务
分享
void HBaseDriver::putMultiple(string& tableName, string& rowKey, unordered_map<string ,string>& qualifierVal, string& family){
currentPutCount +=1;
//std::vector<TPut> puts;
TPut put;
std::vector<TColumnValue> cvs;
put.__set_row(rowKey);
if(BOOL_TEST){
start = clock();
BOOL_TEST = false;
}
unordered_map<string , string>::iterator it;
try{
it = qualifierVal.begin();
while(it != qualifierVal.end()) {
TColumnValue cv;
cv.__set_family(family);
cv.__set_qualifier(it->first);
cv.__set_value(it->second);
/*if(it->first == "feature"){ //if the key is 'feature'
assert(it->second.length() == BASE64_FEATURE_LEN);
}*/
cvs.insert(cvs.end(), cv);
put.__set_durability(TDurability::SKIP_WAL);//skit write ahead log for speed up
put.__set_columnValues(cvs);
puts.insert(puts.end(), put);
it++;
}
if(this->currentPutCount % this->PUT_BATCH_SIZE == 0){
put_client_->putMultiple(tableName, puts);
finish = clock();
duration = (finish - start) / CLOCKS_PER_SEC;
printf( "===================================== %f seconds cost for hbase put.\n", duration );
//long end = CURRENT_TIME();
//LOG(string("Time Cost :"+to_string(end-start)+" ms"));
puts.clear();
}
cvs.clear();
}catch(TException tex) {
LOG(string(tex.what()));
}
}