Skip to content

Commit

Permalink
Merge pull request #1939 from kuzudb/var-length-max-depth-option
Browse files Browse the repository at this point in the history
Add var_length_extend_max_depth option
  • Loading branch information
acquamarin committed Aug 16, 2023
2 parents 9419582 + eb1f10b commit da8107c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/binder/bind/bind_graph_pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ std::shared_ptr<RelExpression> Binder::createRecursiveQueryRel(const parser::Rel
std::pair<uint64_t, uint64_t> Binder::bindVariableLengthRelBound(
const kuzu::parser::RelPattern& relPattern) {
auto recursiveInfo = relPattern.getRecursiveInfo();
auto lowerBound = std::min(
TypeUtils::convertToUint32(recursiveInfo->lowerBound.c_str()), VAR_LENGTH_EXTEND_MAX_DEPTH);
auto upperBound = std::min(
TypeUtils::convertToUint32(recursiveInfo->upperBound.c_str()), VAR_LENGTH_EXTEND_MAX_DEPTH);
auto lowerBound = std::min(TypeUtils::convertToUint32(recursiveInfo->lowerBound.c_str()),
clientContext->varLengthExtendMaxDepth);
auto upperBound = std::min(TypeUtils::convertToUint32(recursiveInfo->upperBound.c_str()),
clientContext->varLengthExtendMaxDepth);
if (lowerBound == 0 || upperBound == 0) {
throw BinderException("Lower and upper bound of a rel must be greater than 0.");
}
Expand Down
8 changes: 8 additions & 0 deletions src/include/main/client_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include "main/kuzu_fwd.h"

namespace kuzu {

namespace binder {
class Binder;
}

namespace main {

struct ActiveQuery {
Expand All @@ -25,10 +30,12 @@ struct ActiveQuery {
*/
class ClientContext {
friend class Connection;
friend class binder::Binder;
friend class testing::TinySnbDDLTest;
friend class testing::TinySnbCopyCSVTransactionTest;
friend class ThreadsSetting;
friend class TimeoutSetting;
friend class VarLengthExtendMaxDepthSetting;

public:
explicit ClientContext();
Expand All @@ -55,6 +62,7 @@ class ClientContext {
uint64_t numThreadsForExecution;
ActiveQuery activeQuery;
uint64_t timeoutInMS;
uint32_t varLengthExtendMaxDepth;
};

} // namespace main
Expand Down
12 changes: 12 additions & 0 deletions src/include/main/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,17 @@ struct TimeoutSetting {
}
};

struct VarLengthExtendMaxDepthSetting {
static constexpr const char* name = "var_length_extend_max_depth";
static constexpr const common::LogicalTypeID inputType = common::LogicalTypeID::INT64;
static void setContext(ClientContext* context, const common::Value& parameter) {
assert(parameter.getDataType()->getLogicalTypeID() == common::LogicalTypeID::INT64);
context->varLengthExtendMaxDepth = parameter.getValue<int64_t>();
}
static std::string getSetting(ClientContext* context) {
return std::to_string(context->varLengthExtendMaxDepth);
}
};

} // namespace main
} // namespace kuzu
3 changes: 2 additions & 1 deletion src/main/client_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ void ActiveQuery::reset() {

ClientContext::ClientContext()
: numThreadsForExecution{std::thread::hardware_concurrency()},
timeoutInMS{ClientContextConstants::TIMEOUT_IN_MS} {}
timeoutInMS{ClientContextConstants::TIMEOUT_IN_MS}, varLengthExtendMaxDepth{
VAR_LENGTH_EXTEND_MAX_DEPTH} {}

void ClientContext::startTimingIfEnabled() {
if (isTimeOutEnabled()) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/db_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace main {
#define GET_CONFIGURATION(_PARAM) \
{ _PARAM::name, _PARAM::inputType, _PARAM::setContext, _PARAM::getSetting }

static ConfigurationOption options[] = {
GET_CONFIGURATION(ThreadsSetting), GET_CONFIGURATION(TimeoutSetting)};
static ConfigurationOption options[] = {GET_CONFIGURATION(ThreadsSetting),
GET_CONFIGURATION(TimeoutSetting), GET_CONFIGURATION(VarLengthExtendMaxDepthSetting)};

ConfigurationOption* DBConfig::getOptionByName(const std::string& optionName) {
auto lOptionName = optionName;
Expand Down
10 changes: 10 additions & 0 deletions test/test_files/tinysnb/call/call.test
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@
-STATEMENT CALL current_setting('timeout') RETURN *
---- 1
20000

-LOG SetGetVarLengthMaxDepth
-STATEMENT CALL var_length_extend_max_depth=10
---- ok
-STATEMENT CALL current_setting('var_length_extend_max_depth') RETURN *
---- 1
10
-STATEMENT MATCH (a:person)-[:knows*1..28]->(b:person) RETURN COUNT(*);
---- 1
354290

0 comments on commit da8107c

Please sign in to comment.