我如何在函数mapobject datawave 2.0中增加变量值? [英] How can i increment variable value inside function mapobject datawave 2.0?

查看:159
本文介绍了我如何在函数mapobject datawave 2.0中增加变量值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在mule4 datawave2.0中的mapobject(我不想使用索引)中增加变量值? 我的代码:

How can i increment variable value inside mapobject(I do not want to use index) in mule4 datawave2.0? My Code:


"Employees":{(inputData.*Employees.*Employee map{

  "Employee": ($) mapObject(v,k) -> {
 ---Increment variable value here
    (k):updateReferenceId(v,($$)+1,v)

  }

})}

推荐答案

您可以在reduce操作的累加器中增加值,然后可以将这些值添加到输出的结构化数据计划中. MuleSoft DataWeave培训课程中有一些示例

You can increment values in the accumulator of a reduce operation, and you can then add these to the structured data plan f the output. There are some examples in the MuleSoft DataWeave training course

flightsInput reduce ( ( flight, acc={ american: {price: 0, count: 0}, delta: {price: 0, count: 0}, united: {price: 0, count: 0} } ) -> flight.airlineName match { case american if(lower(american) contains "amer") -> acc - "american" ++ american: { price: acc.american.price + flight.price, count: acc."american".count + 1 } case delta if(lower(delta) contains "del") -> acc - "delta" ++ delta: { price: acc.delta.price + flight.price, count: acc."delta".count + 1 } case united if(lower(united) contains "uni") -> acc - "united" ++ united: { price: acc.united.price + flight.price, count: acc."united".count + 1 } else -> acc } )

flightsInput reduce ( ( flight, acc={ american: {price: 0, count: 0}, delta: {price: 0, count: 0}, united: {price: 0, count: 0} } ) -> flight.airlineName match { case american if(lower(american) contains "amer") -> acc - "american" ++ american: { price: acc.american.price + flight.price, count: acc."american".count + 1 } case delta if(lower(delta) contains "del") -> acc - "delta" ++ delta: { price: acc.delta.price + flight.price, count: acc."delta".count + 1 } case united if(lower(united) contains "uni") -> acc - "united" ++ united: { price: acc.united.price + flight.price, count: acc."united".count + 1 } else -> acc } )

这将创建具有三个不同关键绩效指标的数据结构:

This creates a data structure with the three different key performance indicators:

这篇关于我如何在函数mapobject datawave 2.0中增加变量值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