Skip to content

Commit

Permalink
Merge "tp: Fix naming in PerfettoSqlEngine" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
aMayzner authored and Gerrit Code Review committed Oct 27, 2023
2 parents 5e6c2f5 + 9b7471b commit 6d1ca4a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ PerfettoSqlEngine::ExecuteUntilLastStatement(SqlSource sql_source) {
return ExecutionResult{std::move(*res), stats};
}

base::Status PerfettoSqlEngine::RegisterSqlFunction(
base::Status PerfettoSqlEngine::RegisterRuntimeFunction(
bool replace,
const FunctionPrototype& prototype,
std::string return_type_str,
Expand All @@ -348,7 +348,7 @@ base::Status PerfettoSqlEngine::RegisterSqlFunction(
std::unique_ptr<CreatedFunction::Context> created_fn_ctx =
CreatedFunction::MakeContext(this);
ctx = created_fn_ctx.get();
RETURN_IF_ERROR(RegisterCppFunction<CreatedFunction>(
RETURN_IF_ERROR(RegisterStaticFunction<CreatedFunction>(
prototype.function_name.c_str(), created_argc,
std::move(created_fn_ctx)));
}
Expand Down Expand Up @@ -487,7 +487,7 @@ base::StatusOr<SqlSource> PerfettoSqlEngine::ExecuteCreateFunction(
const PerfettoSqlParser& parser) {
if (!cf.is_table) {
RETURN_IF_ERROR(
RegisterSqlFunction(cf.replace, cf.prototype, cf.returns, cf.sql));
RegisterRuntimeFunction(cf.replace, cf.prototype, cf.returns, cf.sql));
return RewriteToDummySql(parser.statement_sql());
}

Expand Down
22 changes: 11 additions & 11 deletions src/trace_processor/perfetto_sql/engine/perfetto_sql_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ class PerfettoSqlEngine {
// |determistic|: whether this function has deterministic output given the
// same set of arguments.
template <typename Function = SqlFunction>
base::Status RegisterCppFunction(const char* name,
int argc,
typename Function::Context* ctx,
bool deterministic = true);
base::Status RegisterStaticFunction(const char* name,
int argc,
typename Function::Context* ctx,
bool deterministic = true);

// Registers a trace processor C++ function to be runnable from SQL.
//
Expand All @@ -98,18 +98,18 @@ class PerfettoSqlEngine {
// this pointer instead of the essentially static requirement of the context
// pointer above.
template <typename Function>
base::Status RegisterCppFunction(
base::Status RegisterStaticFunction(
const char* name,
int argc,
std::unique_ptr<typename Function::Context> ctx,
bool deterministic = true);

// Registers a function with the prototype |prototype| which returns a value
// of |return_type| and is implemented by executing the SQL statement |sql|.
base::Status RegisterSqlFunction(bool replace,
const FunctionPrototype& prototype,
std::string return_type,
SqlSource sql);
base::Status RegisterRuntimeFunction(bool replace,
const FunctionPrototype& prototype,
std::string return_type,
SqlSource sql);

// Enables memoization for the given SQL function.
base::Status EnableSqlFunctionMemoization(const std::string& name);
Expand Down Expand Up @@ -227,7 +227,7 @@ void WrapSqlFunction(sqlite3_context* ctx, int argc, sqlite3_value** argv) {
} // namespace perfetto_sql_internal

template <typename Function>
base::Status PerfettoSqlEngine::RegisterCppFunction(
base::Status PerfettoSqlEngine::RegisterStaticFunction(
const char* name,
int argc,
typename Function::Context* ctx,
Expand All @@ -238,7 +238,7 @@ base::Status PerfettoSqlEngine::RegisterCppFunction(
}

template <typename Function>
base::Status PerfettoSqlEngine::RegisterCppFunction(
base::Status PerfettoSqlEngine::RegisterStaticFunction(
const char* name,
int argc,
std::unique_ptr<typename Function::Context> user_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ base::Status CreateFunction::Run(PerfettoSqlEngine* engine,
FunctionPrototype prototype;
RETURN_IF_ERROR(ParsePrototype(base::StringView(prototype_str), prototype));

return engine->RegisterSqlFunction(
return engine->RegisterRuntimeFunction(
false, prototype, return_type_str,
SqlSource::FromTraceProcessorImplementation(std::move(sql_defn_str)));
}
Expand Down
6 changes: 3 additions & 3 deletions src/trace_processor/perfetto_sql/intrinsics/functions/math.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ struct Sqrt : public SqlFunction {
} // namespace

base::Status RegisterMathFunctions(PerfettoSqlEngine& engine) {
RETURN_IF_ERROR(engine.RegisterCppFunction<Ln>("ln", 1, nullptr, true));
RETURN_IF_ERROR(engine.RegisterCppFunction<Exp>("exp", 1, nullptr, true));
return engine.RegisterCppFunction<Sqrt>("sqrt", 1, nullptr, true);
RETURN_IF_ERROR(engine.RegisterStaticFunction<Ln>("ln", 1, nullptr, true));
RETURN_IF_ERROR(engine.RegisterStaticFunction<Exp>("exp", 1, nullptr, true));
return engine.RegisterStaticFunction<Sqrt>("sqrt", 1, nullptr, true);
}

} // namespace perfetto::trace_processor
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ struct StackFromStackProfileFrameFunction : public SqlFunction {

base::Status RegisterStackFunctions(PerfettoSqlEngine* engine,
TraceProcessorContext* context) {
RETURN_IF_ERROR(engine->RegisterCppFunction<CatStacksFunction>(
RETURN_IF_ERROR(engine->RegisterStaticFunction<CatStacksFunction>(
CatStacksFunction::kFunctionName, -1, context->storage.get()));
RETURN_IF_ERROR(
engine->RegisterCppFunction<StackFromStackProfileFrameFunction>(
engine->RegisterStaticFunction<StackFromStackProfileFrameFunction>(
StackFromStackProfileFrameFunction::kFunctionName, 1,
context->storage.get()));
return engine->RegisterCppFunction<StackFromStackProfileCallsiteFunction>(
return engine->RegisterStaticFunction<StackFromStackProfileCallsiteFunction>(
StackFromStackProfileCallsiteFunction::kFunctionName, -1,
context->storage.get());
}
Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/trace_processor_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void RegisterFunction(PerfettoSqlEngine* engine,
int argc,
Ptr context = nullptr,
bool deterministic = true) {
auto status = engine->RegisterCppFunction<SqlFunction>(
auto status = engine->RegisterStaticFunction<SqlFunction>(
name, argc, std::move(context), deterministic);
if (!status.ok())
PERFETTO_ELOG("%s", status.c_message());
Expand Down

0 comments on commit 6d1ca4a

Please sign in to comment.