Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
502 changes: 304 additions & 198 deletions content/cn/docs/config/config-option.md

Large diffs are not rendered by default.

141 changes: 90 additions & 51 deletions content/cn/docs/guides/custom-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ weight: 3

1. HugeGraph 不仅开源开放,而且要做到简单易用,一般用户无需更改源码也能轻松增加插件扩展功能。
2. HugeGraph 支持多种内置存储后端,也允许用户无需更改现有源码的情况下扩展自定义后端。
3. HugeGraph 支持全文检索,全文检索功能涉及到各语言分词,目前已内置 8 种中文分词器,也允许用户无需更改现有源码的情况下扩展自定义分词器。
3. HugeGraph 支持全文检索,全文检索功能涉及到各语言分词,目前已内置 7 种分词器(ansj、hanlp、smartcn、jieba、jcseg、mmseg4j、ikanalyzer),也允许用户无需更改现有源码的情况下扩展自定义分词器。

### 可扩展维度

Expand All @@ -22,7 +22,7 @@ weight: 3
### 插件实现机制

1. HugeGraph 提供插件接口 HugeGraphPlugin,通过 Java SPI 机制支持插件化
2. HugeGraph 提供了 4 个扩展项注册函数:`registerOptions()`、`registerBackend()`、`registerSerializer()`、`registerAnalyzer()`
2. HugeGraph 在 HugeGraphPlugin 接口上以静态方法提供了 4 个扩展项注册函数:`registerOptions()`、`registerBackend()`、`registerSerializer()`、`registerAnalyzer()`
3. 插件实现者实现相应的 Options、Backend、Serializer 或 Analyzer 的接口
4. 插件实现者实现 HugeGraphPlugin 接口的`register()`方法,在该方法中注册上述第 3 点所列的具体实现类,并打成 jar 包
5. 插件使用者将 jar 包放在 HugeGraph Server 安装目录的`plugins`目录下,修改相关配置项为插件自定义值,重启即可生效
Expand Down Expand Up @@ -82,13 +82,18 @@ public class RocksDBStoreProvider extends AbstractBackendStoreProvider {
}

