我有一个构建不同Flow的对象,每个流都有过滤器,可以丢弃值,因此最终结果可能包含原始源的子集。
代码:
AttributeError Traceback (most recent call last)
<ipython-input-26-f37892b21c8b> in <module>()
----> 1 f(np.pi/2)
/users/vishnu/anaconda3/lib/python3.5/site-packages/numpy /__init__.py in <lambda>(_Dummy_23)
AttributeError: 'Symbol' object has no attribute 'cos'
构建流程后,将它们合并到一个图形中,最终结果是一个csv文件,这是带图形的对象
object RawFlowGeneratorByVehicle {
val deviceEventFilter = (de : DeviceEvent) => de.isValidPosition : Boolean
def buildSpeedFlow(vehicles : List[Vehicle]) : VEHICLERAWFLOW = {
Flow[DeviceEvent].filter(deviceEventFilter)
.groupBy(vehicles.length,de => de.getModemId)
.reduce((a, b) => if(a.getGenerationDate >= b.getGenerationDate) a else b)
.mergeSubstreams
.map(de => VehicleFlowResult(de.getModemId,"Speed",de.getSpeed))
}
def buildCountFlow(vehicles: List[Vehicle], maxSpeed : Double) : VEHICLERAWFLOW = {
Flow[DeviceEvent].filter(deviceEventFilter)
.groupBy(vehicles.length,de => de.getModemId)
.filter(de => de.getSpeed > maxSpeed)
.map(_ -> 1)
.reduce((l, r) => (l._1, l._2 + r._2))
.mergeSubstreams
.map(a => VehicleFlowResult(a._1.getModemId, "SpeedCount", a._2))
}
//...Other flows
}
流量可能有不同的大小,所以我不知道如何合并/ concat / zip ?,生成一个与车辆列表相同大小的行的csv(此列表没有重复值),设置默认值时特定车辆未通过流量过滤器
csv必须是这样的
IMEI;名称;事件;值
AAA; vehicle1;事件1; 100
AAA; vehicle1;事件2; 100
BBB; vehicle2; DefaultEvent;默认值
CCC; vehicle3; Event5; 89
谢谢!