我以下列格式从模拟中接收数据: 可以看出,目前有两辆车从7号街到11号街(因为它们穿过许多区域,传感器放置在这些区域以监控运动)。
现在我想在汽车#1和汽车#2之间的最新时差仅为3秒或更短时停止信号。 我怎样才能在esper查询语言中做到这一点。 我必须编写复杂事件处理的查询,这将使我在满足上述条件时立即生成事件。 从数据可以看出,最初汽车#1进入7号街的时间是42500,而当#2汽车进入7号街时,时间是42508,时差为8秒。
{ time: 42500,
location: { Zone: 'Z3', Street: 'Street#7' },
carID: 'car#1' }
---------------------------------------
{ time: 42502,
location: { Zone: 'Z5', Street: 'Street#7' },
carID: 'car#1' }
---------------------------------------
{ time: 42502,
location: { Zone: 'Z1', Street: 'Street#8' },
carID: 'car#1' }
---------------------------------------
{ time: 42504,
location: { Zone: 'Z4', Street: 'Street#8' },
carID: 'car#1' }
---------------------------------------
{ time: 42505,
location: { Zone: 'Z5', Street: 'Street#8' },
carID: 'car#1' }
---------------------------------------
{ time: 42505,
location: { Zone: 'Z1', Street: 'Street#9' },
carID: 'car#1' }
---------------------------------------
{ time: 42507,
location: { Zone: 'Z4', Street: 'Street#9' },
carID: 'car#1' }
---------------------------------------
{ time: 42508,
location: { Zone: 'Z3', Street: 'Street#7' },
carID: 'car#2' }
---------------------------------------
{ time: 42508,
location: { Zone: 'Z5', Street: 'Street#9' },
carID: 'car#1' }
---------------------------------------
{ time: 42508,
location: { Zone: 'Z1', Street: 'Street#10' },
carID: 'car#1' }
---------------------------------------
{ time: 42509,
location: { Zone: 'Z4', Street: 'Street#10' },
carID: 'car#1' }
---------------------------------------
{ time: 42509,
location: { Zone: 'Z5', Street: 'Street#7' },
carID: 'car#2' }
---------------------------------------
{ time: 42509,
location: { Zone: 'Z1', Street: 'Street#8' },
carID: 'car#2' }
---------------------------------------
{ time: 42511,
location: { Zone: 'Z5', Street: 'Street#10' },
carID: 'car#1' }
---------------------------------------
{ time: 42511,
location: { Zone: 'Z1', Street: 'Street#11' },
carID: 'car#1' }
---------------------------------------
{ time: 42511,
location: { Zone: 'Z4', Street: 'Street#8' },
carID: 'car#2' }
---------------------------------------
{ time: 42512,
location: { Zone: 'Z4', Street: 'Street#11' },
carID: 'car#1' }
---------------------------------------
{ time: 42512,
location: { Zone: 'Z5', Street: 'Street#8' },
carID: 'car#2' }
---------------------------------------
{ time: 42512,
location: { Zone: 'Z1', Street: 'Street#9' },
carID: 'car#2' }
---------------------------------------
{ time: 42513,
location: { Zone: 'Z5', Street: 'Street#11' },
carID: 'car#1' }
---------------------------------------
{ time: 42513,
location: { Zone: 'Z1', Street: 'Street#12' },
carID: 'car#1' }
---------------------------------------
答案 0 :(得分:0)
这听起来有点像汽车1的事件与汽车2的事件的结合。问题是然后要加入的事件的子集。用例似乎需要保留每辆车访问过的街道历史。为此,我们可以使用长度窗口或独特窗口或这些窗口的并集。让我们使用一个考虑最近10个街道或事件的长度窗口。例如,像这样的查询:
--no-stop-slow-scripts