-
Notifications
You must be signed in to change notification settings - Fork 24
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
add cypher AST #250
base: master
Are you sure you want to change the base?
add cypher AST #250
Changes from all commits
7707bfb
71c8349
6878eb9
79ec206
ab5e605
71f3cbe
6a86ee4
516cd42
bf32c76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,23 @@ RUN if [ "$DEBUG" = "true" ]; then apt-get update \ | |
&& apt-get install --no-install-recommends -y gdb gdbserver \ | ||
&& apt-get clean; fi | ||
|
||
WORKDIR "${HOME}" | ||
RUN mkdir antlr | ||
WORKDIR "${HOME}"/antlr | ||
RUN apt-get update && apt-get install --no-install-recommends -y default-jre | ||
RUN curl -O https://s3.amazonaws.com/artifacts.opencypher.org/M23/Cypher.g4 | ||
RUN curl -O https://www.antlr.org/download/antlr-4.13.2-complete.jar | ||
RUN java -jar antlr-4.13.2-complete.jar -Dlanguage=Cpp -visitor Cypher.g4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move this entire process of downloading, installing, running, and removing the JVM to pre-requisites image? I do not see a point of doing that here. |
||
RUN apt-get purge default-jre -y | ||
|
||
WORKDIR "${JASMINEGRAPH_HOME}" | ||
RUN mkdir "${JASMINEGRAPH_HOME}"/code_generated/ | ||
RUN mkdir "${JASMINEGRAPH_HOME}"/code_generated/antlr | ||
RUN mv /home/ubuntu/antlr/*.cpp "${JASMINEGRAPH_HOME}"/code_generated/antlr | ||
RUN mv /home/ubuntu/antlr/*.h "${JASMINEGRAPH_HOME}"/code_generated/antlr | ||
RUN rm -f "${HOME}"/antlr/* | ||
|
||
WORKDIR "${JASMINEGRAPH_HOME}" | ||
COPY ./build.sh ./build.sh | ||
COPY ./CMakeLists.txt ./CMakeLists.txt | ||
COPY ./main.h ./main.h | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,12 @@ limitations under the License. | |
#include "JasmineGraphFrontEndProtocol.h" | ||
#include "core/CoreConstants.h" | ||
#include "core/scheduler/JobScheduler.h" | ||
#include "antlr4-runtime.h" | ||
#include "/home/ubuntu/software/jasminegraph/code_generated/antlr/CypherLexer.h" | ||
#include "/home/ubuntu/software/jasminegraph/code_generated/antlr/CypherParser.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than specifying absolute path here, we should use relative path instead. |
||
#include "../query/processor/cypher/astbuilder/ASTBuilder.h" | ||
#include "../query/processor/cypher/astbuilder/ASTNode.h" | ||
|
||
|
||
#define MAX_PENDING_CONNECTIONS 10 | ||
#define DATA_BUFFER_SIZE (FRONTEND_DATA_LENGTH + 1) | ||
|
@@ -64,6 +70,7 @@ bool JasmineGraphFrontEnd::strian_exit; | |
|
||
static std::string getPartitionCount(std::string path); | ||
static void list_command(int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_p); | ||
static void cypher_ast_command(int connFd, bool *loop_exit_p); | ||
static void add_rdf_command(std::string masterIP, int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_p); | ||
static void add_graph_command(std::string masterIP, int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_p); | ||
static void add_graph_cust_command(std::string masterIP, int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_p); | ||
|
@@ -169,7 +176,9 @@ void *frontendservicesesion(void *dummyPt) { | |
break; | ||
} else if (line.compare(LIST) == 0) { | ||
list_command(connFd, sqlite, &loop_exit); | ||
} else if (line.compare(SHTDN) == 0) { | ||
} else if (line.compare(CYPHER_AST) == 0){ | ||
cypher_ast_command(connFd, &loop_exit); | ||
}else if (line.compare(SHTDN) == 0) { | ||
JasmineGraphServer::shutdown_workers(); | ||
close(connFd); | ||
exit(0); | ||
|
@@ -627,6 +636,45 @@ static void list_command(int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_ | |
} | ||
} | ||
|
||
static void cypher_ast_command(int connFd, bool *loop_exit) | ||
{ | ||
|
||
string msg_1 = "Input Query :"; | ||
int result_wr = write(connFd, msg_1.c_str(), msg_1.length()); | ||
if (result_wr < 0) { | ||
frontend_logger.error("Error writing to socket"); | ||
*loop_exit = true; | ||
return; | ||
} | ||
result_wr = write(connFd, "\r\n", 2); | ||
if (result_wr < 0) { | ||
frontend_logger.error("Error writing to socket"); | ||
*loop_exit = true; | ||
return; | ||
} | ||
|
||
// Get user response. | ||
char user_res[FRONTEND_DATA_LENGTH + 1]; | ||
bzero(user_res, FRONTEND_DATA_LENGTH + 1); | ||
read(connFd, user_res, FRONTEND_DATA_LENGTH); | ||
string user_res_s(user_res); | ||
|
||
antlr4::ANTLRInputStream input(user_res_s); | ||
// Create a lexer from the input | ||
CypherLexer lexer(&input); | ||
|
||
// Create a token stream from the lexer | ||
antlr4::CommonTokenStream tokens(&lexer); | ||
|
||
// Create a parser from the token stream | ||
CypherParser parser(&tokens); | ||
|
||
ASTBuilder ast_builder; | ||
auto* ast = any_cast<ASTNode*>(ast_builder.visitOC_Cypher(parser.oC_Cypher())); | ||
string result = ast->print(1); | ||
frontend_logger.log(result, "log"); | ||
} | ||
|
||
static void add_rdf_command(std::string masterIP, int connFd, SQLiteDBInterface *sqlite, bool *loop_exit_p) { | ||
// add RDF graph | ||
int result_wr = write(connFd, SEND.c_str(), FRONTEND_COMMAND_LENGTH); | ||
|
@@ -804,7 +852,8 @@ static void add_graph_command(std::string masterIP, int connFd, SQLiteDBInterfac | |
int result_wr = write(connFd, DONE.c_str(), DONE.size()); | ||
if (result_wr < 0) { | ||
frontend_logger.error("Error writing to socket"); | ||
*loop_exit_p = true; | ||
*loop_exit_p = | ||
true; | ||
return; | ||
} | ||
result_wr = write(connFd, "\r\n", 2); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use C++ 11 standard currently in JasmineGraph. Is there special reason to change the C++ standard to 17?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sir, I have to use "any_cast" and "std::any" in the cypher ast, because I have to override the methods of generated parse by antlr4 and those methods use that "std::any". it is a utility which is provided by c++ 17 standards. that's why I used C++ 17 standards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a simple change. We have to evaluate the effect of this for the entire project. We should not do standard upgrade unless we assess the essential requirement of doing so, what would be the complications, and the development workload attached to that. So what you are saying is Cypher is dependent on C++ 17?