修改密码

请输入密码
请输入密码 请输入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

v4.5
搜索
    v4.5

      下载与导出

      本节为您介绍如何使用Connection对象的方法下载算法结果文件,从图集导出点和边。

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

      downloadAlgoResultFile()

      下载当前图集一个算法任务中的一个结果文件。

      参数:

      • string:文件名称。
      • string:生成结果文件的算法任务ID。
      • DownloadFileResultListener:下载进程的监听器。
      • RequestConfig(可选):配置请求。

      返回值:

      • Response:请求的结果。

      let requestConfig = <RequestType.RequestConfig>{
        useMaster: true,
        graphSetName: "miniCircle",
      };
      
      // 在图集miniCircle上运行鲁汶算法并打印任务ID
      
      let resp = await conn.uql(
        "algo(louvain).params({phase1_loop_num: 20, min_modularity_increase: 0.001}).write({file:{filename_community_id: 'communityID', filename_ids: 'ids', filename_num: 'num'}})",
        requestConfig
      );
      let myTask = await conn.showTask(
        "louvain",
        RequestType.TASK_STATUS.TASK_DONE,
        requestConfig
      );
      
      let myTaskID = myTask.data.map((item) => item.task_info.task_id)[0];
      console.log("taskID = ", myTaskID);
      
      let myDownload = await conn.downloadAlgoResultFile(
        "communityID",
        myTaskID,
        function (chunkData) {
          fsPromises
            .writeFile(`E:/NodeJs/Algo/communityID`, chunkData)
            .then(() => {
              console.log("Download write success");
            })
            .catch((err) => {
              console.error("Download write error", err);
            });
        },
        {
          graphSetName: "miniCircle",
          stream: {
            onData(data) {
              console.log("Success");
            },
            onEnd() {},
            onError(error) {
              console.error("Download write error");
            },
          },
        }
      );
      

      taskID =  60085
      Success
      Download write success
      

      downloadAllAlgoResultFile()

      下载当前图集一个算法任务中的全部结果文件。

      参数:

      • string:生成结果文件的算法任务ID。
      • DownloadFileResultListener:下载进程的监听器。
      • RequestConfig(可选):配置请求。

      返回值:

      • Response:请求的结果。

      let requestConfig = <RequestType.RequestConfig>{
        useMaster: true,
        graphSetName: "miniCircle",
      };
      
      // 在图集miniCircle上运行鲁汶算法并打印任务ID
      
      let resp = await conn.uql(
        "algo(louvain).params({phase1_loop_num: 20, min_modularity_increase: 0.001}).write({file:{filename_community_id: 'communityID', filename_ids: 'ids', filename_num: 'num'}})",
        requestConfig
      );
      let myTask = await conn.showTask(
        "louvain",
        RequestType.TASK_STATUS.TASK_DONE,
        requestConfig
      );
      
      let myTaskID = myTask.data.map((item) => item.task_info.task_id)[0];
      console.log("taskID = ", myTaskID);
      
      let myDownload = await conn.downloadAllAlgoResultFile(
        myTaskID,
        function (chunkData) {
          fsPromises
            .writeFile(`E:/NodeJs/Algo/LovainResult`, chunkData)
            .then(() => {
              console.log("Download write success");
            })
            .catch((err) => {
              console.error("Download write error", err);
            });
        },
        {
          graphSetName: "miniCircle",
          stream: {
            onData(data) {},
            onEnd() {},
            onError(error) {
              console.error("Download write error");
            },
          },
        }
      );
      

      taskID =  60088
      Download write success
      Download write success
      Download write success
      

      export()

      从当前图集导出点和边。

      参数:

      • RequestType.ExportRequest:导出请求的配置信息,包括dbType:ULTIPA.DBType, schemaName:string, limit:numberselectPropertiesName:string[]
      • ExportListener:导出进程的监听器。
      • RequestConfig(可选):配置请求。

      返回值:

      • Response:请求的结果。

      // 从图集miniCircle名为account的schema导出10个点,并打印点的信息
      
      let requestConfig = <RequestType.RequestConfig>{
        useMaster: true,
        graphSetName: "miniCircle",
      };
      
      let resp = await conn.export(
        {
          dbType: ULTIPA.DBType.DBNODE,
          schemaName: "account",
          limit: 10,
          selectPropertiesName: ["_id", "_uuid", "name", "year"],
        },
        async (n, e) => {
          console.log(n);
        },
        {
          graphSetName: "miniCircle",
          stream: {
            onData(data) {},
            onEnd() {},
            onError(error) {
              console.error("Download write error");
            },
          },
        }
      );
      
      

      [
        Node {
          id: 'ULTIPA8000000000000001',
          uuid: '1',
          schema: 'account',
          values: { name: 'Yu78', year: 1978 }
        },
        Node {
          id: 'ULTIPA8000000000000002',
          uuid: '2',
          schema: 'account',
          values: { name: 'jibber-jabber', year: 1989 }
        },
        Node {
          id: 'ULTIPA8000000000000003',
          uuid: '3',
          schema: 'account',
          values: { name: 'mochaeach', year: 1982 }
        },
        Node {
          id: 'ULTIPA8000000000000004',
          uuid: '4',
          schema: 'account',
          values: { name: 'Win-win0', year: 2007 }
        },
        Node {
          id: 'ULTIPA8000000000000005',
          uuid: '5',
          schema: 'account',
          values: { name: 'kevinh', year: 1973 }
        },
        Node {
          id: 'ULTIPA8000000000000006',
          uuid: '6',
          schema: 'account',
          values: { name: 'alexyhel', year: 1974 }
        },
        Node {
          id: 'ULTIPA8000000000000007',
          uuid: '7',
          schema: 'account',
          values: { name: 'hooj', year: 1986 }
        },
        Node {
          id: 'ULTIPA8000000000000008',
          uuid: '8',
          schema: 'account',
          values: { name: 'vv67', year: 1990 }
        },
        Node {
          id: 'ULTIPA8000000000000009',
          uuid: '9',
          schema: 'account',
          values: { name: '95smith', year: 1988 }
        },
        Node {
          id: 'ULTIPA800000000000000A',
          uuid: '10',
          schema: 'account',
          values: { name: 'jo', year: 1992 }
        }
      ]
      

      完整示例

      import { ConnectionPool, ULTIPA } from "@ultipa-graph/ultipa-node-sdk";
      import { GraphExra } from "@ultipa-graph/ultipa-node-sdk/dist/connection/extra/graph.extra";
      import { getEdgesPrintInfo } from "@ultipa-graph/ultipa-node-sdk/dist/printers/edge";
      import { RequestType } from "@ultipa-graph/ultipa-node-sdk/dist/types";
      import { ListFormat } from "typescript";
      
      let sdkUsage = async () => {
        // 设置连接
        // URI示例: hosts="mqj4zouys.us-east-1.cloud.ultipa.com:60010"
        let hosts = [
          "192.168.1.85:60061",
          "192.168.1.86:60061",
          "192.168.1.87:60061",
        ];
        let username = "***";
        let password = "***";
        let connPool = new ConnectionPool(hosts, username, password);
      
        // 建立与数据库的连接
        let conn = await connPool.getActive();
        let isSuccess = await conn.test();
        console.log(isSuccess);
      
        // 配置请求
        let requestConfig = <RequestType.RequestConfig>{
          graphSetName: "miniCircle",
          useMaster: true,
        };
      
        // 运行鲁汶算法并打印任务ID
        let resp = await conn.uql(
          "algo(louvain).params({phase1_loop_num: 20, min_modularity_increase: 0.001}).write({file:{filename_community_id: 'communityID', filename_ids: 'ids', filename_num: 'num'}})",
          requestConfig
        );
        let myTask = await conn.showTask(
          "louvain",
          RequestType.TASK_STATUS.TASK_DONE,
          requestConfig
        );
        let myTaskID = myTask.data.map((item) => item.task_info.task_id)[0];
        console.log("taskID = ", myTaskID);
      
        // 下载以上算法任务生成的全部文件,打印每个文件的内容和下载响应信息
        let myDownload = await conn.downloadAllAlgoResultFile(
          myTaskID,
          function (chunkData) {
            fsPromises
              .writeFile(`C:/NodeJs/tw/LovainResult`, chunkData)
              .then(() => {
                console.log("Download write success");
              })
              .catch((err) => {
                console.error("Download write error", err);
              });
          },
          {
            graphSetName: "miniCircle",
            stream: {
              onData(data) {},
              onEnd() {},
              onError(error) {
                console.error("Download write error");
              },
            },
          }
        );
      };
      
      sdkUsage().then(console.log).catch(console.log);
      
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写