Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Qup42 committed Mar 3, 2025
1 parent 545de6b commit deddf9d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/engine/ExportQueryExecutionTrees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,8 @@ ExportQueryExecutionTrees::computeResultAsQLeverJSON(

nlohmann::json jsonPrefix;

jsonPrefix["query"] = ad_utility::truncateOperation(query._originalString);
jsonPrefix["query"] =
ad_utility::truncateOperationString(query._originalString);
jsonPrefix["status"] = "OK";
jsonPrefix["warnings"] = qet.collectWarnings();
if (query.hasSelectClause()) {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/GraphStoreProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class GraphStoreProtocol {
res._clause = parsedQuery::UpdateClause{std::move(up)};
// Graph store protocol POST requests might have a very large body. Limit
// the length used for the string representation.
string_view body = ad_utility::truncateOperation(rawRequest.body());
string_view body = ad_utility::truncateOperationString(rawRequest.body());
res._originalString = absl::StrCat("Graph Store POST Operation\n", body);
return res;
}
Expand Down
9 changes: 5 additions & 4 deletions src/engine/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ auto Server::prepareOperation(
LOG(INFO) << "Processing the following " << operationName << ":"
<< (pinResult ? " [pin result]" : "")
<< (pinSubtrees ? " [pin subresults]" : "") << "\n"
<< ad_utility::truncateOperation(operationSPARQL) << std::endl;
<< ad_utility::truncateOperationString(operationSPARQL)
<< std::endl;

Check warning on line 263 in src/engine/Server.cpp

View check run for this annotation

Codecov / codecov/patch

src/engine/Server.cpp#L262-L263

Added lines #L262 - L263 were not covered by tests
QueryExecutionContext qec(index_, &cache_, allocator_,
sortPerformanceEstimator_, std::ref(messageSender),
pinSubtrees, pinResult);
Expand Down Expand Up @@ -581,13 +582,13 @@ json Server::composeErrorResponseJson(
const std::optional<ExceptionMetadata>& metadata) {
json j;
using ad_utility::Timer;
j["query"] = ad_utility::truncateOperationString(query);

Check warning on line 585 in src/engine/Server.cpp

View check run for this annotation

Codecov / codecov/patch

src/engine/Server.cpp#L585

Added line #L585 was not covered by tests
j["status"] = "ERROR";
j["resultsize"] = 0;
j["time"]["total"] = requestTimer.msecs().count();
j["time"]["computeResult"] = requestTimer.msecs().count();
j["exception"] = errorMsg;

j["query"] = ad_utility::truncateOperation(query);
// If the error location is truncated don't send it's location.
if (metadata.has_value() &&
metadata.value().stopIndex_ < MAX_LENGTH_OPERATION_ECHO) {
Expand Down Expand Up @@ -825,8 +826,8 @@ json Server::createResponseMetadataForUpdate(
};

json response;
response["update"] =
ad_utility::truncateOperation(plannedQuery.parsedQuery_._originalString);
response["update"] = ad_utility::truncateOperationString(
plannedQuery.parsedQuery_._originalString);
response["status"] = "OK";
auto warnings = qet.collectWarnings();
warnings.emplace(warnings.begin(),
Expand Down
2 changes: 1 addition & 1 deletion src/util/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ std::string addIndentation(std::string_view str,
}

// ___________________________________________________________________________
std::string truncateOperation(std::string_view operation) {
std::string truncateOperationString(std::string_view operation) {
static_assert(MAX_LENGTH_OPERATION_ECHO >= 3);
if (operation.length() <= MAX_LENGTH_OPERATION_ECHO) {
return std::string{operation};
Expand Down
3 changes: 1 addition & 2 deletions src/util/StringUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,9 @@ constexpr std::string_view constexprStrCat() {
return {b.data(), b.size() - 1};
}

// TODO: make this a general truncate operation
// Truncates the operation string to a maximum length of
// `MAX_LENGTH_OPERATION_ECHO`.
std::string truncateOperation(std::string_view operation);
std::string truncateOperationString(std::string_view operation);
} // namespace ad_utility

// A helper function for the `operator+` overloads below.
Expand Down

0 comments on commit deddf9d

Please sign in to comment.