When I saw the Nebula Graph code repository for the first time, I was so shocked by its huge size that I didn’t know how to dig into the source code. Then I worked up the nerve. After reading the code and running the use cases over and over, I finally gained some experience worth sharing with you, hoping that all my experience could push you to give Nebula Graph source code a shot to know more about the graph DBMS, to improve your graph database knowledge, and to fix some bugs that are not so complicated of this repository.

In this article, I took the SHOW SPACES statement as an example to show you how Nebula Graph processes an nGQL statement after it was input on the client side. GDB, the GNU Project debugger, was used to trace the execution.

Additionally, some open-source libraries are used in Nebula Graph. For more information, see the Libraries section.

Architecture of Nebula Graph

A complete Nebula Graph DBMS contains three services: Query Service, Storage Service, and Meta Service. Each service has its own executable binary files.

Query Service is responsible for these tasks:

  • Managing connection to the client
  • Parsing an nGQL statement input from a client into an AST (Abstract Syntax Tree) and then parsing the AST to an execution plan
  • Optimizing the execution plan
  • Executing queries with the optimized execution plan

Storage Service is responsible for distributed data store.

Meta Service is responsible for these tasks:

  • Operating CRUD on graph schema objects
  • Managing the cluster
  • Performing user authentication

In this case, I used Query Service as an example to show you some experience.

Source Code Directory Hierarchy

When we get the source packages and have them unzipped, we should do a check of the source code directory hierarchy. Each package has its own functions. Here is how the src directory looks like.

Shell

1

|--src

2

    |--client // Provides the code for the client

3

    |--common // Provides some common basic components

4

    |--console

5

    |--daemons

6

    |--dataman

7

    |--graph // Contains most codes of Query Service

8

    |--interface // Contains some communication interfaces for meta, storage, and query services

9

    |--jni

10

    |--kvstore

11

    |--meta // Relates to meta service information 

12

    |--parser // Contains modules for lexical parsing (Lexer) and semantic analysis 

13

    |--storage // Contains codes about the storage layer

14

    |--tools

15

    |--webservice

#database #tutorial #c++ #graph database #source code #nebula graph

Nebula Graph Source Code Explained via a Sample Graph Query
1.40 GEEK