MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getHostFunction

Function getHostFunction

src/Interpreters/WebAssembly/HostApi.cpp:191–211  ·  view source on GitHub ↗

API exported to guest WebAssembly code.

Source from the content-addressed store, hash-verified

189
190/// API exported to guest WebAssembly code.
191WasmHostFunction getHostFunction(std::string_view function_name)
192{
193 static const std::array exported_functions{
194 makeHostFunction("clickhouse_server_version", wasmExportServerVer),
195 makeHostFunction("clickhouse_throw", wasmExportThrow),
196 makeHostFunction("clickhouse_log", wasmExportLog),
197 makeHostFunction("clickhouse_random", wasmExportRandom),
198 /// Mandatory import for any AssemblyScript module that uses runtime checks
199 /// (memory allocation, bounds checks, etc). Linked only when the module
200 /// declares `(import "env" "abort" (func ...))`, so non-AS modules are unaffected.
201 makeHostFunction("abort", wasmExportAssemblyScriptAbort),
202 };
203
204 for (const auto & function : exported_functions)
205 {
206 if (function.getFunctionDeclaration().getName() == function_name)
207 return function;
208 }
209
210 throw Exception(ErrorCodes::RESOURCE_NOT_FOUND, "Unknown WebAssembly host function '{}'", function_name);
211}
212
213}

Callers 1

linkHostFunctionsFunction · 0.85

Calls 4

makeHostFunctionFunction · 0.85
ExceptionClass · 0.50
getNameMethod · 0.45

Tested by

no test coverage detected