Kùzu C++ API
Loading...
Searching...
No Matches
kuzu::main::Connection Class Reference

Connection is used to interact with a Database instance. Each Connection is thread-safe. Multiple connections can connect to the same Database instance in a multi-threaded environment. More...

#include <connection.h>

Public Member Functions

KUZU_API Connection (Database *database)
 Creates a connection to the database.
 
KUZU_API ~Connection ()
 Destructs the connection.
 
KUZU_API void setMaxNumThreadForExec (uint64_t numThreads)
 Sets the maximum number of threads to use for execution in the current connection.
 
KUZU_API uint64_t getMaxNumThreadForExec ()
 Returns the maximum number of threads to use for execution in the current connection.
 
KUZU_API std::unique_ptr< QueryResultquery (std::string_view query)
 Executes the given query and returns the result.
 
KUZU_API std::unique_ptr< PreparedStatementprepare (std::string_view query)
 Prepares the given query and returns the prepared statement.
 
template<typename... Args>
std::unique_ptr< QueryResultexecute (PreparedStatement *preparedStatement, std::pair< std::string, Args >... args)
 Executes the given prepared statement with args and returns the result.
 
KUZU_API std::unique_ptr< QueryResultexecuteWithParams (PreparedStatement *preparedStatement, std::unordered_map< std::string, std::unique_ptr< common::Value > > inputParams)
 Executes the given prepared statement with inputParams and returns the result.
 
KUZU_API void interrupt ()
 interrupts all queries currently executing within this connection.
 
KUZU_API void setQueryTimeOut (uint64_t timeoutInMS)
 sets the query timeout value of the current connection. A value of zero (the default) disables the timeout.
 
template<typename TR , typename... Args>
void createScalarFunction (std::string name, TR(*udfFunc)(Args...))
 
template<typename TR , typename... Args>
void createScalarFunction (std::string name, std::vector< common::LogicalTypeID > parameterTypes, common::LogicalTypeID returnType, TR(*udfFunc)(Args...))
 
void addUDFFunctionSet (std::string name, function::function_set func)
 
void removeUDFFunction (std::string name)
 
template<typename TR , typename... Args>
void createVectorizedFunction (std::string name, function::scalar_func_exec_t scalarFunc)
 
void createVectorizedFunction (std::string name, std::vector< common::LogicalTypeID > parameterTypes, common::LogicalTypeID returnType, function::scalar_func_exec_t scalarFunc)
 
ClientContextgetClientContext ()
 

Friends

class kuzu::testing::BaseGraphTest
 
class kuzu::testing::PrivateGraphTest
 
class kuzu::testing::TestHelper
 
class kuzu::testing::TestRunner
 
class kuzu::benchmark::Benchmark
 
class kuzu::testing::TinySnbDDLTest
 
class ConnectionExecuteAsyncWorker
 
class ConnectionQueryAsyncWorker
 

Detailed Description

Connection is used to interact with a Database instance. Each Connection is thread-safe. Multiple connections can connect to the same Database instance in a multi-threaded environment.

Constructor & Destructor Documentation

◆ Connection()

KUZU_API kuzu::main::Connection::Connection ( Database * database)
explicit

Creates a connection to the database.

Parameters
databaseA pointer to the database instance that this connection will be connected to.

◆ ~Connection()

KUZU_API kuzu::main::Connection::~Connection ( )

Destructs the connection.

Member Function Documentation

◆ addUDFFunctionSet()

void kuzu::main::Connection::addUDFFunctionSet ( std::string name,
function::function_set func )
inline

◆ createScalarFunction() [1/2]

template<typename TR , typename... Args>
void kuzu::main::Connection::createScalarFunction ( std::string name,
std::vector< common::LogicalTypeID > parameterTypes,
common::LogicalTypeID returnType,
TR(* udfFunc )(Args...) )
inline

◆ createScalarFunction() [2/2]

template<typename TR , typename... Args>
void kuzu::main::Connection::createScalarFunction ( std::string name,
TR(* udfFunc )(Args...) )
inline

