hybridse::vm::Engine

#include <engine.h>

An engine is responsible to compile SQL on the specific Catalog.

Summary

class hybridse::vm::Engine;

An engine is responsible to compile SQL on the specific Catalog.

An engine can be used to `compile sql and explain the compiling result. It maintains a LRU cache for compiling result.

Example

// Assuming the catalog has been created and initialized before
base::Status status;
EngineOptions options;
Engine engine(catalog, options);
BatchRunSession session;
std::db = "test_db";
std::string sql = "select col0, col1, col2, col1+col2 as col12 from t1;";
engine.Get(sql, db, session, status);
engine.Explain(sql, db, EngineMode::kBatchMode, &output, &status);
Public functions

Engine(const std::shared_ptr< Catalog > & cl)

Create an Engine with a specific Catalog object.

Engine(const std::shared_ptr< Catalog > & cl, const EngineOptions & options)

Create an Engine a specific Catalog object, configuring it with EngineOptions.

Get(const std::string & sql, const std::string & db, RunSession & session, base::Status & status)

bool Compile sql in db and stored the results in the session.

GetDependentTables(const std::string & sql, const std::string & db, EngineMode engine_mode, std::set< std::string > * tables, base::Status & status)

bool Search all tables related to the specific sql in db.

Explain(const std::string & sql, const std::string & db, EngineMode engine_mode, ExplainOutput * explain_output, base::Status * status)

bool Explain sql compiling result.

Explain(const std::string & sql, const std::string & db, EngineMode engine_mode, const std::set< size_t > & common_column_indices, ExplainOutput * explain_output, base::Status * status)

bool Same as above, but allowing compiling with configuring common column indices.

UpdateCatalog(std::shared_ptr< Catalog > cl)

void Update engine's catalog.

ClearCacheLocked(const std::string & db)

void Clear engine's compiling result cache.

void Initialize LLVM environments.

Public Functions

function Engine

Create an Engine with a specific Catalog object.

function Engine

Create an Engine a specific Catalog object, configuring it with EngineOptions.

function ~Engine

function Get

Compile sql in db and stored the results in the session.

function GetDependentTables

Search all tables related to the specific sql in db.

The tables' names are returned in tables

function Explain

Explain sql compiling result.

The results are returned as ExplainOutput in explain_output. The success or fail status message is returned as Status in status. TODO: base::Status* status -> base::Status& status

function Explain

Same as above, but allowing compiling with configuring common column indices.

The common column indices are used for common column optimization under EngineMode::kBatchRequestMode

function UpdateCatalog

Update engine's catalog.

function ClearCacheLocked

Clear engine's compiling result cache.

function InitializeGlobalLLVM

Initialize LLVM environments.

Last updated