Change Password

Please enter the password.
Please enter the password. Between 8-64 characters. Not identical to your email address. Contain at least 3 of: uppercase, lowercase, numbers, and special characters.
Please enter the password.
Submit

Change Nickname

Current Nickname:
Submit

Apply New License

License Detail

Please complete this required field.

  • Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

The MAC address of the server you want to deploy.

Please complete this required field.

Please complete this required field.

Cancel
Apply
ID
Product
Status
Cores
Applied Validity Period(days)
Effective Date
Excpired Date
Mac Address
Apply Comment
Review Comment
Close
Profile
  • Full Name:
  • Phone:
  • Company:
  • Company Email:
  • Country:
  • Language:
Change Password
Apply

You have no license application record.

Apply
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

Product Created On ID Amount (USD) Invoice
Product Created On ID Amount (USD) Invoice

No Invoice

v4.5
Search
    English
    v4.5

      reduce()

      Function reduce() iterates a designated calculation against each elements in a list one after another. Developers need to define the calculation via an expression, firstly execute the calculation based on an initial value and the 1st element in the list, then re-execute the calculation based on the calculation result and the 2nd element in the list, ... until all elements in the list are traversed.

      The iteration pattern of this function is similar to the 'for' in most programming languages, just that the index of each iteration is not exposed to developers.

      Syntax:

      reduce(<result> = <initial_value>, <element> in <list> | <expression>) 
      
      • <result> denotes the variable name of the calculation result
      • <initial_value> denotes the initial value
      • <element> denotes the variable name of element in the list
      • <list> denotes the alias of the list
      • <expression> denotes the calculation

      Common Usage

      Example: Calculate the sum of all numbers in [1,2,3]

      with [1,2,3] as list
      return reduce(sum = 0, element in list | sum + element) as mySum
      

      6
      

      Sample graph: (to be used for the following examples)

      Run below UQLs one by one in an empty graphset to create graph data:

      create().node_schema("firm").node_schema("human").edge_schema("hold")
      create().edge_property(@hold, "portion", double)
      insert().into(@firm).nodes([{_id:"F001", _uuid:1}, {_id:"F002", _uuid:2}])
      insert().into(@human).nodes([{_id:"H001", _uuid:3}, {_id:"H002", _uuid:4}])
      insert().into(@hold).edges([{_uuid:1, _from_uuid:3, _to_uuid:1, portion:0.3}, {_uuid:2, _from_uuid:2, _to_uuid:1, portion:0.7}, {_uuid:3, _from_uuid:3, _to_uuid:2, portion:0.4}, {_uuid:4, _from_uuid:4, _to_uuid:2, portion:0.6}])
      

      Example: Calculate the share of each UBO of F001

      n({_id == "F001"}).le()[:5].n({@human} as UBO) as p
      with pedges(p) as edgeList
      call{
        with edgeList
        uncollect edgeList as edges
        with collect(edges.portion) as portionList
        return reduce(init = 1, element in portionList | init * element) as share
      }
      group by UBO
      return table(UBO._id, sum(share))
      

      | UBO._id | sum(share) |
      |---------|------------|
      | H001    | 0.58       |
      | H002    | 0.42       |
      
      Please complete the following information to download this book
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写