Nebula Graph 如何做多版本控制

问题描述:

  1. nebula graph 如何做多版本控制?
  2. 如何查看 vertex / edge 的版本?如何做版本的回滚?
  3. 执行同样的 insert 语句多次,该 vertex / edge 会生成多个版本吗?

使用场景:
假设数据库里已有一份全量图数据,每天增量更新数据,涉及的可能操作包括:

  • 删除 vertex / edge
  • 新增 vertex / edge

经过增量更新,数据是最新的,但是如果想查询前两天的图数据及关系,如何通过之前的版本查询到?

nebula对增量的插入操作是overwrite操作,不支持查询历史数据。

这里提到的【版本切换】是指?

这个文章里的数据版本指的是集群间的数据版本切换

用ngql语句没法查询历史版本的数据, 但是2.x的客户端提供了Graph Storage Client,可以把历史版本的数据扫描出来:
https://github.com/vesoft-inc/nebula-python/blob/master/nebula2/sclient/GraphStorageClient.py

    def scan_vertex(self,
                    space_name,
                    tag_name,
                    prop_names=[],
                    limit=DEFAULT_LIMIT,
                    start_time=DEFAULT_START_TIME,
                    end_time=DEFAULT_END_TIME,
                    where=None,
                    only_latest_version=False,
                    enable_read_from_follower=True,
                    partial_success=False):
        """
        scan_vertex
        :param prop_names: if given empty, return all property
        :param tag_name: the tag name
        :param space_name: the space name
        :param limit: the max vertex number from one storaged
        :param start_time: the min version of vertex
        :param end_time: the max version of vertex
        :param where: now is unsupported
        :param only_latest_version: when storage enable multi versions and only_latest_version is true,
        only return latest version.
        when storage disable multi versions, just use the default value.
        :param enable_read_from_follower: if set to false, forbid follower read
        :param partial_success: if set true, when partial success, it will continue until finish
        :return: ScanResult
        """