Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed cypher related shell config commands #2881

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 8 additions & 49 deletions tools/shell/embedded_shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,9 @@ struct ShellCommand {
const char* HELP = ":help";
const char* CLEAR = ":clear";
const char* QUIT = ":quit";
const char* THREAD = ":thread";
const char* LOGGING_LEVEL = ":logging_level";
const char* QUERY_TIMEOUT = ":timeout";
const char* MAXROWS = ":maxrows";
const char* MAXWIDTH = ":maxwidth";
const std::array<const char*, 8> commandList = {
HELP, CLEAR, QUIT, THREAD, LOGGING_LEVEL, QUERY_TIMEOUT, MAXROWS, MAXWIDTH};
const char* MAXROWS = ":max_rows";
const char* MAXWIDTH = ":max_width";
const std::array<const char*, 5> commandList = {HELP, CLEAR, QUIT, MAXROWS, MAXWIDTH};
} shellCommand;

const char* TAB = " ";
Expand Down Expand Up @@ -227,12 +223,6 @@ int EmbeddedShell::processShellCommands(std::string lineStr) {
linenoiseClearScreen();
} else if (lineStr == shellCommand.QUIT) {
return -1;
} else if (lineStr.rfind(shellCommand.THREAD) == 0) {
setNumThreads(lineStr.substr(strlen(shellCommand.THREAD)));
} else if (lineStr.rfind(shellCommand.LOGGING_LEVEL) == 0) {
setLoggingLevel(lineStr.substr(strlen(shellCommand.LOGGING_LEVEL)));
} else if (lineStr.rfind(shellCommand.QUERY_TIMEOUT) == 0) {
setQueryTimeout(lineStr.substr(strlen(shellCommand.QUERY_TIMEOUT)));
} else if (lineStr.rfind(shellCommand.MAXROWS) == 0) {
setMaxRows(lineStr.substr(strlen(shellCommand.MAXROWS)));
} else if (lineStr.rfind(shellCommand.MAXWIDTH) == 0) {
Expand Down Expand Up @@ -318,21 +308,6 @@ void EmbeddedShell::interruptHandler(int /*signal*/) {
globalConnection->interrupt();
}

void EmbeddedShell::setNumThreads(const std::string& numThreadsString) {
auto numThreads = 0;
try {
numThreads = stoi(numThreadsString);
} catch (std::exception& e) {
printf(
"Cannot parse '%s' as number of threads. Expect integer.\n", numThreadsString.c_str());
return;
}
try {
conn->setMaxNumThreadForExec(numThreads);
printf("numThreads set as %d\n", numThreads);
} catch (Exception& e) { printf("%s", e.what()); }
}

void EmbeddedShell::setMaxRows(const std::string& maxRowsString) {
uint64_t parsedMaxRows = 0;
try {
Expand Down Expand Up @@ -361,17 +336,15 @@ void EmbeddedShell::printHelp() {
printf("%s%s %sget command list\n", TAB, shellCommand.HELP, TAB);
printf("%s%s %sclear shell\n", TAB, shellCommand.CLEAR, TAB);
printf("%s%s %sexit from shell\n", TAB, shellCommand.QUIT, TAB);
printf("%s%s [num_threads] %sset number of threads for query execution\n", TAB,
shellCommand.THREAD, TAB);
printf("%s%s [logging_level] %sset logging level of database, available options: debug, info, "
"err\n",
TAB, shellCommand.LOGGING_LEVEL, TAB);
printf(
"%s%s [query_timeout] %sset query timeout in ms\n", TAB, shellCommand.QUERY_TIMEOUT, TAB);
printf("%s%s [max_rows] %sset maximum number of rows for display (default: 20)\n", TAB,
shellCommand.MAXROWS, TAB);
printf("%s%s [max_width] %sset maximum width in characters for display\n", TAB,
shellCommand.MAXWIDTH, TAB);
printf("\n");
printf("%sNote: you can change and see several system configurations, such as num-threads, \n", TAB);
printf("%s%s timeout, and logging_level using Cypher CALL statements.\n", TAB, TAB);
printf("%s%s e.g. CALL THREADS=5; or CALL current_setting('threads') return *;\n", TAB, TAB);
printf("%s%s See: https://kuzudb.com/docusaurus/cypher/configuration\n", TAB, TAB);
}

void EmbeddedShell::printExecutionResult(QueryResult& queryResult) const {
Expand Down Expand Up @@ -622,19 +595,5 @@ void EmbeddedShell::printExecutionResult(QueryResult& queryResult) const {
}
}

void EmbeddedShell::setLoggingLevel(const std::string& loggingLevel) {
auto level = StringUtils::ltrim(loggingLevel);
try {
database->setLoggingLevel(level);
printf("logging level has been set to: %s.\n", level.c_str());
} catch (Exception& e) { printf("%s\n", e.what()); }
}

void EmbeddedShell::setQueryTimeout(const std::string& timeoutInMS) {
auto queryTimeOutVal = std::stoull(StringUtils::ltrim(timeoutInMS));
conn->setQueryTimeOut(queryTimeOutVal);
printf("query timeout value has been set to: %llu ms.\n", queryTimeOutVal);
}

} // namespace main
} // namespace kuzu
9 changes: 0 additions & 9 deletions tools/shell/include/embedded_shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,12 @@ class EmbeddedShell {
private:
int processShellCommands(std::string lineStr);

void setNumThreads(const std::string& numThreadsString);

void printNodeSchema(const std::string& tableName);
void printRelSchema(const std::string& tableName);

static void printHelp();

void printExecutionResult(QueryResult& queryResult) const;

void updateTableNames();

void setLoggingLevel(const std::string& loggingLevel);

void setQueryTimeout(const std::string& timeoutInMS);

void setMaxRows(const std::string& maxRowsString);

void setMaxWidth(const std::string& maxWidthString);
Expand Down
Loading