|
@@ -823,6 +823,11 @@ int RocksdbProcess::saveRow(
|
|
|
if (ret != 0)
|
|
|
{
|
|
|
log_error("parse field value failed! compoundValue:%s", compoundValue.c_str());
|
|
|
+ for(int i = 0; i < mTableDef->num_fields()+1; i++){
|
|
|
+ if((*row)[i].str.ptr != NULL){
|
|
|
+ free((*row)[i].str.ptr);
|
|
|
+ }
|
|
|
+ }
|
|
|
delete row;
|
|
|
return -1;
|
|
|
}
|
|
@@ -833,6 +838,11 @@ int RocksdbProcess::saveRow(
|
|
|
ret = condition_filter(fieldValue, fieldId, mTableDef->field_type(fieldId), Condition);
|
|
|
if (ret < 0)
|
|
|
{
|
|
|
+ for(int i = 0; i < mTableDef->num_fields()+1; i++){
|
|
|
+ if((*row)[i].str.ptr != NULL){
|
|
|
+ free((*row)[i].str.ptr);
|
|
|
+ }
|
|
|
+ }
|
|
|
delete row;
|
|
|
log_error("string[%s] conver to value[%d] error: %d", fieldValue.c_str(), mTableDef->field_type(fieldId), ret);
|
|
|
return (-2);
|
|
@@ -840,6 +850,11 @@ int RocksdbProcess::saveRow(
|
|
|
else if (ret == 1)
|
|
|
{
|
|
|
// condition is not matched
|
|
|
+ for(int i = 0; i < mTableDef->num_fields()+1; i++){
|
|
|
+ if((*row)[i].str.ptr != NULL){
|
|
|
+ free((*row)[i].str.ptr);
|
|
|
+ }
|
|
|
+ }
|
|
|
delete row;
|
|
|
return 0;
|
|
|
}
|
|
@@ -848,6 +863,11 @@ int RocksdbProcess::saveRow(
|
|
|
ret = str2Value(fieldValue, mTableDef->field_type(fieldId), (*row)[fieldId]);
|
|
|
if (ret < 0)
|
|
|
{
|
|
|
+ for(int i = 0; i < mTableDef->num_fields()+1; i++){
|
|
|
+ if((*row)[i].str.ptr != NULL){
|
|
|
+ free((*row)[i].str.ptr);
|
|
|
+ }
|
|
|
+ }
|
|
|
delete row;
|
|
|
log_error("string[%s] conver to value[%d] error: %d", fieldValue.c_str(), mTableDef->field_type(fieldId), ret);
|
|
|
return (-2);
|
|
@@ -857,6 +877,11 @@ int RocksdbProcess::saveRow(
|
|
|
// Task->update_key(row);
|
|
|
ret = Task->append_row(row);
|
|
|
|
|
|
+ for(int i = 0; i < mTableDef->num_fields()+1; i++){
|
|
|
+ if((*row)[i].str.ptr != NULL){
|
|
|
+ free((*row)[i].str.ptr);
|
|
|
+ }
|
|
|
+ }
|
|
|
delete row;
|
|
|
|
|
|
if (ret < 0)
|
|
@@ -1755,6 +1780,54 @@ int RocksdbProcess::process_delete(DTCTask *Task)
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
+ std::set<int> req_ids;
|
|
|
+ std::vector<std::string> quick_keys(mCompoundKeyFieldNums);
|
|
|
+ quick_keys[0] = prefixKey;
|
|
|
+ DTCFieldValue *req_condition = (DTCFieldValue*)Task->request_condition();
|
|
|
+ if(req_condition != NULL){
|
|
|
+ for ( int i = 0; i < req_condition->num_fields(); i++ ){
|
|
|
+ int req_field_id = req_condition->field_id(i);
|
|
|
+ if ( mTableDef->is_volatile(req_field_id) )
|
|
|
+ continue;
|
|
|
+ int rocks_fid = translate_field_idx(req_field_id);
|
|
|
+ assert(rocks_fid >= 0 && rocks_fid < mCompoundKeyFieldNums + mExtraValueFieldNums);
|
|
|
+ if ( req_field_id == 0 || rocks_fid == 0 || rocks_fid >= mCompoundKeyFieldNums)
|
|
|
+ continue;
|
|
|
+ req_ids.insert(rocks_fid);
|
|
|
+ std::string& va = quick_keys[rocks_fid];
|
|
|
+ ret = value2Str(req_condition->field_value(i), req_field_id, va);
|
|
|
+ assert( ret == 0 );
|
|
|
+ }
|
|
|
+ bool hit_all_key = true;
|
|
|
+ for ( int idx = 1; idx < mCompoundKeyFieldNums; idx++ ){
|
|
|
+ if(req_ids.find(idx) == req_ids.end()){
|
|
|
+ hit_all_key = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(true == hit_all_key){
|
|
|
+ std::stringstream ss;
|
|
|
+ for(auto it :req_ids) { ss << it << ","; }
|
|
|
+ std::stringstream sskey;
|
|
|
+ for(auto key_it :quick_keys) { sskey << key_it << ","; }
|
|
|
+ log_debug("hit all unique keys, goto quick delete, req_ids: %s, keys: %s, mCompoundKeyFieldNums: %d",
|
|
|
+ ss.str().c_str(), sskey.str().c_str(), mCompoundKeyFieldNums);
|
|
|
+ std::string quick_rocks_Key;
|
|
|
+ std::string keyBitmaps;
|
|
|
+ encode_bitmap_keys(quick_keys, keyBitmaps);
|
|
|
+ quick_rocks_Key = std::move(key_format::Encode(quick_keys, mKeyfield_types));
|
|
|
+
|
|
|
+ ret = mDBConn->delete_entry(quick_rocks_Key);
|
|
|
+ if ( ret != 0 ) {
|
|
|
+ log_error("deleteEntry failed! ");
|
|
|
+ Task->set_error(-EC_ERROR_BASE, __FUNCTION__, "deleteEntry failed!");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ log_debug("quick delete success");
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ req_ids.clear();
|
|
|
+ }
|
|
|
+
|
|
|
if (mKeyfield_types[0] == DField::String)
|
|
|
std::transform(prefixKey.begin(), prefixKey.end(), prefixKey.begin(), ::tolower);
|
|
|
|
|
@@ -3102,10 +3175,10 @@ int RocksdbProcess::split_values(
|
|
|
char *head = const_cast<char *>(compoundValue.data());
|
|
|
for (int idx = 0; idx < mExtraValueFieldNums; idx++)
|
|
|
{
|
|
|
- if(idx == mExtraValueFieldNums-1){ // extend field no need to parse
|
|
|
- values.push_back("");
|
|
|
- break;
|
|
|
- }
|
|
|
+ //if(idx == mExtraValueFieldNums-1){ // extend field no need to parse
|
|
|
+ // values.push_back("");
|
|
|
+ // break;
|
|
|
+ //}
|
|
|
ret = get_value_by_id(head, mFieldIndexMapping[mCompoundKeyFieldNums + idx], value);
|
|
|
assert(ret == 0);
|
|
|
values.push_back(std::move(value));
|