修改密码

请输入密码
请输入密码 请输入8-64长度密码 和 email 地址不相同 至少包括数字、大写字母、小写字母、半角符号中的 3 个
请输入密码
提交

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Blaze (v4)

Standalone

Please complete this required field.

Please complete this required field.

Please complete this required field.

Please complete this required field.

如果不需要 HDC 服务,则此项留空。

Please complete this required field.

如果不需要 HDC 服务,则此项留空。

Please complete this required field.

Please complete this required field.

所有服务器的MAC地址,由换行符或逗号分隔。

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
Shard 服务最大数量
Shard 服务最大总核数
HDC 服务最大数量
HDC 服务最大总核数
申请天数
审批日期
过期日期
MAC地址
申请理由
审核信息
关闭
基础信息
  • 用户昵称:
  • 手机号:
  • 公司名称:
  • 公司邮箱:
  • 地区:
  • 语言:
修改密码
申请证书

当前未申请证书.

申请证书
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

ProductName CreateTime ID Price File
ProductName CreateTime ID Price File

No Invoice

v5.0
搜索
    v5.0

      本节介绍用于管理数据库中图的方法。

      ShowGraph()

      获取数据库中全部的图。

      参数

      • config: *configuration.RequestConfig(可选):请求配置。

      返回值

      • []*structs.GraphSet:获取的图的指针切片。
      • error:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil

      // Retrieves all graphs and prints the names of those with over 2000 edges
      
      graphs, _ := driver.ShowGraph(nil)
      for _, graph := range graphs {
        if graph.TotalEdges > 2000 {
          println(graph.Name)
        }
      }
      

      Display_Ad_Click
      ERP_DATA2
      wikiKG
      

      GetGraph()

      获取数据库中一个指定的图。

      参数

      • graphName: string:图名称。
      • config: *configuration.RequestConfig(可选):请求配置。

      返回值

      • *structs.GraphSet:获取的图的指针。
      • error:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil

      // Retrieves the graph named 'miniCircle'
      
      graph, _ := driver.GetGraph("miniCircle", nil)
      fmt.Println(graph)
      

      &{1438 miniCircle 307 1961  NORMAL [1 2 3] 256 CityHash64}
      

      HasGraph()

      检查数据库中是否存在一个指定的图。

      参数

      • graphName: string:图名称。
      • config: *configuration.RequestConfig(可选):请求配置。

      返回值

      • bool:检查结果。
      • error:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil

      // Checks the existence of a graph named 'miniCircle'
      
      response, _ := driver.HasGraph("miniCircle", nil)
      println(response)
      

      True
      

      CreateGraph()

      在数据库中创建一个图。

      参数

      • graphSet: *structs.GraphSet:待创建的图;Name字段必填,ShardsPartitionByDescription可选。
      • config: *configuration.RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。
      • error:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil

      // Creates a graph
      
      response, _ := driver.CreateGraph(&structs.GraphSet{Name: "testGoSDK", Shards: []string{"1"}, PartitionBy: "Crc32", Description: "testGoSDK desc"}, nil)
      fmt.Println(response.Status.Code)
      

      SUCCESS
      

      CreateGraphIfNotExist()

      在数据库中创建一个图,并返回是否数据库中已有同名图存在。

      参数

      • graphSet: *structs.GraphSet:待创建的图;Name字段必填,ShardsPartitionByDescription可选。
      • config: *configuration.RequestConfig(可选):请求配置。

      返回值

      • ResponseWithExistCheck:请求结果。
      • error:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil

      graph := &structs.GraphSet{Name: "testGoSDK", Shards: []string{"1"}, PartitionBy: "Crc32", Description: "testGoSDK desc"}
      
      result, _ := driver.CreateGraphIfNotExist(graph, nil)
      fmt.Println("Does the graph already exist?", result.Exist)
      if result.Response == nil {
          fmt.Println("Graph creation status: No response")
      } else {
          fmt.Println("Graph creation status:", result.Response.Status.Code)
      }
      
      time.Sleep(3 * time.Second)
      
      fmt.Println("----- Creates the graph again -----")
      result_1, _ := driver.CreateGraphIfNotExist(graph, nil)
      fmt.Println("Does the graph already exist?", result_1.Exist)
      if result_1.Response == nil {
          fmt.Println("Graph creation status: No response")
      } else {
          fmt.Println("Graph creation status:", result_1.Response.Status.Code)
      }
      

      Does the graph already exist? false
      Graph creation status: SUCCESS
      ----- Creates the graph again -----
      Does the graph already exist? true
      Graph creation status: No response
      

      AlterGraph()

      修改数据库中一个图的名称和描述。

      参数

      • graphName: string:图名称。
      • alterGraphset: *structs.GraphSet: 用于设置新的Name和/或Description的指向GraphSet结构体的指针。
      • config: *configuration.RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。
      • error:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil

      // Alters the name and description of the graph 'testPythonSDK'
      
      newGraphInfo := &structs.GraphSet{Name: "newGraph", Description: "a new graph"}
      response, _ := driver.AlterGraph("testGoSDK", newGraphInfo, nil)
      fmt.Println(response.Status.Code)
      

      SUCCESS
      

      DropGraph()

      从数据库中删除一个指定的图。

      参数

      • graphName: string:图名称。
      • config: *configuration.RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。
      • error:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil

      // Drops the graph 'testGoSDK'
      
      response, _ := driver.DropGraph("testGoSDK", nil)
      fmt.Println(response.Status.Code)
      

      SUCCESS
      

      Truncate()

      清空(删除)图中的指定点或边,或清空整个图。请注意,清空点的同时会删除与点相连的所有边。清空操作仅删除点边,图的schema和属性定义仍保留。

      参数

      • params: *structs.TruncateParams: 清空操作的参数;GraphName字段必填,SchemaNameDBType可选。
      • config: *configuration.RequestConfig(可选):请求配置。

      返回值

      • Response:请求结果。
      • error:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil

      // Truncates User nodes in 'myGraph'
      
      NodeType := ultipa.DBType_DBNODE
      response1, _ := driver.Truncate(&structs.TruncateParams{GraphName: "myGraph", SchemaName: "User", DBType: &NodeType}, nil)
      fmt.Println(response1.Status.Code)
      
      // Truncates all edges in the 'myGraph'
      
      EdgeType := ultipa.DBType_DBEDGE
      response2, _ := driver.Truncate(&structs.TruncateParams{GraphName: "myGraph", SchemaName: "*", DBType: &EdgeType}, nil)
      fmt.Println(response2.Status.Code)
      
      // Truncates 'myGraph'
      
      response3, _ := driver.Truncate(&structs.TruncateParams{GraphName: "myGraph"}, nil)
      fmt.Println(response3.Status.Code)
      

      SUCCESS
      SUCCESS
      SUCCESS
      

      Compact()

      清除图中的无效及冗余数据。有效数据不会受到影响。

      参数

      • graphName: string:图名称。
      • config: *configuration.RequestConfig(可选):请求配置。

      返回值

      • JobResponse:请求结果。
      • error:包含操作过程中遇到的任何问题的错误对象;如果操作成功,则返回nil

      // Compacts the graph 'miniCircle'
      
      requestConfig := &configuration.RequestConfig{
          Graph: "miniCircle",
      }
      
      response, _ := driver.Compact("miniCircle", nil)
      jobID := response.JobId
      
      time.Sleep(3 * time.Second)
      jobs, _ := driver.ShowJob(jobID, requestConfig)
      for _, job := range jobs {
          fmt.Println(job.Id, "-", job.Status)
      }
      

      138 - FINISHED
      138_1 - FINISHED
      138_2 - FINISHED
      138_3 - FINISHED
      

      完整示例

      package main
      
      import (
      	"fmt"
      	"log"
      
      	"github.com/ultipa/ultipa-go-sdk/sdk"
      	"github.com/ultipa/ultipa-go-sdk/sdk/configuration"
      	"github.com/ultipa/ultipa-go-sdk/sdk/structs"
      )
      
      func main() {
      	config := &configuration.UltipaConfig{
      		// URI example:	Hosts: []string{"mqj4zouys.us-east-1.cloud.ultipa.com:60010"},
      		Hosts:    []string{"192.168.1.85:60061", "192.168.1.87:60061", "192.168.1.88:60061"},
      		Username: "<usernmae>",
      		Password: "<password>",
      	}
      
      	driver, err := sdk.NewUltipaDriver(config)
      	if err != nil {
      		log.Fatalln("Failed to connect to Ultipa:", err)
      	}
      
      	// Creates a graph
      
      	response, _ := driver.CreateGraph(&structs.GraphSet{Name: "testGoSDK", Shards: []string{"1"}, PartitionBy: "Crc32", Description: "testGoSDK desc"}, nil)
      	fmt.Println(response.Status.Code)
      }
      
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写