图数据库之hugegraph

  一、HugeGraph是一款易用、高效、通用的开源图数据库系统(Graph Database,GitHub项目地址), 实现了Apache TinkerPop3框架及完全兼容Gremlin查询语言, 具备完善的工具链组件,助力用户轻松构建基于图数据库之上的应用和产品。HugeGraph支持百亿以上的顶点和边快速导入,并提供毫秒级的关联关系查询能力(OLTP), 并支持大规模分布式图分析(OLAP)。

  HugeGraph典型应用场景包括深度关系探索、关联分析、路径搜索、特征抽取、数据聚类、社区检测、 知识图谱等,适用业务领域有如网络安全、电信诈骗、金融风控、广告推荐、社交网络和智能机器人等。

本系统的主要应用场景是解决反欺诈、威胁情报、黑产打击等业务的图数据存储和建模分析需求,在此基础上逐步扩展及支持了更多的通用图应用。

  二、目前hugegraph1.0.0版本已经有apache接管了,已经进行了开源处理,可以在apache的网站看到hugegraph图数据库相关的概述,不过大部分的文档还是在百度hugegraph的官网上面了。

  三、和neo4j相比,概念层面大同小异。不同点如下:

    1、hugegraph需要先定义属性、标签(顶点)、关系类型(边)。并且入库数据时,相关的东西必须存在。neo4j不需要预先定义。

    2、hugegraph在1.0.0版本后支持cypher语法查询了。相对于neo4j也是做了兼容了。

    3、hugegraph可以切换不同的数据源存储。neo4j单节点性能优势比较大,hugegraph分布式能力更好。

    4、其他的不同点主要是在性能层面。具体地址参考:https://hugegraph.apache.org/cn/docs/changelog/hugegraph-1.0.0-release-notes/  https://zhuanlan.zhihu.com/p/199277762?utm_id=0

    

  四、安装:百度官网地址:https://hugegraph.apache.org/cn/ 查看安装文档。apahce官网地址:https://incubator.apache.org/clutch/hugegraph.html 

    这采用apache的1.0.0版本docker安装。db是执行后生成的脚本。driver是因为镜像不带驱动。

  

   docker-compose.yml

version: '3'
services:
  xbd-mysql:
    build:
      context: ./
      dockerfile: ./dockerfile/Dockerfile-mysql
    image: xbd-mysql:8.0.29
    container_name: xbd-mysql
    restart: always
    privileged: true
    ports:
      - 3306:3306
    environment:
      - TZ=Asia/Shanghai
      - MYSQL_ROOT_PASSWORD=root
    volumes:
      - /var/lib/hugegraph:/var/lib/mysql
    command:
      --lower_case_table_names=1
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --default-authentication-plugin=mysql_native_password
  xbd-hugegraph-server:
    build:
      context: ./
      dockerfile: ./dockerfile/Dockerfile-hugegraph-server
    image: xbd-hugegraph-server:1.0.0
    container_name: xbd-hugegraph-server
    restart: always
    privileged: true
    ports:
      - 8080:8080
    depends_on:
      - xbd-mysql
  xbd-hugegraph-hubble:
    image: hugegraph/hubble
    container_name: xbd-hugegraph-hubble
    restart: always
    privileged: true
    ports:
      - 8088:8088

  dockerfile

FROM mysql:8.0.29
MAINTAINER xbd
COPY ./db /docker-entrypoint-initdb.d
FROM hugegraph/hugegraph:1.0.0
ADD ./driver/mysql-connector-java-8.0.29.jar /hugegraph/lib
COPY ./conf/hugegraph.properties /hugegraph/conf/graphs/hugegraph.properties

  db产生方式:https://hugegraph.apache.org/cn/docs/quickstart/hugegraph-server/

CREATE DATABASE IF NOT EXISTS hugegraph DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

