2014-10-02 2 views
0

나는 시장 데이터를 가져 오기위한 특별한 쿼리를 얻었습니다. 모양은 다음과 같습니다.표현식에서 에스퍼 스트림의 출력을 강제 실행합니다.

select * from L1Quote(Symbol='MSFT') 

새로운 견적이 생길 때마다 작동합니다. 몇 가지 초기 설정을하려면 첫 번째 견적/이벤트가 필요합니다. 이것은 이벤트/따옴표가 매 초마다 실행되는 심볼에서는 문제가되지 않지만 일부 심볼에서는 1 분 동안 새로운 인용 이벤트를 얻지 않습니다.

이 표현식을 설정하기 전에 견적 이벤트가 있었다고 가정하고 작업하십시오. 표현식을 처음 구문 분석 할 때 강제로 출력 할 수 있습니까? 즉 표현할 때 마지막 사건을 말해 줄 수있는 방법이 있을까요?

답변

1

최신 견적을 저장하고 쿼리 할 창을 만들어야합니다.

당신에 에스퍼 EPL :

클라이언트가 모두 창을 조회하고 가입해야합니다
//the L1Quote event definition 
create schema L1Quote(Symbol string, ...) 

//create a window with the same definition as L1Quote and it retain the latest event by Symbol 
create window L1Quotes.std:unique(Symbol) as select * from L1Quote 

//insert all incoming quotes into the window we created 
insert into L1Quotes select * from L1Quote 

:

//subscribe to quote updates 
EPStatement statement = epAdmin.createEPL("select * from L1Quotes(Symbol='MSFT')"); 
statement.addListener([my listener]); 

//get the latest quote 
epEngine.executeQuery("select * from L1Quotes(Symbol='MSFT')"); 
0

Esper는 EPL이 데이터 창이나 패턴을 사용하도록 지정하지 않는 한 오래된 이벤트를 메모리에 유지하지 않습니다. 따라서 귀하가 제공 한 질의에 따라 과거 이벤트가 발생하지 않습니다.

관련 문제