c++ 通过thrift2写入HBase效率很慢,有类似java的BufferedMutator的操作吗?就是java的高效的缓冲接口BufferedMutator每次mutate是到内存里,只有达到write.buffer的值后才写入,或自己flush()。
c++是调用thrift2的接口,怎样做到高效的插入,或关闭表的自动flush??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()));
}
}