2017-02-04 6 views
0

を残して、私はちょうどこのような単純なEPLを書く:出力エスパーサンプルから

select symbol, avg(price) as avgprice,count(*) as count,    
current_timestamp() as time from StockTick.win:time(0.4 sec) 
group by symbol 

そして、各100ミリ秒、私は次のようにエスパーにデータをフィード:

StockTick={symbol='YHOO', price=100} 
t=t.plus(0.1 seconds) 
StockTick={symbol='YHOO', price=65} 
t=t.plus(0.1 seconds) 
StockTick={symbol='YHOO', price=75} 
t=t.plus(0.1 seconds) 
StockTick={symbol='YHOO', price=65} 
t=t.plus(0.1 seconds) 
StockTick={symbol='YHOO', price=100} 
t=t.plus(0.1 seconds) 
StockTick={symbol='YHOO', price=15} 

が、私は時間400および500で

Statement: AVGTABLE 
Insert 
AVGTABLE-output={symbol='YHOO', avgprice=76.25, count=4, time=300} 
At: 1970-01-01 00:00:00.400 
Statement: AVGTABLE 
Insert 
AVGTABLE-output={symbol='YHOO',avgprice=68.33333333333333, count=3,  
time=400} 
At: 1970-01-01 00:00:00.400 
Statement: AVGTABLE 
Insert 
AVGTABLE-output={symbol='YHOO', avgprice=76.25, count=4, time=400} 
At: 1970-01-01 00:00:00.500 
Statement: AVGTABLE 
Insert 
AVGTABLE-output={symbol='YHOO', avgprice=80.0, count=3, time=500} 
At: 1970-01-01 00:00:00.500 
Statement: AVGTABLE 
Insert 
AVGTABLE-output={symbol='YHOO', avgprice=63.75, count=4, time=500} 
At: 1970-01-01 00:00:00.600 
Statement: AVGTABLE 
Insert 
AVGTABLE-output={symbol='YHOO', avgprice=60.0, count=3, time=600} 

私は混乱して作る受信出力がありますここに2つのアウトプットがあり、別のイベントが来る前にウィンドウの1つのイベントが残っているように見えます。 irstreamを選択していないので、なぜここに表示されますか? UpdateEventListenerでそれを避けるにはどうすればよいですか?

答えて

0

イベントがタイムウィンドウから期限切れになると、平均値が変化するため、古い平均値が正しくないため、リスナーは新しい平均値を表示します。例えば、時間窓を使わないで避けてください。... from StockTick group by ...

+0

私は過去1日間の平均価格を計算するために時間窓を使いました。この場合、私にヒントを与えることができますか? – kh4nhvu

関連する問題