2014-10-10 46 views
0

我使用艾斯波(事件處理引擎),英超查詢:艾斯波:「time_order」似乎不工作

select * from Event.ext:time_order(timestamp_event, 10000 minutes) where duration > 10 

但輸出不受「timestamp_event」下令:

id int = 1, timestamp_event= 1412686800000, duration = 30 
id int = 4, timestamp_event= 1412685900000, duration = 70 
id int = 2, timestamp_event= 1412688600000, duration = 45 
id int = 3, timestamp_event= 1412689500000, duration = 60 
id int = 5, timestamp_event= 1412636400000, duration = 15 

爲什麼「time_order(timestamp_event,10000分鐘)」指令不起作用?

我認爲這個問題是埃斯佩爾配置,讓我們考慮一個簡單的查詢:

select * from Event.win:time(10 sec) order by id_event 

這是UpdateListener的「upate」方法的代碼:

public void update(EventBean[] newEvents, EventBean[] oldEvents) { 
    EventBean event = newEvents[0]; 
    System.out.println("id int = " + event.get("id_event") + ", timestamp_event = " + ((Long)event.get("timestamp_event")).toString()); 

但產量不是由「id_event」命令!

id event = 1, timestamp_event = 1412686800000 
id event = 4, timestamp_event = 1412687700000 
id event = 2, timestamp_event = 1412687100000 
id event = 3, timestamp_event = 1412687400000 
id event = 5, timestamp_event = 1412688000000 

看來既不是「order by」指令不起作用,它怎麼可能?

回答

0

文檔說選擇rstream作爲離開的事件是有序的,而不是事件輸入。請參閱http://esper.codehaus.org/esper-5.0.0/doc/reference/en-US/html_single/index.html#view-time-order

+0

添加「rstream」的輸出是一樣的,有沒有辦法通過時間戳傳遞給Esper有序事件? – paolo789 2014-10-11 09:18:29

+0

你爲什麼不回顧time_order的迴歸測試,看看你的代碼和迴歸代碼的不同之處。鏈接是http://svn.codehaus.org/esper/esper/trunk/esper/src/test/java/com/espertech/esper/regression/view/TestViewTimeOrder.java – user650839 2014-10-13 15:32:50

0

您需要定義某種時間或長度約束。您的聲明只是將所有進入的事件返回到time_order窗口中。

像這樣的例子聲明會給你以正確的順序所有的事件,每1分鐘:

select * from Event.ext:time_order(timestamp_event, 10000 minutes) 
where duration > 10 output snapshot every 1 minute 

或者,你可以定義一個數據窗口,並插入事件到它是這樣的:

create window OrderedEvents.ext:time_order(timestamp_event, 10000 minutes) as select * from Event; 
insert into OrderedEvents select * from Event; 

然後可以使用即席查詢反對,他們會以正確的順序返回的事件(雖然你可以實現一個win:time(10000 minutes)相同,添加order by timestamp_event到您的即席查詢)。

+0

我已經編輯了更多詳細信息的初始文章,似乎沒有「按命令」命令不起作用! – paolo789 2014-10-13 14:54:33

+0

'Order by'不會以這種方式工作,因爲您仍在選擇輸入流,並且在插入時仍然會獲取每個事件。嘗試從Event.win:time(10秒)通過id_event輸出快照每10秒選擇一次*。 – xpa1492 2014-10-13 23:59:55