图数据库比较

图数据库比较

图数据库 语言 图引擎 后端存储 访问方式 备注
Neo4j java Cypher
http://www.opencypher.org/
定制化 rest 社区版节点限制
商业版不限制
Hugegraph
百度开源图数据库
java tinkerpop
https://tinkerpop.apache.org/
Rocksdb facebook开源
Cassandra
rest 节点不限制
RedisGraph
官网 https://oss.redislabs.com/redisgraph/
c openCyper
https://juejin.im/post/5aba18b85188255c4c104be2
http://www.opencypher.org/
https://github.com/opencypher/openCypher
热内存 Redis client 为支持高效的图搜索操作,RedisGraph 底层实现了一种称为 Hexastore 的三元组存储结构
采用稀疏矩阵表示,极大节省了内存https://laowei.wang/article/5d1dce6f4b3b1f3cfe5c4d2d redisGraph简单调研 https://www.jianshu.com/p/abf5583bf7ac

RedisGraph

采用热内存,图引擎cypher,关系图使用稀疏邻接矩阵,位操作,目前性能最佳的图数据库
图表示模型
adjacent matrix
https://mathworld.wolfram.com/AdjacencyMatrix.html

新能测试:

  • 启动命令 redis-server --loadmodule /path/to/module/src/redisgraph.so
    • 4000万点,15亿边 twitter数据集
    • 单机 250G内存 32核机器
      https://redislabs.com/blog/new-redisgraph-1-0-achieves-600x-faster-performance-graph-databases/

编译redisgraph

依赖

On Ubuntu Linux, run: apt-get install build-essential cmake m4 automake peg libtool autoconf

cmake
m4
automake
libtool
autoconf

install peg 失败

  • 需要编译安装https://www.piumarta.com/software/peg/ 选择peg-0.1.18.tar.gz

  • 编译问题
    https://stackoverflow.com/questions/9637551/relocation-r-x86-64-32s-against-rodata-while-compiling-on-64-bit-platform

编译源码

tar -zxvf RedisGraph.tar.gz
cd RedisGraph
cd deps/rax/
vim Makefile
//Add -fPIC to CFLAGS or CXXFLAGS for make-based projects.

export CC=/opt/compiler/gcc-8.2/bin/gcc
export CXX=/opt/compiler/gcc-8.2/bin/g++
make -j8
make
make clean

find .|grep redisgraph.so

编译及安装问题

  • 问题1,编译失败
    …/deps/rax/rax.o: relocation r_x86_64_32 against `.rodata.str1.8’ can not be used when making a shared object; recompile with -fpic

编译动态库的时候需要使用
添加-fPIC

  • 问题2,redis start失败,查到版本低造成的,redis load失败
    https://github.com/RedisGraph/redisgraph-py/issues/24
  • 问题3,使用4.0.20 load仍然失败
    RedisGraph requires redis-server version 5.0.7 and up

启动后的log:
./redis-server --loadmodule /home/work/redis-graph/redisgraph.so

18067:M 27 Aug 2020 19:22:47.064 * Graph deletion will be done asynchronously.
18067:M 27 Aug 2020 19:22:47.064 * Thread pool created, using 8 threads.
18067:M 27 Aug 2020 19:22:47.064 * Maximum number of OpenMP threads set to 8
18067:M 27 Aug 2020 19:22:47.064 * Module ‘graph’ loaded from /home/work/redis-graph/redisgraph.so
18067:M 27 Aug 2020 19:22:47.065 * Ready to accept connections

测试

redis-cli client:
创建对象:
127.0.0.1:6379> GRAPH.QUERY social “CREATE (:person {name: ‘roi’, age: 33, gender: ‘male’, status: ‘married’})”
127.0.0.1:6379> GRAPH.QUERY social “CREATE (p:Person)-[:LIKES]→(t:Technology)”

查询对象:
GRAPH.QUERY social “MATCH(Person) return Person”

参考文档
cypher语法使用 https://neo4j.com/developer/cypher/syntax/
cypher使用 https://www.cnblogs.com/ljhdo/p/5516793.html

你可能感兴趣的