Skip to content

Commit ff7c109

Browse files
wumeibanfaYour Name
authored andcommitted
[fix] remove parse_id (#57240)
Related PR: #55057 Problem Summary: Remove `parse_id`, as this method modifies the string. When using the same string, a second call to this method will fail. Following testing, from_hex and parse_id demonstrate identical behaviour. ```c++ parse_id(abcd-1234) = (from_hex(abcd), from_hex(1234)) = (0xabcd, 0x1234) parse_id(0123456789abcdef-0123456789abcdef) = (from_hex(0123456789abcdef), from_hex(0123456789abcdef)) = (0x0123456789abcdef, 0x0123456789abcdef) ```
1 parent eb3e21d commit ff7c109

3 files changed

Lines changed: 7 additions & 29 deletions

File tree

‎be/src/service/arrow_flight/flight_sql_service.cpp‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,14 @@ class FlightSqlServer::Impl {
4949
return arrow::Status::Invalid(fmt::format("Malformed ticket, size: {}", fields.size()));
5050
}
5151

52+
std::vector<std::string> str = absl::StrSplit(fields[0], "-");
53+
if (str.size() != 2) {
54+
return arrow::Status::Invalid("Malformed ticket, missing query id: {}", fields[0]);
55+
}
56+
5257
TUniqueId queryid;
53-
parse_id(fields[0], &queryid);
58+
from_hex(&queryid.hi, str[0]);
59+
from_hex(&queryid.lo, str[1]);
5460
TNetworkAddress result_addr;
5561
result_addr.hostname = fields[1];
5662
result_addr.port = std::stoi(fields[2]);

‎be/src/util/uid_util.cpp‎

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,6 @@ std::string print_id(const PUniqueId& id) {
5959
static_cast<uint64_t>(id.lo()));
6060
}
6161

62-
bool parse_id(const std::string& s, TUniqueId* id) {
63-
DCHECK(id != nullptr);
64-
65-
const char* hi_part = s.c_str();
66-
char* colon = const_cast<char*>(strchr(hi_part, '-'));
67-
68-
if (colon == nullptr) {
69-
return false;
70-
}
71-
72-
const char* lo_part = colon + 1;
73-
*colon = '\0';
74-
75-
char* error_hi = nullptr;
76-
char* error_lo = nullptr;
77-
id->hi = strtoul(hi_part, &error_hi, 16);
78-
id->lo = strtoul(lo_part, &error_lo, 16);
79-
80-
bool valid = *error_hi == '\0' && *error_lo == '\0';
81-
*colon = ':';
82-
return valid;
83-
}
84-
8562
bool TUniqueId::operator<(const TUniqueId& rhs) const {
8663
if (hi < rhs.hi) {
8764
return true;

‎be/src/util/uid_util.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,6 @@ std::string print_id(const UniqueId& id);
172172
std::string print_id(const TUniqueId& id);
173173
std::string print_id(const PUniqueId& id);
174174

175-
// Parse 's' into a TUniqueId object. The format of s needs to be the output format
176-
// from PrintId. (<hi_part>:<low_part>)
177-
// Returns true if parse succeeded.
178-
bool parse_id(const std::string& s, TUniqueId* id);
179-
180175
} // namespace doris
181176

182177
template <>

0 commit comments

Comments
 (0)