@Override
protected BackendStore newSchemaStore(String store) {
return new RocksDBSchemaStore(this, this.database(), store);
protected BackendStore newSchemaStore(HugeConfig config, String store) {
return new RocksDBStore.RocksDBSchemaStore(this, this.database(), store);
}

@Override
protected BackendStore newGraphStore(String store) {
return new RocksDBGraphStore(this, this.database(), store);
protected BackendStore newGraphStore(HugeConfig config, String store) {
return new RocksDBStore.RocksDBGraphStore(this, this.database(), store);
}

@Override
protected BackendStore newSystemStore(HugeConfig config, String store) {
return new RocksDBStore.RocksDBSystemStore(this, this.database(), store);
}

@Override
Expand All @@ -97,8 +102,8 @@ public class RocksDBStoreProvider extends AbstractBackendStoreProvider {
}

@Override
public String version() {
return "1.0";
public String driverVersion() {
return "1.11";
}
}
```
Expand All @@ -110,41 +115,59 @@ BackendStore 接口定义如下:
```java
public interface BackendStore {
// Store name
public String store();
String store();

// Stored version
String storedVersion();

// Database name
public String database();
String database();

// Get the parent provider
public BackendStoreProvider provider();
BackendStoreProvider provider();

// Get the system schema store
SystemSchemaStore systemSchemaStore();

// Whether it is the storage of schema
boolean isSchemaStore();

// Open/close database
public void open(HugeConfig config);
public void close();
void open(HugeConfig config);
void close();
boolean opened();

// Initialize/clear database
public void init();
public void clear();
void init();
void clear(boolean clearSpace);
boolean initialized();

// Delete all data of database (keep table structure)
void truncate();

// Add/delete data
public void mutate(BackendMutation mutation);
void mutate(BackendMutation mutation);

// Query data
public Iterator<BackendEntry> query(Query query);
Iterator<BackendEntry> query(Query query);
Number queryNumber(Query query);

// Transaction
public void beginTx();
public void commitTx();
public void rollbackTx();
void beginTx();
void commitTx();
void rollbackTx();

// Get metadata by key
public <R> R metadata(HugeType type, String meta, Object[] args);
<R> R metadata(HugeType type, String meta, Object[] args);

// Backend features
public BackendFeatures features();
BackendFeatures features();

// Generate an id for a specific type
public Id nextId(HugeType type);
// Increase next id for specific type
void increaseCounter(HugeType type, long increment);

// Get current counter for a specific type
long getCounter(HugeType type);
}
```

Expand All @@ -155,27 +178,29 @@ public interface BackendStore {

```java
public interface GraphSerializer {
public BackendEntry writeVertex(HugeVertex vertex);
public BackendEntry writeVertexProperty(HugeVertexProperty<?> prop);
public HugeVertex readVertex(HugeGraph graph, BackendEntry entry);
public BackendEntry writeEdge(HugeEdge edge);
public BackendEntry writeEdgeProperty(HugeEdgeProperty<?> prop);
public HugeEdge readEdge(HugeGraph graph, BackendEntry entry);
public BackendEntry writeIndex(HugeIndex index);
public HugeIndex readIndex(HugeGraph graph, ConditionQuery query, BackendEntry entry);
public BackendEntry writeId(HugeType type, Id id);
public Query writeQuery(Query query);
BackendEntry writeVertex(HugeVertex vertex);
BackendEntry writeOlapVertex(HugeVertex vertex);
BackendEntry writeVertexProperty(HugeVertexProperty<?> prop);
HugeVertex readVertex(HugeGraph graph, BackendEntry entry);
BackendEntry writeEdge(HugeEdge edge);
BackendEntry writeEdgeProperty(HugeEdgeProperty<?> prop);
HugeEdge readEdge(HugeGraph graph, BackendEntry entry);
CIter<Edge> readEdges(HugeGraph graph, BackendEntry bytesEntry);
BackendEntry writeIndex(HugeIndex index);
HugeIndex readIndex(HugeGraph graph, ConditionQuery query, BackendEntry entry);
BackendEntry writeId(HugeType type, Id id);
Query writeQuery(Query query);
}

public interface SchemaSerializer {
public BackendEntry writeVertexLabel(VertexLabel vertexLabel);
public VertexLabel readVertexLabel(HugeGraph graph, BackendEntry entry);
public BackendEntry writeEdgeLabel(EdgeLabel edgeLabel);
public EdgeLabel readEdgeLabel(HugeGraph graph, BackendEntry entry);
public BackendEntry writePropertyKey(PropertyKey propertyKey);
public PropertyKey readPropertyKey(HugeGraph graph, BackendEntry entry);
public BackendEntry writeIndexLabel(IndexLabel indexLabel);
public IndexLabel readIndexLabel(HugeGraph graph, BackendEntry entry);
BackendEntry writeVertexLabel(VertexLabel vertexLabel);
VertexLabel readVertexLabel(HugeGraph graph, BackendEntry entry);
BackendEntry writeEdgeLabel(EdgeLabel edgeLabel);
EdgeLabel readEdgeLabel(HugeGraph graph, BackendEntry entry);
BackendEntry writePropertyKey(PropertyKey propertyKey);
PropertyKey readPropertyKey(HugeGraph graph, BackendEntry entry);
BackendEntry writeIndexLabel(IndexLabel indexLabel);
IndexLabel readIndexLabel(HugeGraph graph, BackendEntry entry);
}
```

Expand Down Expand Up @@ -211,25 +236,29 @@ public class RocksDBOptions extends OptionHolder {
"rocksdb.data_path",
"The path for storing data of RocksDB.",
disallowEmpty(),
"rocksdb-data"
"rocksdb-data/data"
);

public static final ConfigOption<String> WAL_PATH =
new ConfigOption<>(
"rocksdb.wal_path",
"The path for storing WAL of RocksDB.",
disallowEmpty(),
"rocksdb-data"
"rocksdb-data/wal"
);

public static final ConfigListOption<String> DATA_DISKS =
new ConfigListOption<>(
"rocksdb.data_disks",
false,
"The optimized disks for storing data of RocksDB. " +
"The format of each element: `STORE/TABLE: /path/to/disk`." +
"Allowed keys are [graph/vertex, graph/edge_out, graph/edge_in, " +
"graph/secondary_index, graph/range_index]",
"The format of each element: `STORE/TABLE: /path/disk`." +
"Allowed keys are [g/vertex, g/edge_out, g/edge_in, " +
"g/vertex_label_index, g/edge_label_index, " +
"g/range_int_index, g/range_float_index, " +
"g/range_long_index, g/range_double_index, " +
"g/secondary_index, g/search_index, g/shard_index, " +
"g/unique_index, g/olap]",
null,
String.class,
ImmutableList.of()
Expand Down Expand Up @@ -267,13 +296,13 @@ public class SpaceAnalyzer implements Analyzer {
```java
public interface HugeGraphPlugin {

public String name();
String name();

public void register();
void register();

public String supportsMinVersion();
String supportsMinVersion();

public String supportsMaxVersion();
String supportsMaxVersion();
}
```

Expand Down Expand Up @@ -301,6 +330,16 @@ public class DemoPlugin implements HugeGraphPlugin {
public void register() {
HugeGraphPlugin.registerAnalyzer("demo", SpaceAnalyzer.class.getName());
}

@Override
public String supportsMinVersion() {
return "1.7.0";
}

@Override
public String supportsMaxVersion() {
return "1.8.0";
}
}
```

Expand Down
14 changes: 12 additions & 2 deletions content/cn/docs/guides/desgin-concept.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ HugeGraph目前采用EdgeCut的分区方案。

### 3. VertexId 策略

HugeGraph的Vertex支持三种ID策略,在同一个图数据库中不同的VertexLabel可以使用不同的Id策略,目前HugeGraph支持的Id策略分别是:
HugeGraph的Vertex支持四种ID策略,在同一个图数据库中不同的VertexLabel可以使用不同的Id策略,目前HugeGraph支持的Id策略分别是:

- 自动生成(AUTOMATIC):使用Snowflake算法自动生成全局唯一Id,Long类型;
- 主键(PRIMARY_KEY):通过VertexLabel+PrimaryKeyValues生成Id,String类型;
- 自定义(CUSTOMIZE_STRING|CUSTOMIZE_NUMBER):用户自定义Id,分为String和Long类型两种,需自己保证Id的唯一性;
- 自定义UUID(CUSTOMIZE_UUID):用户自定义UUID形式的Id,需自己保证Id的唯一性;

默认的Id策略是AUTOMATIC,如果用户调用primaryKeys()方法并设置了正确的PrimaryKeys,则自动启用PRIMARY_KEY策略。
启用PRIMARY_KEY策略后HugeGraph能根据PrimaryKeys实现数据去重。
Expand Down Expand Up @@ -77,6 +78,15 @@ schema.vertexLabel("person")
graph.addVertex(T.label, "person", T.id, 123456, "name", "marko","age", 18, "city", "Beijing");
```

5. CUSTOMIZE_UUID ID策略
```java
schema.vertexLabel("person")
.useCustomizeUuidId()
.properties("name", "age", "city")
.create();
graph.addVertex(T.label, "person", T.id, UUID.randomUUID(), "name", "marko","age", 18, "city", "Beijing");
```

如果用户需要Vertex去重,有三种方案分别是:

1. 采用PRIMARY_KEY策略,自动覆盖,适合大数据量批量插入,用户无法知道是否发生了覆盖行为
Expand Down Expand Up @@ -200,7 +210,7 @@ TinkerPop transaction事务是指对数据库执行操作的工作单元,一

- 服务端内部通过将事务与线程绑定实现隔离(ThreadLocal)
- 本事务未提交的内容按照时间顺序覆盖老数据以供本事务查询最新版本数据
- 底层依赖后端数据库保证事务原子性操作(如Cassandra/RocksDB的batch接口均保证原子性
- 底层依赖后端数据库保证事务原子性操作(如RocksDB的batch接口保证原子性

###### *注意*

Expand Down
8 changes: 4 additions & 4 deletions content/cn/docs/guides/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@ weight: 6

- 如何删除图中的全部数据

管理员可调用 `DELETE /graphspaces/{graphspace}/graphs/{graph}/clear`。请求必须携带源码要求的 `confirm_message`,具体格式见 [Graph API](../clients/restful-api/graphs)。该操作会清除 schema、顶点、边和索引。
管理员可调用 `DELETE /graphspaces/{graphspace}/graphs/{graph}/clear?confirm_message=I'm sure to delete all data`。`confirm_message` 查询参数必须与该值完全一致,否则请求会被拒绝,详见 [Graph API](../clients/restful-api/graphs)。该操作会清除 schema、顶点、边和索引。

- 清空了数据库,并且执行了`init-store`,但是添加`schema`时提示"xxx has existed"

`HugeGraphServer`内是有缓存的,清空数据库的同时是需要重启`Server`的,否则残留的缓存会产生不一致。

- 插入顶点或边的过程中报错:`Id max length is 128, but got xxx {yyy}` 或 `Big id max length is 32768, but got xxx`
- 插入顶点或边的过程中报错:`The max length of vertex id is 16384, but got xxx {yyy}` 或 `The max length of edge id is 65536, but got xxx {yyy}`

为了保证查询性能,目前的后端存储对id列的长度做了限制,顶点id不能超过128字节,边id长度不能超过32768字节,索引id不能超过128字节
为了保证查询性能,目前的后端存储对id列的长度做了限制,顶点id不能超过16384字节,边id长度不能超过65536字节;索引id超过32字节时会转为哈希存储,而不是报错

- 是否支持嵌套属性,如果不支持,是否有什么替代方案

嵌套属性目前暂不支持。替代方案:可以把嵌套属性作为单独的顶点拿出来,然后用边连接起来。

- 一个`EdgeLabel`是否可以连接多对`VertexLabel`,比如"投资"关系,可以是"个人"投资"企业",也可以是"企业"投资"企业"

一个`EdgeLabel`不支持连接多对`VertexLabel`,需要用户将`EdgeLabel`拆分得更细一点,如:"个人投资","企业投资"
可以。创建`EdgeLabel`时对每一对顶点标签各调用一次`link(sourceLabel, targetLabel)`,所有配对都会被保留,因此同一个"投资"标签可以同时覆盖"个人"投资"企业"和"企业"投资"企业"。旧的`sourceLabel()`和`targetLabel()`构建方法已废弃,且只支持单一配对

- 通过`RestAPI`发送请求时提示`HTTP 415 Unsupported Media Type`

Expand Down
7 changes: 4 additions & 3 deletions content/cn/docs/language/hugegraph-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ HugeGraph 相对于 TitanDB 而言,其主要特点如下:
| father | edge | character | character | - |
| mother | edge | character | character | - |
| brother | edge | character | character | - |
| battled | edge | character | character | time |
| pet | edge | character | character | - |
| lives | edge | character | location | reason |

在 HugeGraph 中,每个 edge label 只能作用于一对 source vertex label 和 target vertex label。也就是说,如果一个图内定义了一种关系 father 连接 character 和 character,那 farther 就不能再连接其他的 vertex labels
一个 edge label 可以连接多对 source vertex label 和 target vertex label:创建时对每一对顶点标签各调用一次 `link(sourceLabel, targetLabel)` 即可。已废弃的 `sourceLabel()` 和 `targetLabel()` 构建方法只支持单一配对

因此本例子将原TitanDB中的monster, god, human, demigod均使用相同的`vertex label: character`来表示, 同时增加属性type来标识人物的类型。`edge label`与原TitanDB保持一致。当然为了满足`edge label`约束,也可以通过调整`edge label`的`name`来实现
本例子将原TitanDB中的monster, god, human, demigod均使用相同的`vertex label: character`来表示, 同时增加属性type来标识人物的类型。`edge label`与原TitanDB保持一致。

### 2 Graph Schema and Data Ingest Examples

Expand Down Expand Up @@ -158,7 +159,7 @@ g.V().hasLabel('character').has('name','pluto').out('lives').in('lives').values(

```groovy
pluto = g.V().hasLabel('character').has('name', 'pluto')
g.V(pluto).out('lives').in('lives').where(is(neq(pluto)).values('name')
g.V(pluto).out('lives').in('lives').where(is(neq(pluto))).values('name')

// use 'as'
g.V().hasLabel('character').has('name', 'pluto').as('x').out('lives').in('lives').where(neq('x')).values('name')
Expand Down
Loading