USE hugegraph;

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for c
-- ----------------------------
DROP TABLE IF EXISTS `c`;
CREATE TABLE `c`  (
  `SCHEMA_TYPE` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `ID` int NULL DEFAULT NULL,
  PRIMARY KEY (`SCHEMA_TYPE`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of c
-- ----------------------------

-- ----------------------------
-- Table structure for el
-- ----------------------------
DROP TABLE IF EXISTS `el`;
CREATE TABLE `el`  (
  `ID` int NOT NULL,
  `NAME` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `FREQUENCY` tinyint NULL DEFAULT NULL,
  `SOURCE_LABEL` int NULL DEFAULT NULL,
  `TARGET_LABEL` int NULL DEFAULT NULL,
  `SORT_KEYS` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `PROPERTIES` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `NULLABLE_KEYS` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `INDEX_LABELS` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `ENABLE_LABEL_INDEX` tinyint(1) NULL DEFAULT NULL,
  `USER_DATA` text CHARACTER SET utf8 COLLATE utf8_bin NULL,
  `STATUS` tinyint NULL DEFAULT NULL,
  `TTL` int NULL DEFAULT NULL,
  `TTL_START_TIME` int NULL DEFAULT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of el
-- ----------------------------

-- ----------------------------
-- Table structure for g_ai
-- ----------------------------
DROP TABLE IF EXISTS `g_ai`;
CREATE TABLE `g_ai`  (
  `FIELD_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `INDEX_LABEL_ID` int NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`FIELD_VALUES`, `INDEX_LABEL_ID`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of g_ai
-- ----------------------------

-- ----------------------------
-- Table structure for g_di
-- ----------------------------
DROP TABLE IF EXISTS `g_di`;
CREATE TABLE `g_di`  (
  `INDEX_LABEL_ID` int NOT NULL,
  `FIELD_VALUES` double NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`INDEX_LABEL_ID`, `FIELD_VALUES`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of g_di
-- ----------------------------

-- ----------------------------
-- Table structure for g_fi
-- ----------------------------
DROP TABLE IF EXISTS `g_fi`;
CREATE TABLE `g_fi`  (
  `INDEX_LABEL_ID` int NOT NULL,
  `FIELD_VALUES` double NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`INDEX_LABEL_ID`, `FIELD_VALUES`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of g_fi
-- ----------------------------

-- ----------------------------
-- Table structure for g_hi
-- ----------------------------
DROP TABLE IF EXISTS `g_hi`;
CREATE TABLE `g_hi`  (
  `INDEX_LABEL_ID` int NOT NULL,
  `FIELD_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`INDEX_LABEL_ID`, `FIELD_VALUES`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of g_hi
-- ----------------------------

-- ----------------------------
-- Table structure for g_ie
-- ----------------------------
DROP TABLE IF EXISTS `g_ie`;
CREATE TABLE `g_ie`  (
  `OWNER_VERTEX` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `DIRECTION` tinyint NOT NULL,
  `LABEL` int NOT NULL,
  `SORT_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `OTHER_VERTEX` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `PROPERTIES` text CHARACTER SET utf8 COLLATE utf8_bin NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`OWNER_VERTEX`, `DIRECTION`, `LABEL`, `SORT_VALUES`, `OTHER_VERTEX`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of g_ie
-- ----------------------------

-- ----------------------------
-- Table structure for g_ii
-- ----------------------------
DROP TABLE IF EXISTS `g_ii`;
CREATE TABLE `g_ii`  (
  `INDEX_LABEL_ID` int NOT NULL,
  `FIELD_VALUES` int NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`INDEX_LABEL_ID`, `FIELD_VALUES`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of g_ii
-- ----------------------------

-- ----------------------------
-- Table structure for g_li
-- ----------------------------
DROP TABLE IF EXISTS `g_li`;
CREATE TABLE `g_li`  (
  `INDEX_LABEL_ID` int NOT NULL,
  `FIELD_VALUES` bigint NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`INDEX_LABEL_ID`, `FIELD_VALUES`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of g_li
-- ----------------------------

-- ----------------------------
-- Table structure for g_oe
-- ----------------------------
DROP TABLE IF EXISTS `g_oe`;
CREATE TABLE `g_oe`  (
  `OWNER_VERTEX` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `DIRECTION` tinyint NOT NULL,
  `LABEL` int NOT NULL,
  `SORT_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `OTHER_VERTEX` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `PROPERTIES` text CHARACTER SET utf8 COLLATE utf8_bin NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`OWNER_VERTEX`, `DIRECTION`, `LABEL`, `SORT_VALUES`, `OTHER_VERTEX`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of g_oe
-- ----------------------------

-- ----------------------------
-- Table structure for g_si
-- ----------------------------
DROP TABLE IF EXISTS `g_si`;
CREATE TABLE `g_si`  (
  `FIELD_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `INDEX_LABEL_ID` int NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`FIELD_VALUES`, `INDEX_LABEL_ID`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of g_si
-- ----------------------------

-- ----------------------------
-- Table structure for g_ui
-- ----------------------------
DROP TABLE IF EXISTS `g_ui`;
CREATE TABLE `g_ui`  (
  `FIELD_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `INDEX_LABEL_ID` int NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`FIELD_VALUES`, `INDEX_LABEL_ID`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of g_ui
-- ----------------------------

-- ----------------------------
-- Table structure for g_v
-- ----------------------------
DROP TABLE IF EXISTS `g_v`;
CREATE TABLE `g_v`  (
  `ID` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `LABEL` int NULL DEFAULT NULL,
  `PROPERTIES` mediumtext CHARACTER SET utf8 COLLATE utf8_bin NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of g_v
-- ----------------------------

-- ----------------------------
-- Table structure for il
-- ----------------------------
DROP TABLE IF EXISTS `il`;
CREATE TABLE `il`  (
  `ID` int NOT NULL,
  `NAME` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `BASE_TYPE` tinyint NULL DEFAULT NULL,
  `BASE_VALUE` int NULL DEFAULT NULL,
  `INDEX_TYPE` tinyint NULL DEFAULT NULL,
  `FIELDS` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `USER_DATA` text CHARACTER SET utf8 COLLATE utf8_bin NULL,
  `STATUS` tinyint NULL DEFAULT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of il
-- ----------------------------

-- ----------------------------
-- Table structure for m
-- ----------------------------
DROP TABLE IF EXISTS `m`;
CREATE TABLE `m`  (
  `NAME` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `VALUE` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  PRIMARY KEY (`NAME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of m
-- ----------------------------
INSERT INTO `m` VALUES ('VERSION', '1.11');

-- ----------------------------
-- Table structure for pk
-- ----------------------------
DROP TABLE IF EXISTS `pk`;
CREATE TABLE `pk`  (
  `ID` int NOT NULL,
  `NAME` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `DATA_TYPE` tinyint NULL DEFAULT NULL,
  `CARDINALITY` tinyint NULL DEFAULT NULL,
  `AGGREGATE_TYPE` tinyint NULL DEFAULT NULL,
  `WRITE_TYPE` tinyint NULL DEFAULT NULL,
  `PROPERTIES` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `USER_DATA` text CHARACTER SET utf8 COLLATE utf8_bin NULL,
  `STATUS` tinyint NULL DEFAULT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of pk
-- ----------------------------

-- ----------------------------
-- Table structure for s_ai
-- ----------------------------
DROP TABLE IF EXISTS `s_ai`;
CREATE TABLE `s_ai`  (
  `FIELD_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `INDEX_LABEL_ID` int NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`FIELD_VALUES`, `INDEX_LABEL_ID`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of s_ai
-- ----------------------------

-- ----------------------------
-- Table structure for s_di
-- ----------------------------
DROP TABLE IF EXISTS `s_di`;
CREATE TABLE `s_di`  (
  `INDEX_LABEL_ID` int NOT NULL,
  `FIELD_VALUES` double NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`INDEX_LABEL_ID`, `FIELD_VALUES`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of s_di
-- ----------------------------

-- ----------------------------
-- Table structure for s_fi
-- ----------------------------
DROP TABLE IF EXISTS `s_fi`;
CREATE TABLE `s_fi`  (
  `INDEX_LABEL_ID` int NOT NULL,
  `FIELD_VALUES` double NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`INDEX_LABEL_ID`, `FIELD_VALUES`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of s_fi
-- ----------------------------

-- ----------------------------
-- Table structure for s_hi
-- ----------------------------
DROP TABLE IF EXISTS `s_hi`;
CREATE TABLE `s_hi`  (
  `INDEX_LABEL_ID` int NOT NULL,
  `FIELD_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`INDEX_LABEL_ID`, `FIELD_VALUES`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of s_hi
-- ----------------------------

-- ----------------------------
-- Table structure for s_ie
-- ----------------------------
DROP TABLE IF EXISTS `s_ie`;
CREATE TABLE `s_ie`  (
  `OWNER_VERTEX` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `DIRECTION` tinyint NOT NULL,
  `LABEL` int NOT NULL,
  `SORT_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `OTHER_VERTEX` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `PROPERTIES` text CHARACTER SET utf8 COLLATE utf8_bin NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`OWNER_VERTEX`, `DIRECTION`, `LABEL`, `SORT_VALUES`, `OTHER_VERTEX`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of s_ie
-- ----------------------------

-- ----------------------------
-- Table structure for s_ii
-- ----------------------------
DROP TABLE IF EXISTS `s_ii`;
CREATE TABLE `s_ii`  (
  `INDEX_LABEL_ID` int NOT NULL,
  `FIELD_VALUES` int NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`INDEX_LABEL_ID`, `FIELD_VALUES`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of s_ii
-- ----------------------------

-- ----------------------------
-- Table structure for s_li
-- ----------------------------
DROP TABLE IF EXISTS `s_li`;
CREATE TABLE `s_li`  (
  `INDEX_LABEL_ID` int NOT NULL,
  `FIELD_VALUES` bigint NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`INDEX_LABEL_ID`, `FIELD_VALUES`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of s_li
-- ----------------------------

-- ----------------------------
-- Table structure for s_oe
-- ----------------------------
DROP TABLE IF EXISTS `s_oe`;
CREATE TABLE `s_oe`  (
  `OWNER_VERTEX` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `DIRECTION` tinyint NOT NULL,
  `LABEL` int NOT NULL,
  `SORT_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `OTHER_VERTEX` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `PROPERTIES` text CHARACTER SET utf8 COLLATE utf8_bin NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`OWNER_VERTEX`, `DIRECTION`, `LABEL`, `SORT_VALUES`, `OTHER_VERTEX`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of s_oe
-- ----------------------------

-- ----------------------------
-- Table structure for s_si
-- ----------------------------
DROP TABLE IF EXISTS `s_si`;
CREATE TABLE `s_si`  (
  `FIELD_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `INDEX_LABEL_ID` int NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`FIELD_VALUES`, `INDEX_LABEL_ID`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of s_si
-- ----------------------------

-- ----------------------------
-- Table structure for s_ui
-- ----------------------------
DROP TABLE IF EXISTS `s_ui`;
CREATE TABLE `s_ui`  (
  `FIELD_VALUES` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `INDEX_LABEL_ID` int NOT NULL,
  `ELEMENT_IDS` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`FIELD_VALUES`, `INDEX_LABEL_ID`, `ELEMENT_IDS`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of s_ui
-- ----------------------------

-- ----------------------------
-- Table structure for s_v
-- ----------------------------
DROP TABLE IF EXISTS `s_v`;
CREATE TABLE `s_v`  (
  `ID` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `LABEL` int NULL DEFAULT NULL,
  `PROPERTIES` mediumtext CHARACTER SET utf8 COLLATE utf8_bin NULL,
  `EXPIRED_TIME` bigint NULL DEFAULT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of s_v
-- ----------------------------

-- ----------------------------
-- Table structure for vl
-- ----------------------------
DROP TABLE IF EXISTS `vl`;
CREATE TABLE `vl`  (
  `ID` int NOT NULL,
  `NAME` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `ID_STRATEGY` tinyint NULL DEFAULT NULL,
  `PRIMARY_KEYS` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `PROPERTIES` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `NULLABLE_KEYS` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `INDEX_LABELS` varchar(1024) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
  `ENABLE_LABEL_INDEX` tinyint(1) NULL DEFAULT NULL,
  `USER_DATA` text CHARACTER SET utf8 COLLATE utf8_bin NULL,
  `STATUS` tinyint NULL DEFAULT NULL,
  `TTL` int NULL DEFAULT NULL,
  `TTL_START_TIME` int NULL DEFAULT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_bin ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of vl
-- ----------------------------

SET FOREIGN_KEY_CHECKS = 1;
View Code

  hugegraph.properties

# gremlin entrance to create graph
# auth config: org.apache.hugegraph.auth.HugeFactoryAuthProxy
gremlin.graph=org.apache.hugegraph.HugeFactory

# cache config
#schema.cache_capacity=100000
# vertex-cache default is 1000w, 10min expired
vertex.cache_type=l2
#vertex.cache_capacity=10000000
#vertex.cache_expire=600
# edge-cache default is 100w, 10min expired
edge.cache_type=l2
#edge.cache_capacity=1000000
#edge.cache_expire=600


# schema illegal name template
#schema.illegal_name_regex=\s+|~.*

#vertex.default_label=vertex

backend=mysql
serializer=mysql

store=hugegraph

raft.mode=false
raft.path=./raft-log
raft.safe_read=true
raft.use_replicator_pipeline=true
raft.election_timeout=10000
raft.snapshot_interval=3600
raft.backend_threads=48
raft.read_index_threads=8
raft.snapshot_threads=4
raft.read_strategy=ReadOnlyLeaseBased
raft.queue_size=16384
raft.queue_publish_timeout=60
raft.apply_batch=1
raft.rpc_threads=80
raft.rpc_connect_timeout=5000
raft.rpc_timeout=60
raft.install_snapshot_rpc_timeout=36000

search.text_analyzer=jieba
search.text_analyzer_mode=INDEX

# rocksdb backend config
#rocksdb.data_path=/path/to/disk
#rocksdb.wal_path=/path/to/disk


# cassandra backend config
cassandra.host=localhost
cassandra.port=9042
cassandra.username=
cassandra.password=
#cassandra.connect_timeout=5
#cassandra.read_timeout=20
#cassandra.keyspace.strategy=SimpleStrategy
#cassandra.keyspace.replication=3

# hbase backend config
#hbase.hosts=localhost
#hbase.port=2181
#hbase.znode_parent=/hbase
#hbase.threads_max=64
# IMPORTANT: recommend to modify the HBase partition number
#            by the actual/env data amount & RS amount before init store
#            It will influence the load speed a lot
#hbase.enable_partition=true
#hbase.vertex_partitions=10
#hbase.edge_partitions=30

# mysql backend config
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://xbd-mysql:3306
jdbc.username=root
jdbc.password=root
jdbc.reconnect_max_times=3
jdbc.reconnect_interval=3
jdbc.sslmode=false

# postgresql & cockroachdb backend config
#jdbc.driver=org.postgresql.Driver
#jdbc.url=jdbc:postgresql://localhost:5432/
#jdbc.username=postgres
#jdbc.password=
#jdbc.postgresql.connect_database=template1

# palo backend config
#palo.host=127.0.0.1
#palo.poll_interval=10
#palo.temp_dir=./palo-data
#palo.file_limit_size=32

  五、使用

  1、界面查看使用hugegraph-hubble。默认语言采用gremlin。可以参考例子使用:https://hugegraph.apache.org/cn/docs/language/hugegraph-example/

   2、Java版本使用,需要客户端适配

  

  1.0.0版本需要用apache的client。

 

  使用方式:

  1、1.0.0版本以前的可以使用百度的方式。实例如下:

public static void main(String[] args) {

        HugeClient client = HugeClient
                .builder("http://172.17.230.13:8080", "hugegraph")
                .configTimeout(10)
                .build();
        SchemaManager schema = client.schema();

        PropertyKey xbdId = schema.propertyKey("xbd_id").asLong().ifNotExist().create();
        PropertyKey xbdName = schema.propertyKey("xbd_name").asText().ifNotExist().create();
        PropertyKey xbdAge = schema.propertyKey("xbd_age").asInt().ifNotExist().create();

        VertexLabel xbdV = schema.vertexLabel("xbd_v").properties("xbd_id", "xbd_name", "xbd_age").primaryKeys("xbd_id").useAutomaticId().nullableKeys("xbd_name").create();

        EdgeLabel xbdE = schema.edgeLabel("xbd_e").properties("xbd_name").create();

        //data
        GraphManager graph = client.graph();
        Vertex xbd1 = graph.addVertex("xbd_v", JSON.parseObject("{'xbd_name':'xbd_1', 'xbd_age': 1}"));
        Vertex xbd2 = graph.addVertex("xbd_v", JSON.parseObject("{'xbd_name':'xbd_2', 'xbd_age': 2}"));

        xbd1.addEdge("xbd_e", xbd2, JSON.parseObject("{'xbd_name':'xbd_ref'}"));

    }

  2、1.0.0版本以上的目前还不完善,可以参考api的调用方式:地址:https://hugegraph.apache.org/cn/docs/clients/restful-api/

posted @ 2023-10-09 16:28  小不点丶  阅读(1036)  评论(0编辑  收藏  举报