Skip to content

Commit

Permalink
Fixing matchLineWithRegex() function
Browse files Browse the repository at this point in the history
  • Loading branch information
minhancao committed Aug 9, 2024
1 parent 138d6bc commit 664dd0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions presto-native-execution/presto_cpp/main/LinuxMemoryChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int64_t LinuxMemoryChecker::systemUsedMemoryBytes() {
size_t memTotal = 0;
size_t inactiveAnon = 0;
size_t activeAnon = 0;
boost::smatch match;
boost::cmatch match;
std::array<char, 50> buf;
static const boost::regex inactiveAnonRegex(R"!(inactive_anon\s*(\d+)\s*)!");
static const boost::regex activeAnonRegex(R"!(active_anon\s*(\d+)\s*)!");
Expand Down Expand Up @@ -114,13 +114,13 @@ int64_t LinuxMemoryChecker::systemUsedMemoryBytes() {
}

size_t LinuxMemoryChecker::matchLineWithRegex(
folly::StringPiece& line,
boost::smatch& match,
const folly::StringPiece& line,
boost::cmatch& match,
const boost::regex& regex) {
if (boost::regex_match(line.begin(), line.end(), match, regex)) {
folly::StringPiece numStr(
line.begin() + match.position(1), size_t(match.length(1)));
return folly::to<size_t>(numStr);
std::string str(line.data(), line.size());
if (boost::regex_match(str.c_str(), match, regex)) {
std::string numStr(match[1].str());
return std::stoul(numStr);
}
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions presto-native-execution/presto_cpp/main/LinuxMemoryChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class LinuxMemoryChecker : public PeriodicMemoryChecker {
int64_t systemUsedMemoryBytes() override;

size_t matchLineWithRegex(
folly::StringPiece& line,
boost::smatch& match,
const folly::StringPiece& line,
boost::cmatch& match,
const boost::regex& regex);

int64_t mallocBytes() const override {
Expand Down

0 comments on commit 664dd0d

Please sign in to comment.