Skip to content

Commit

Permalink
[chore][log] Disable coprocessor scalar error log output.
Browse files Browse the repository at this point in the history
  • Loading branch information
Haijun Yu committed Apr 22, 2024
1 parent f617bbe commit 70d8dc0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/coprocessor/coprocessor_scalar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ bvar::Adder<uint64_t> CoprocessorScalar::bvar_coprocessor_v2_filter_scalar_total
bvar::LatencyRecorder CoprocessorScalar::coprocessor_v2_filter_scalar_latency(
"dingo_coprocessor_v2_filter_scalar_latency");

DEFINE_bool(dingo_log_switch_coprocessor_scalar_detail, false, "coprocessor_scalar detail log");

CoprocessorScalar::CoprocessorScalar() = default;
CoprocessorScalar::~CoprocessorScalar() { Close(); }

Expand Down Expand Up @@ -93,7 +95,9 @@ butil::Status CoprocessorScalar::Filter(const pb::common::VectorScalardata& scal

status = TransToAnyRecord(scalar_data, original_record);
if (!status.ok()) {
DINGO_LOG(ERROR) << status.error_cstr();
if (FLAGS_dingo_log_switch_coprocessor_scalar_detail) {
DINGO_LOG(ERROR) << status.error_cstr();
}
return status;
}

Expand Down Expand Up @@ -139,14 +143,18 @@ butil::Status CoprocessorScalar::TransToAnyRecord(const pb::common::VectorScalar
std::string error_message =
fmt::format("field name : {} type not match. schema type : {} field_type : {}", name,
BaseSchema::GetTypeString(type), pb::common::ScalarFieldType_Name(field_type));
LOG(ERROR) << "[" << __PRETTY_FUNCTION__ << "] " << error_message;
if (FLAGS_dingo_log_switch_coprocessor_scalar_detail) {
LOG(ERROR) << "[" << __PRETTY_FUNCTION__ << "] " << error_message;
}
return butil::Status(pb::error::EILLEGAL_PARAMTETERS, error_message);
}

if (scalar_value.fields().empty()) {
std::string error_message = fmt::format("name : {} field_type : {} scalar_value.fields() empty", name,
pb::common::ScalarFieldType_Name(field_type));
LOG(ERROR) << "[" << __PRETTY_FUNCTION__ << "] " << error_message;
if (FLAGS_dingo_log_switch_coprocessor_scalar_detail) {
LOG(ERROR) << "[" << __PRETTY_FUNCTION__ << "] " << error_message;
}
return butil::Status(pb::error::EILLEGAL_PARAMTETERS, error_message);
}

Expand Down Expand Up @@ -232,7 +240,9 @@ butil::Status CoprocessorScalar::TransToAnyRecord(const pb::common::VectorScalar
std::string error_message =
fmt::format("field name : {} not support . schema type : {} field_type : {}", name,
BaseSchema::GetTypeString(type), pb::common::ScalarFieldType_Name(field_type));
DINGO_LOG(ERROR) << error_message;
if (FLAGS_dingo_log_switch_coprocessor_scalar_detail) {
DINGO_LOG(ERROR) << error_message;
}
return butil::Status(pb::error::EILLEGAL_PARAMTETERS, error_message);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/vector/vector_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ DEFINE_bool(dingo_log_switch_scalar_speed_up_detail, false, "scalar speed up log
bvar::LatencyRecorder g_bruteforce_search_latency("dingo_bruteforce_search_latency");
bvar::LatencyRecorder g_bruteforce_range_search_latency("dingo_bruteforce_range_search_latency");

DECLARE_bool(dingo_log_switch_coprocessor_scalar_detail);

butil::Status VectorReader::QueryVectorWithId(const pb::common::Range& region_range, int64_t partition_id,
int64_t vector_id, bool with_vector_data,
pb::common::VectorWithId& vector_with_id) {
Expand Down Expand Up @@ -1002,7 +1004,9 @@ bool VectorReader::ScalarCompareWithCoprocessorCore(
bool is_reverse = false;
butil::Status status = scalar_coprocessor->Filter(internal_vector_scalar, is_reverse);
if (!status.ok()) {
DINGO_LOG(ERROR) << "scalar coprocessor::Filter failed " << status.error_cstr();
if (FLAGS_dingo_log_switch_coprocessor_scalar_detail) {
DINGO_LOG(ERROR) << "scalar coprocessor::Filter failed " << status.error_cstr();
}
return false;
}
return is_reverse;
Expand Down

0 comments on commit 70d8dc0

Please sign in to comment.