◆ createVectorizedFunction() [1/2]

template<typename TR , typename... Args>
void kuzu::main::Connection::createVectorizedFunction ( std::string name,
function::scalar_func_exec_t scalarFunc )
inline

◆ createVectorizedFunction() [2/2]

void kuzu::main::Connection::createVectorizedFunction ( std::string name,
std::vector< common::LogicalTypeID > parameterTypes,
common::LogicalTypeID returnType,
function::scalar_func_exec_t scalarFunc )
inline

◆ execute()

template<typename... Args>
std::unique_ptr< QueryResult > kuzu::main::Connection::execute ( PreparedStatement * preparedStatement,
std::pair< std::string, Args >... args )
inline

Executes the given prepared statement with args and returns the result.

Parameters
preparedStatementThe prepared statement to execute.
argsThe parameter pack where each arg is a std::pair with the first element being parameter name and second element being parameter value.
Returns
the result of the query.

◆ executeWithParams()

KUZU_API std::unique_ptr< QueryResult > kuzu::main::Connection::executeWithParams ( PreparedStatement * preparedStatement,
std::unordered_map< std::string, std::unique_ptr< common::Value > > inputParams )

Executes the given prepared statement with inputParams and returns the result.

Parameters
preparedStatementThe prepared statement to execute.
inputParamsThe parameter pack where each arg is a std::pair with the first element being parameter name and second element being parameter value.
Returns
the result of the query.

◆ getClientContext()

ClientContext * kuzu::main::Connection::getClientContext ( )
inline

◆ getMaxNumThreadForExec()

KUZU_API uint64_t kuzu::main::Connection::getMaxNumThreadForExec ( )

Returns the maximum number of threads to use for execution in the current connection.

Returns
the maximum number of threads to use for execution in the current connection.

◆ interrupt()

KUZU_API void kuzu::main::Connection::interrupt ( )

interrupts all queries currently executing within this connection.

◆ prepare()

KUZU_API std::unique_ptr< PreparedStatement > kuzu::main::Connection::prepare ( std::string_view query)

Prepares the given query and returns the prepared statement.

Parameters
queryThe query to prepare.
Returns
the prepared statement.

◆ query()

KUZU_API std::unique_ptr< QueryResult > kuzu::main::Connection::query ( std::string_view query)

Executes the given query and returns the result.

Parameters
queryThe query to execute.
Returns
the result of the query.

◆ removeUDFFunction()

void kuzu::main::Connection::removeUDFFunction ( std::string name)
inline

◆ setMaxNumThreadForExec()

KUZU_API void kuzu::main::Connection::setMaxNumThreadForExec ( uint64_t numThreads)

Sets the maximum number of threads to use for execution in the current connection.

Parameters
numThreadsThe number of threads to use for execution in the current connection.

◆ setQueryTimeOut()

KUZU_API void kuzu::main::Connection::setQueryTimeOut ( uint64_t timeoutInMS)

sets the query timeout value of the current connection. A value of zero (the default) disables the timeout.

Friends And Related Symbol Documentation

◆ ConnectionExecuteAsyncWorker

friend class ConnectionExecuteAsyncWorker
friend

◆ ConnectionQueryAsyncWorker

friend class ConnectionQueryAsyncWorker
friend

◆ kuzu::benchmark::Benchmark

friend class kuzu::benchmark::Benchmark
friend

◆ kuzu::testing::BaseGraphTest

friend class kuzu::testing::BaseGraphTest
friend

◆ kuzu::testing::PrivateGraphTest

friend class kuzu::testing::PrivateGraphTest
friend

◆ kuzu::testing::TestHelper

friend class kuzu::testing::TestHelper
friend

◆ kuzu::testing::TestRunner

friend class kuzu::testing::TestRunner
friend

◆ kuzu::testing::TinySnbDDLTest

friend class kuzu::testing::TinySnbDDLTest
friend

The documentation for this class was generated from the following file: