修改密码

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

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

服务器的MAC地址

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
申请天数
审批时间
过期时间
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

搜索

      执行嬴图GQL

      本节为您介绍如何在嬴图GQL语句中使用Connection对象的uql()方法和uqlStream()方法查询数据库。

      每个示例主要展示如何使用所列方法。点击完整示例查看完整代码示例。

      嬴图GQL(Graph Query Language)是全面操作嬴图数据库的专用语言。更多嬴图GQL的详细信息,请参阅本文档

      uql()

      在当前图集或数据库上执行GQL查询语句并返回查询结果。

      参数:

      • String:待执行的嬴图GQL查询语句。
      • RequestConfig(可选):配置请求。

      返回值:

      • Response:请求的结果。

      // 获取图集miniCircle中@movie下的5个点并打印其名称
      
      RequestConfig requestConfig = new RequestConfig();
      requestConfig.setGraphName("miniCircle");
      
      Response response = client.uql("find().nodes({@movie}) as n return n{*} limit 5", requestConfig);
      List<Node> nodeList = response.alias("n").asNodes();
      for (Node node : nodeList) {
          System.out.println(node.get("name"));
      }
      

      The Shawshank Redemption
      Farewell My Concubine
      Léon: The Professional
      Titanic
      Life is Beautiful
      

      更多示例,请参阅嬴图数据与Java类型映射

      uqlStream()

      在当前图集或数据库上执行GQL查询语句并以增量形式返回查询结果。在处理大型数据集时,无需立刻加载所有数据至内存中。

      参数:

      • String:待执行的嬴图GQL查询语句。
      • UqlListener:流处理监听器。
      • RequestConfig(可选):配置请求。

      返回值:

      • void

      // 获取图集miniCircle的1步路径
      
      RequestConfig requestConfig = new RequestConfig();
      requestConfig.setGraphName("miniCircle");
      
      client.uqlStream("n().e().n() as paths return paths{*}", new UqlListener() {
          int count = 0;
      
          public void onReady() {
              System.out.println("Start downloading");
          }
      
          public void next(Response response) {
              if (response.getStatus().getErrorCode() != Ultipa.ErrorCode.SUCCESS){
                  System.out.println(response.getStatus().getMsg());
              }
              List<Path> paths = response.get(0).asPaths();
              count += paths.size();
              System.out.println("count = " + count);
          }
      
          public void onComplete() {
              System.out.println("Done");
              System.out.println("count = " + count);
          }
      
          public void onError(Throwable throwable) {
              System.out.println("Error");
      
          }
      }, requestConfig);
      

      count = 1250
      count = 1392
      Done
      count = 1392
      

      完整示例

      package com.ultipa.www.sdk.api;
      
      import com.ultipa.sdk.connect.Connection;
      import com.ultipa.sdk.connect.conf.RequestConfig;
      import com.ultipa.sdk.connect.conf.UltipaConfiguration;
      import com.ultipa.sdk.connect.driver.UltipaClientDriver;
      import com.ultipa.sdk.operate.entity.*;
      import com.ultipa.sdk.operate.response.Response;
      import java.util.*;
      
      public class Main {
          public static void main(String[] args) {
               // 设置连接
              UltipaConfiguration myConfig = UltipaConfiguration.config()
                  // URI示例: .hosts("mqj4zouys.us-east-1.cloud.ultipa.com:60010")
                  .hosts("192.168.1.85:60061,192.168.1.86:60061,192.168.1.87:60061")
                  .username("<username>")
                  .password("<password>");
      
              UltipaClientDriver driver = null;
              try {
                  // 建立与数据库的连接
                  driver = new UltipaClientDriver(myConfig);
                  Connection client = driver.getConnection();
                
                  // 配置请求
                  RequestConfig config = new RequestConfig();
                  config.setGraphName("amz");
                  
                  // 获取10个点并打印返回的第一个点的 _id和storeName属性值
                  Response response = client.uql("find().nodes() as n return n{*} limit 10");
                  List<Node> nodeList = response.alias("n").asNodes();
                  System.out.println("ID of the 1st node: " + nodeList.get(0).getID());
                  System.out.println("Store name of the 1st node: " + nodeList.get(0).get("storeName"));
              } finally {
                  if (driver != null) {
                      driver.close();
                  }
              }
          }
      }
      
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写