-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GIE Compiler] Introduce cypher service to accept queries from neo4j …
…ecosystem (#2848) <!-- Thanks for your contribution! please review https://github.com/alibaba/GraphScope/blob/main/CONTRIBUTING.md before opening an issue. --> ## What do these changes do? 1. introdure `GraphServer` which wrappers `IrGremlinServer` (gremlin service) and `CommunityBootstrapper` (cypher service) 2. remove cypher service from gremlin stack 3. add document of neo4j ecosystem <!-- Please give a short brief about these changes. --> ## Related issue number <!-- Are there any issues opened that will be resolved by merging this change? --> #2598 --------- Co-authored-by: siyuan0322 <[email protected]> Co-authored-by: Longbin Lai <[email protected]> Co-authored-by: longbinlai <[email protected]>
- Loading branch information
1 parent
7637aaf
commit c1007cf
Showing
52 changed files
with
2,029 additions
and
861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# GIE for Cypher | ||
This document will provide you with step-by-step guidance on how to connect your Cypher applications to the GIE's | ||
FrontEnd service, which offers functionalities similar to the official Tinkerpop service. | ||
|
||
Your first step is to obtain the Bolt Connector of GIE Frontend service: | ||
- Follow the [instruction](./dev_and_test.md#manually-start-the-gie-services) while starting GIE on a local machine. | ||
|
||
## Connecting via Python Driver | ||
|
||
GIE makes it easy to connect to a loaded graph with Neo4j's [Python Driver]](https://pypi.org/project/neo4j/). | ||
|
||
You first install the dependency: | ||
```bash | ||
pip3 install neo4j | ||
``` | ||
|
||
Then connect to the service and run queries: | ||
|
||
```Python | ||
from neo4j import GraphDatabase, RoutingControl | ||
|
||
URI = "neo4j://localhost:7687" # the bolt connector you've obtained | ||
AUTH = ("", "") # We have not implemented authentication yet | ||
|
||
def print_top_10(driver): | ||
records, _, _ = driver.execute_query( | ||
"MATCH (n) RETURN n Limit 10", | ||
routing_=RoutingControl.READ, | ||
) | ||
for record in records: | ||
print(record["n"]) | ||
|
||
|
||
with GraphDatabase.driver(URI, auth=AUTH) as driver: | ||
print_top_10(driver) | ||
``` | ||
|
||
|
||
## Connecting via Cypher-Shell | ||
1. Download and extract `cypher-shell` | ||
```bash | ||
wget https://dist.neo4j.org/cypher-shell/cypher-shell-4.4.19.zip | ||
unzip cypher-shell-4.4.19.zip && cd cypher-shell | ||
``` | ||
2. Connect to the Bolt Connector | ||
```bash | ||
./cypher-shell -a neo4j://localhost:7687 | ||
``` | ||
3. Run Queries | ||
```bash | ||
@neo4j> Match (n) Return n Limit 10; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# Cypher Support | ||
This document outlines the current capabilities of GIE in supporting Neo4j's Cypher queries and | ||
compares them to the [syntax](https://neo4j.com/docs/cypher-manual/current/syntax/) specified in Neo4j. | ||
While our goal is to comply with Neo4j's syntax, GIE currently has some limitations. | ||
One major constraint is that we solely support the **read** path in Cypher. | ||
Therefore, functionalities associated with writing, such as adding vertices/edges or modifying their properties, remain **unaddressed**. | ||
|
||
We provide in-depth details regarding Cypher's support in GIE, mainly including data types, operators and clauses. | ||
We further highlight planned features that we intend to offer in the near future. | ||
While all terminologies, including data types, operators, and keywords in clauses, are case-insensitive in this document, we use capital and lowercase letters for the terminologies of Neo4j and GIE, respectively, to ensure clarity. | ||
|
||
## Data Types | ||
As [Neo4j](https://neo4j.com/docs/cypher-manual/current/values-and-types), we have provided support for | ||
data value of types in the categories of **property**, **structural** and **constructed**. | ||
However, the specific data types that we support are slightly modified from those in Cypher to ensure compatibility with our storage system. Further details will be elaborated upon. | ||
|
||
### Property Types | ||
The available data types stored in the vertices (equivalent of nodes in Cypher) and edges (equivalent of relationships in Cypher), known as property types, are divided into several categories including Boolean, Integer, Float, String, Bytes, Placeholder and Temporal. These property types are extensively utilized and can be commonly utilized in queries and as parameters -- making them the most commonly used data types. | ||
|
||
| Category | Cypher Type | GIE Type | Supported | Todo | | ||
|:---|:---|:---|:---:|:---| | ||
| Boolean | BOOLEAN | bool | <input type="checkbox" disabled checked /> | | | ||
| Integer | INTEGER | int32/uint32/int64/uint64 | <input type="checkbox" disabled checked /> | | | ||
| Float | FLOAT | float/double | <input type="checkbox" disabled checked /> | | | ||
| String | STRING | string | <input type="checkbox" disabled checked /> | | | ||
| Bytes| BYTE_ARRAY | bytes | <input type="checkbox" disabled checked /> | | | ||
| Placeholder | NULL | none | <input type="checkbox" disabled /> | Planned | | ||
| Temporal | DATE | date | <input type="checkbox" disabled /> | Planned | | ||
| Temporal | DATETIME (ZONED) | datetime (Zoned) | <input type="checkbox" disabled /> | Planned | | ||
| Temporal | TIME (ZONED) | time (Zoned) | <input type="checkbox" disabled /> | Planned | | ||
|
||
### Structural types | ||
In a graph, Structural Types are the first-class citizens and are comprised of the following: | ||
- Vertex: It encodes the information of a particular vertex in the graph. The information includes the id, label, and a map of properties. However, it is essential to note that multiple labels in a vertex are currently unsupported in GIE. | ||
- Edge: It encodes the information of a particular edge in the graph. The information comprises the id, edge label, a map of properties, and a pair of vertex ids that refer to source/destination vertices. | ||
- Path: It encodes the alternating sequence of vertices and conceivably edges while traversing the graph. | ||
|
||
|Category | Cypher Type | GIE Type | Supported | Todo | | ||
|:---|:---|:---|:---:|:---| | ||
|Graph | NODE | vertex | <input type="checkbox" disabled checked /> | | | ||
|Graph | RELATIONSHIP | edge | <input type="checkbox" disabled checked /> | | | ||
|Graph | PATH | path | <input type="checkbox" disabled checked /> | | | ||
|
||
### Constructed Types | ||
Constructed types mainly include the categories of Array and Map. | ||
|
||
| Category | Cypher Type | GIE Type | Supported | Todo | | ||
|:---|:---|:---|:---:|:---| | ||
| Array | LIST<INNER_TYPE> | int32/int64/double/string/pair Array | <input type="checkbox" disabled checked /> | | | ||
| Map | MAP | N/A | <input type="checkbox" disabled />| only used in Vertex/Edge | | ||
|
||
## Operators | ||
We list GIE's support of the operators in the categories of Aggregation, Property, Mathematical, | ||
Comparison, String and Boolean. Examples and functionalities of these operators are the same | ||
as in [Neo4j](https://neo4j.com/docs/cypher-manual/current/syntax/operators/). | ||
Note that some Aggregator operators, such as `max()`, we listed here are implemented in Neo4j as | ||
[functions](https://neo4j.com/docs/cypher-manual/current/functions/). We have not introduced functions at this moment. | ||
|
||
|
||
| Category | Description | Cypher Operation | GIE Operation | Supported | Todo | | ||
|:---|:----|:---|:----|:---:|:---| | ||
| Aggregate | Average value | AVG() | avg() | <input type="checkbox" disabled checked /> | | | ||
| Aggregate | Minimum value | MIN() | min() | <input type="checkbox" disabled checked /> | | | ||
| Aggregate | Maximum value |MAX() | max() | <input type="checkbox" disabled checked /> | | | ||
| Aggregate | Count the elements |COUNT() | count() | <input type="checkbox" disabled checked /> | | | ||
| Aggregate | Count the distinct elements | COUNT(DISTINCT) | count(distinct) | <input type="checkbox" disabled checked /> | | | ||
| Aggregate | Summarize the value | SUM() | sum() | <input type="checkbox" disabled checked /> | | | ||
| Aggregate | Collect into a list | COLLECT() | collect() | <input type="checkbox" disabled checked /> | | | ||
| Aggregate | Collect into a set | COLLECT(DISTINCT) | collect(distinct) | <input type="checkbox" disabled checked /> | | | ||
| Property | Get property of a vertex/edge | [N\|R]."KEY" | [v\|e]."key" | <input type="checkbox" disabled checked /> | | | ||
| Mathematical | Addition | + | + | <input type="checkbox" disabled checked /> | | | ||
| Mathematical | Subtraction | - | - | <input type="checkbox" disabled checked /> | | | ||
| Mathematical | Multiplication | * | * | <input type="checkbox" disabled checked /> | | | ||
| Mathematical | Division | / | / | <input type="checkbox" disabled checked /> | | | ||
| Mathematical | Modulo division | % | % | <input type="checkbox" disabled checked /> | | | ||
| Mathematical | Exponentiation | ^ | ^^ | <input type="checkbox" disabled checked /> | | | ||
| Comparison | Equality | = | = | <input type="checkbox" disabled checked /> | | | ||
| Comparison | Inequality| <> | <> | <input type="checkbox" disabled checked /> | | | ||
| Comparison | Less than | < | < | <input type="checkbox" disabled checked /> | | | ||
| Comparison | Less than or equal | <= | <= | <input type="checkbox" disabled checked /> | | | ||
| Comparison | Greater than | > | > | <input type="checkbox" disabled checked /> | | | ||
| Comparison | Greater than or equal | >= | >= | <input type="checkbox" disabled checked /> | | | ||
| Comparison | Verify as `NULL`| IS NULL | is null | <input type="checkbox" disabled /> | planned | | ||
| Comparison | Verify as `NOT NULL`| IS NOT NULL | is not null | <input type="checkbox" disabled /> | planned | | ||
| Comparison | String starts with | STARTS WITH | starts with | <input type="checkbox" disabled />| planned | | ||
| Comparison | String ends with | ENDS WITH | ends with | <input type="checkbox" disabled />| planned | | ||
| Comparison | String contains | CONTAINS | contains | <input type="checkbox" disabled />| planned | | ||
| Boolean | Conjunction | AND | and | <input type="checkbox" disabled checked /> | | | ||
| Boolean | Disjunction | OR | or | <input type="checkbox" disabled checked /> | | | ||
| Boolean | Exclusive Disjunction | XOR | xor | <input type="checkbox" disabled /> | planned | | ||
| Boolean | Negation | NOT | not | <input type="checkbox" disabled /> | planned | | ||
| BitOpr | Bit and | via function | & | <input type="checkbox" disabled checked /> | | | ||
| BitOpr | Bit or | via function | \| | <input type="checkbox" disabled checked /> | | | ||
| Boolean | Bit xor | via function | ^ | <input type="checkbox" disabled checked /> | | | ||
| BitOpr | Bit reverse | via function | ~ | <input type="checkbox" disabled checked /> | | | ||
| BitOpr | Bit left shift | via function | << | <input type="checkbox" disabled />| planned | | ||
| BitOpr | Bit right shift | via function | >> | <input type="checkbox" disabled />| planned | | ||
| Branch | Use with `Project` and `Return` | CASE WHEN | CASE WHEN | <input type="checkbox" disabled />| planned | | ||
|
||
|
||
|
||
## Clause | ||
A notable limitation for now is that we do not | ||
allow specifying multiple `MATCH` clauses in **one** query. For example, | ||
the following code will not compile: | ||
```Cypher | ||
MATCH (a) -[]-> (b) | ||
WITH a, b | ||
MATCH (a) -[]-> () -[]-> (b) # second MATCH clause | ||
RETURN a, b; | ||
``` | ||
|
||
| Keyword | Comments | Supported | Todo | ||
|:---|---|:---:|:---| | ||
| MATCH | only one Match clause is allowed | <input type="checkbox" disabled checked /> | | ||
| OPTIONAL MATCH | implements as left outer join | <input type="checkbox" disabled /> | planned | | ||
| RETURN .. [AS] | | <input type="checkbox" disabled checked /> | | | ||
| WITH .. [AS] | project, aggregate, distinct | <input type="checkbox" disabled checked /> | | | ||
| WHERE | | <input type="checkbox" disabled checked /> | | | ||
| NOT EXIST (an edge/path) | implements as anti join | <input type="checkbox" disabled />| | | ||
| ORDER BY | | <input type="checkbox" disabled checked /> | | | ||
| LIMIT | | <input type="checkbox" disabled checked /> | | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Neo4j Ecosystem | ||
|
||
[Neo4j](https://neo4j.com/) is a graph database management system that utilizes graph natively to store and process data. | ||
Unlike traditional relational databases that rely on relational schemas, Neo4j leverages the power of interconnected nodes and relationships, | ||
forming a highly flexible and expressive data model. GIE implements Neo4j's HTTP and TCP protocol so that the system can | ||
seamlessly interact with the Neo4j ecosystem, including development tools such as [cypher-shell] (https://dist.neo4j.org/cypher-shell/cypher-shell-4.4.19.zip) | ||
and [drivers] (https://neo4j.com/developer/language-guides/). | ||
|
||
The following documentations will guide you through empowering the Neo4j ecosystem | ||
with GIE's distributed capability for large-scale graph. | ||
|
||
```{toctree} arguments | ||
--- | ||
caption: GIE For Tinkerpop Ecosystem | ||
maxdepth: 2 | ||
--- | ||
neo4j/cypher_sdk | ||
neo4j/supported_cypher | ||
``` |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.