// not deep copy cell content to decoded_cell int ObParamDecoder::decode_cond_cell(const ObCondInfo & org_cond, const ObSchemaManagerV2 & schema, ObCellInfo & decoded_cell) { int ret = OB_SUCCESS; const ObCellInfo & org_cell = org_cond.get_cell(); if (org_cell.table_name_.length() <= 0) // || (org_cell.row_key_.length() <= 0)) { ret = OB_INPUT_PARAM_ERROR; TBSYS_LOG(WARN, "check cell table name or column name failed:table[%.*s], column[%.*s]", org_cell.table_name_.length(), org_cell.table_name_.ptr(), org_cell.column_name_.length(), org_cell.column_name_.ptr()); } else if (false == org_cond.is_exist_type()) { ret = decode_cell(false, org_cell, schema, decoded_cell); if (ret != OB_SUCCESS) { TBSYS_LOG(WARN, "decode cond cell failed:ret[%d]", ret); } } else { ret = decode_cell(true, org_cell, schema, decoded_cell); if (ret != OB_SUCCESS) { TBSYS_LOG(WARN, "decode exist cond cell failed:ret[%d]", ret); } } // TODO check op type suitable return ret; }
TEST_F(TestParamDecoder, test_decode_cond_cell) { ObSchemaManagerV2 schema(100); tbsys::CConfig config; EXPECT_TRUE(schema.parse_from_file("schema.ini", config)); ObCondInfo cond; ObCellInfo out_cell; char * no_name = (char*)"test_not_exist"; char * tablename = (char*)"collect_info"; char * columnname = (char*)"item_price"; char * rowkey = (char*)"rowkey_test"; ObString table_name; ObString column_name; ObRowkey row_key; // NORMAL TYPE // table name not exist and column not exist table_name.assign(no_name, static_cast<int32_t>(strlen(no_name))); column_name.assign(no_name, static_cast<int32_t>(strlen(no_name))); row_key = make_rowkey(rowkey, &allocator_); ObObj obj; obj.set_int(1234); cond.set(NE, table_name, row_key, column_name, obj); EXPECT_TRUE(OB_SUCCESS != ObParamDecoder::decode_cond_cell(cond, schema, out_cell)); // table name not exist but column exist table_name.assign(no_name, static_cast<int32_t>(strlen(no_name))); column_name.assign(columnname, static_cast<int32_t>(strlen(columnname))); cond.set(NE, table_name, row_key, column_name, obj); EXPECT_TRUE(OB_SUCCESS != ObParamDecoder::decode_cond_cell(cond, schema, out_cell)); // table name exist but column not exist table_name.assign(tablename, static_cast<int32_t>(strlen(tablename))); column_name.assign(no_name, static_cast<int32_t>(strlen(no_name))); cond.set(NE, table_name, row_key, column_name, obj); EXPECT_TRUE(OB_SUCCESS != ObParamDecoder::decode_cond_cell(cond, schema, out_cell)); // table name exist and column exist table_name.assign(tablename, static_cast<int32_t>(strlen(tablename))); column_name.assign(columnname, static_cast<int32_t>(strlen(columnname))); cond.set(NE, table_name, row_key, column_name, obj); EXPECT_TRUE(OB_SUCCESS == ObParamDecoder::decode_cond_cell(cond, schema, out_cell)); // EXIST TYPE // table name not exist table_name.assign(no_name, static_cast<int32_t>(strlen(no_name))); row_key = make_rowkey(rowkey, &allocator_); cond.set(table_name, row_key, false); EXPECT_TRUE(OB_SUCCESS != ObParamDecoder::decode_cond_cell(cond, schema, out_cell)); cond.set(table_name, row_key, true); EXPECT_TRUE(OB_SUCCESS != ObParamDecoder::decode_cond_cell(cond, schema, out_cell)); // table name exist table_name.assign(tablename, static_cast<int32_t>(strlen(tablename))); cond.set(table_name, row_key, true); EXPECT_TRUE(OB_SUCCESS == ObParamDecoder::decode_cond_cell(cond, schema, out_cell)); cond.set(table_name, row_key, false); EXPECT_TRUE(OB_SUCCESS == ObParamDecoder::decode_cond_cell(cond, schema, out_cell)); }
int ObMutatorParamDecoder::add_condition(const ObCondInfo & decoded_cell, ObUpdateCondition & decoded_cond, ObGetParam & get_param) { int ret = decoded_cond.add_cond(decoded_cell); if (OB_SUCCESS == ret) { // add id type cell to get_param ret = add_cell(decoded_cell.get_cell(), get_param); if (ret != OB_SUCCESS) { TBSYS_LOG(WARN, "check add condition cell failed:ret[%d]", ret); } } else { TBSYS_LOG(WARN, "add decoede condition cell to new mutator failed:ret[%d]", ret); } return ret; }