本文整理汇总了Java中org.wso2.siddhi.core.event.in.InEvent类的典型用法代码示例。如果您正苦于以下问题:Java InEvent类的具体用法?Java InEvent怎么用?Java InEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InEvent类属于org.wso2.siddhi.core.event.in包,在下文中一共展示了InEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEvent
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
public void addEvent (InEvent inEvent, Map<Integer, String> paramPositions, int paramCount) {
incCounter++;
eventCount++;
double[] dataX = new double[paramCount];
double[] dataY = new double[1];
dataX[0] = 1.0;
Iterator<Map.Entry<Integer, String>> it = paramPositions.entrySet().iterator();
dataY[0] = ((Number) inEvent.getData(it.next().getKey())).doubleValue();
for(int i=1; i<paramCount; i++) {
dataX[i] = ((Number) inEvent.getData(it.next().getKey())).doubleValue();
}
xValueList.add(dataX);
yValueList.add(dataY);
}
示例2: calculateLinearRegression
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
public Object[] calculateLinearRegression(InEvent inEvent, Map<Integer, String> paramPositions) {
addEvent(inEvent, paramPositions, xParameterCount+1);
// removing oldest events in order to maintain batchsize
if(eventCount > batchSize){
eventCount--;
removeEvent();
}
// processing at a user specified calculation interval
if(incCounter % calcInterval != 0){
return null;
}
return processData();
}
示例3: addEvent
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
public void addEvent (InEvent inEvent, Map<Integer, String> paramPositions, int paramCount) {
eventCount++;
incCounter++;
Iterator<Map.Entry<Integer, String>> it = paramPositions.entrySet().iterator();
yValue = ((Number) inEvent.getData(it.next().getKey())).doubleValue();
yValueList.add(yValue);
xValue = ((Number) inEvent.getData(it.next().getKey())).doubleValue();
xValueList.add(xValue);
sumX += xValue;
sumXsquared += (xValue*xValue);
sumY += yValue;
}
示例4: init
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
@Override
protected void init(Expression[] parameters, QueryPostProcessingElement nextProcessor, AbstractDefinition streamDefinition, String elementId, boolean async, SiddhiContext siddhiContext) {
if (parameters[0] instanceof IntConstant) {
timeToKeep = ((IntConstant) parameters[0]).getValue();
} else {
timeToKeep = ((LongConstant) parameters[0]).getValue();
}
oldEventList = new ArrayList<RemoveEvent>();
if (this.siddhiContext.isDistributedProcessingEnabled()) {
newEventList = this.siddhiContext.getHazelcastInstance().getList(elementId + "-newEventList");
} else {
newEventList = new ArrayList<InEvent>();
}
if (this.siddhiContext.isDistributedProcessingEnabled()) {
window = new SchedulerSiddhiQueueGrid<StreamEvent>(elementId, this, this.siddhiContext, this.async);
} else {
window = new SchedulerSiddhiQueue<StreamEvent>(this);
}
//Ordinary scheduling
window.schedule();
}
示例5: init
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
@Override
protected void init(Expression[] parameters, QueryPostProcessingElement nextProcessor, AbstractDefinition streamDefinition, String elementId, boolean async, SiddhiContext siddhiContext) {
lengthToKeep = ((IntConstant) parameters[0]).getValue();
if (this.siddhiContext.isDistributedProcessingEnabled()) {
window = new SiddhiQueueGrid<StreamEvent>(elementId, this.siddhiContext, this.async);
} else {
window = new SiddhiQueue<StreamEvent>();
}
oldEventList = new ArrayList<RemoveEvent>();
if (this.siddhiContext.isDistributedProcessingEnabled()) {
newEventList = this.siddhiContext.getHazelcastInstance().getList(elementId + "-newEventList");
} else {
newEventList = new ArrayList<InEvent>();
}
}
示例6: send
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
@Override
public synchronized void send(long timeStamp, StreamEvent currentEvent, StreamEvent expiredEvent, String groupByKey) {
if (currentEvent != null) {
if (currentEvent instanceof ListEvent) {
for (int i = 0, size = ((ListEvent) currentEvent).getActiveEvents(); i < size; i++) {
currentGroupByKeyEvents.put(groupByKey, (InEvent) ((ListEvent) currentEvent).getEvent(i));
allGroupByKeyEvents.put(groupByKey + "-current", (InEvent) ((ListEvent) currentEvent).getEvent(i));
}
} else {
currentGroupByKeyEvents.put(groupByKey, (InEvent) currentEvent);
allGroupByKeyEvents.put(groupByKey + "-current", (InEvent) currentEvent);
}
}
if (expiredEvent != null) {
if (expiredEvent instanceof ListEvent) {
for (int i = 0, size = ((ListEvent) expiredEvent).getActiveEvents(); i < size; i++) {
expiredGroupByKeyEvents.put(groupByKey, (InEvent) ((ListEvent) expiredEvent).getEvent(i));
allGroupByKeyEvents.put(groupByKey + "-expired", (InEvent) ((ListEvent) expiredEvent).getEvent(i));
}
} else {
expiredGroupByKeyEvents.put(groupByKey, (InEvent) expiredEvent);
allGroupByKeyEvents.put(groupByKey + "-expired", (InEvent) expiredEvent);
}
}
}
示例7: send
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
@Override
public synchronized void send(long timeStamp, StreamEvent currentEvent, StreamEvent expiredEvent, String groupByKey) {
this.timeStamp = timeStamp;
if (currentEvent != null) {
if (currentEvent instanceof ListEvent) {
for (int i = 0, size = ((ListEvent) currentEvent).getActiveEvents(); i < size; i++) {
currentEventList.add((InEvent) ((ListEvent) currentEvent).getEvent(i));
allEventList.add((InEvent) ((ListEvent) currentEvent).getEvent(i));
}
} else {
currentEventList.add((InEvent) currentEvent);
allEventList.add((InEvent) currentEvent);
}
}
if (expiredEvent != null) {
if (expiredEvent instanceof ListEvent) {
for (int i = 0, size = ((ListEvent) expiredEvent).getActiveEvents(); i < size; i++) {
expiredEventList.add((InEvent) ((ListEvent) expiredEvent).getEvent(i));
allEventList.add((InEvent) ((ListEvent) expiredEvent).getEvent(i));
}
} else {
expiredEventList.add((InEvent) expiredEvent);
allEventList.add((InEvent) expiredEvent);
}
}
}
示例8: sendEvents
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
public synchronized void sendEvents() {
if (groupByKeyEvents.size() == 1) {
Event event = groupByKeyEvents.values().iterator().next().lastInEvent;
sendToCallBacks(timeStamp, event, null, event);
} else if (groupByKeyEvents.size() > 1) {
InEvent[] events = new InEvent[groupByKeyEvents.size()];
int i = 0;
for (LastEventHolder lastEventHolder : groupByKeyEvents.values()) {
events[i] = lastEventHolder.lastInEvent;
i++;
}
StreamEvent streamEvent = new InListEvent(events);
sendToCallBacks(timeStamp, streamEvent, null, streamEvent);
} else {
sendToCallBacks(timeStamp, null, null, null);
}
}
开发者ID:redBorder,项目名称:rb-bi,代码行数:19,代码来源:AllAggregationGroupByWindowedPerSnapshotOutputRateManager.java
示例9: addDataToMap
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
/**
* Add new entry to time stamp map from the received event.
*
* @param event Event received by Siddhi.
*/
private void addDataToMap(InEvent event) {
if (!isActive) {
log.info("Received first event. Marking fault handling window processor as active");
isActive = true;
}
String id = (String) event.getData()[memberIdAttrIndex];
//checking whether this member is the topology.
//sometimes there can be a delay between publishing member terminated events
//and actually terminating instances. Hence CEP might get events for already terminated members
//so we are checking the topology for the member existence
Member member = getMemberFromId(id);
if (null == member) {
log.warn("Member not found in the topology. Event rejected");
return;
}
if (StringUtils.isNotEmpty(id)) {
memberTimeStampMap.put(id, event.getTimeStamp());
} else {
log.warn("NULL member id found in the event received. Event rejected.");
}
if (log.isDebugEnabled()) {
log.debug("Event received from [member-id] " + id + " [time-stamp] " + event.getTimeStamp());
}
}
示例10: addDataToMap
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
/**
* Add new entry to time stamp map from the received event.
*
* @param event Event received by Siddhi.
*/
private void addDataToMap(InEvent event) {
if (!isActive) {
log.info("Received first event. Marking fault handling window processor as active");
isActive = true;
}
String id = (String) event.getData()[memberIdAttrIndex];
//checking whether this member is the topology.
//sometimes there can be a delay between publishing member terminated events
//and actually terminating instances. Hence CEP might get events for already terminated members
//so we are checking the topology for the member existence
Member member = getMemberFromId(id);
if (null == member) {
log.warn(String.format("Member with [id] %s not found in the topology. Event rejected", id));
return;
}
if (StringUtils.isNotEmpty(id)) {
memberTimeStampMap.put(id, event.getTimeStamp());
} else {
log.warn("NULL member id found in the event received. Event rejected.");
}
if (log.isDebugEnabled()) {
log.debug("Event received from [member-id] " + id + " [time-stamp] " + event.getTimeStamp());
}
}
示例11: testDeserialize
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
@Test
public void testDeserialize() throws Exception {
Object[] values = new Object[5];
values[0]= new ColumnNameTypeValue("name", ColumnType.STRING, "test");
values[1]= new ColumnNameTypeValue("value", ColumnType.INTEGER, 10);
values[2]= new ColumnNameTypeValue("enabled", ColumnType.BOOLEAN, true);
values[3]= new ColumnNameTypeValue("numberl", ColumnType.LONG, 123L);
values[4]= new ColumnNameTypeValue("numberf", ColumnType.FLOAT, 13f);
Event event= new InEvent(StreamsHelper.STREAM_NAME, System.currentTimeMillis(), values);
StratioStreamingMessage message= serializer.deserialize(event);
assertEquals("Expected value not found", "test",
((ColumnNameTypeValue) message.getColumns().get(0).getValue()).getValue());
assertEquals("Expected value not found",10,
((ColumnNameTypeValue) message.getColumns().get(1).getValue()).getValue());
assertEquals("Expected value not found", true,
((ColumnNameTypeValue) message.getColumns().get(2).getValue()).getValue());
}
示例12: testDeserializeList
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
@Test
public void testDeserializeList() throws Exception {
List<Event> events= new ArrayList<Event>();
Object[] values = new Object[3];
values[0]= new ColumnNameTypeValue("name", ColumnType.STRING, "test");
values[1]= new ColumnNameTypeValue("value", ColumnType.INTEGER, 10);
values[2]= new ColumnNameTypeValue("enabled", ColumnType.BOOLEAN, true);
events.add(new InEvent(StreamsHelper.STREAM_NAME, System.currentTimeMillis(), values));
values = new Object[3];
values[0]= new ColumnNameTypeValue("name", ColumnType.STRING, "test2");
values[1]= new ColumnNameTypeValue("value", ColumnType.INTEGER, 11);
values[2]= new ColumnNameTypeValue("enabled", ColumnType.BOOLEAN, false);
events.add(new InEvent(StreamsHelper.STREAM_NAME, System.currentTimeMillis(), values));
List<StratioStreamingMessage> messages= serializer.deserialize(events);
assertEquals("Expected value not found", 2, messages.size());
}
示例13: doProcessing
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
private void doProcessing(InEvent event) {
StringBuilder sb = new StringBuilder();
for (Variable cons : constants) {
sb.append(event.getData(cons.getPosition()));
}
String key = sb.toString();
boolean process = false;
if (!lastObjectHash.containsKey(key) || !lastObjectHash.get(key).equals(event.getData(variable.getPosition()))) {
lastObjectHash.put(key, event.getData(variable.getPosition()));
process = true;
}
if (process) {
nextProcessor.process(event);
}
}
示例14: distinctFilterTest
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
@Test
public void distinctFilterTest() throws InterruptedException {
sm.defineStream("define stream testStream (c1 string, c2 float, c3 int);");
sm.addQuery("from testStream #window.stratio:distinct(c1) select c1, c2,c3 insert into resultStream;");
sm.addCallback("resultStream", new StreamCallback() {
@Override
public void receive(Event[] events) {
for (Event event : events) {
if (event instanceof InEvent) {
count.getAndIncrement();
}
}
}
});
sm.getInputHandler("testStream").send(new Object[] { new String("KEY_A"), new Float(10), new Integer(20) });
sm.getInputHandler("testStream").send(new Object[] { new String("KEY_A"), new Float(20), new Integer(30) });
sm.getInputHandler("testStream").send(new Object[] { new String("KEY_A"), new Float(30), new Integer(40) });
sm.getInputHandler("testStream").send(new Object[] { new String("KEY_B"), new Float(30), new Integer(40) });
Thread.sleep(500);
assertEquals(2, count.get());
}
示例15: processEvent
import org.wso2.siddhi.core.event.in.InEvent; //导入依赖的package包/类
@Override
protected InStream processEvent(InEvent inEvent) {
if (log.isDebugEnabled()) {
log.debug("processEvent");
}
// Capture all data elements in the input stream
Object [] inStreamData = inEvent.getData();
Object [] outStreamData;
// Perform Regression and get regression results
Object [] temp = regressionCalculator.calculateLinearRegression(inEvent, paramPositions);
// Send null until the first regression calculation
if(regResult==null && temp==null){
outStreamData = null;
} else {
// For each calculation, get new regression coefficients, otherwise send previous coefficients
if(temp!=null) {
regResult = temp;
}
// Combine Regression Results and Input Stream Data and send to OutputStream
outStreamData = new Object[regResult.length + inStreamData.length];
System.arraycopy(regResult, 0, outStreamData, 0, regResult.length);
System.arraycopy(inStreamData, 0, outStreamData, regResult.length, inStreamData.length);
}
return new InEvent(inEvent.getStreamId(), System.currentTimeMillis(), outStreamData);
}